Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • serverName: The server name as shown in the MQTT Engine > Servers configuration
    • Note: This is the Name and not the URL configuration parameter
  • mqttTopic: The MQTT Topic to publish on
  • payload: The MQTT payload
  • qos: The MQTT quality of service to publish on
  • retain: Whether or not to set the retain flag in the MQTT message
Note

If your payload contains escape characters such as backslash you will need to use the 'r' modifier on your payload string to ensure these are included

payload = r{"metadata" : {},"plan" : {"requiredState" : {"value_control" :"{\"pump_1\":{\"4\":\"off\",\"3\":\"off\",\"2\":\"off\",\"1\":\"off\"},},},}}"},"state" : {}},"version" : 12}


When complete, the script should look something like this.  Now click OK.

...

Finally, save and publish the project.  At this point every time this tags value, quality, or timestamp changes it will result in a MQTT message being published on topic 'a/b/c' with a payload of 'hello world'.


Additional JSON examples:

payload=str('{"name":"John", "age":30, "car":"BMW"}').encode()


Additional Resources