Changes on payload context in custom MQTT topic?

Hello,

Are there any modifications to the action’s communication with the device using the custom MQTT topic?

Until now I was given a structure, and a few minutes ago it changed.

Before

[
  {
    variable: "payload",
    value: "#01,1,1,1,1,1,250,250,1",
    metadata: {
      mqtt_topic: "farm/STATUS",
    },
  },
];

Later

Raw payload

[
    '#01,1,1,1,1,1,250,250,1'
]

I think I figured out the problem.

When I publish in a certain topic with a numeric value (even if it is a string), the context is not assembled correctly, however, when I publish a character everything works normally.

hi @douglaszuqueto,

It’s correct. The payload variable is auto-generated if you send a string.

Anyway, you can see what’s coming in your inspector and prepare your payload parser for these scenarios.

1 Like

Hi @eger

But when I send “0”, everything works as expected, but when I send “1”, “2”… the result is different.

  • When I send “0”:
Raw payload
[
    {
        "variable": "payload",
        "value": "0",
        "metadata": {
            "mqtt_topic": "douglas/PAINEL"
        }
    }
]

Command: mosquitto_pub -h mqtt.tago.io -u token -P token -t douglas/PAINEL -m "0"

  • When I send “1”:
Raw payload
[
    1
]

Command: mosquitto_pub -h mqtt.tago.io -u token -P token -t douglas/PAINEL -m "1"

I think in both contexts the behavior should be the same :thinking:

@douglaszuqueto I’ll check this case.

@eger, any updates about this?

hi @douglaszuqueto,

I already fixed it, but it’s not in production yet. Probably will this afternoon, I let you know.

For your information when sending 0 or 1 the payload will be:

[
    {
        "variable": "payload",
        "value": "your number",
        "metadata": {
            "mqtt_topic": "douglas/PAINEL"
        }
    }
]
1 Like

Thank you very much @eger.

1 Like

hi @douglaszuqueto,

The update is in production!

Now when you send 0 or 1 the result will be:

[
    {
        "variable": "payload",
        "value": "your number",
        "metadata": {
            "mqtt_topic": "douglas/PAINEL"
        }
    }
]

Thanks for your feedback!

1 Like

Thanks @eger.

I tested it and everything is ok.

1 Like