...
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}"}". |
After you publish a new MQTT message to the subscribed topic, a new log entry should appear:
...