Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 64

...

The script can use $msgData and $msgTopic variables. $msgData defines the MQTT message that was published and $msgTopic defines the MQTT topic, where the message was published. Both variables are automatically generated when a new message appears.

Info
  • $msgData and $msgTopic variables will not work when used in the "System>Script" section created scripts, meaning, they will not work inside "/iot mqtt subscriptions set on-message={/system script run x}" added scripts. Both variables will work only when they are used inside the "on-message={}" written script, like, for example, "on-message={:log info "Got data {$msgData} from topic {$msgTopic}"}".
  • The same applies to global variable usage. If there are global variables that are "generated" using other scripts (variables that appear under System>Script>Environment section), they will not work inside the "on-message" script.

After you publish a new MQTT message to the subscribed topic, a new log entry should appear:

...