MQTT publish/suscript from Script

Script programming can be used to get data from subscribed topics of publish extra topics.

war

Please go to the script programming manual for more information.

Script - Suscription

You can subscribe to up to 10 topics

mqttcfgpubtopic

mqttcfgpubtopic

The use read_io 1000 to get the messages on the script

                read_io 1000,b,0;

                b how may messages are queued waiting to be read

To get the first message in the queue use read_str 1000

                read_str 1000,c,z;

                z message text

Script - Publish

You public message straight from the script code

Go to the script programming manual for more information.

Before publishing it's suggest it to check if the broker connection is established

                read_io 1001,h,0;

                h=1 connection established

Then set the topic to publish

                write_str 1001,'v1/devices/me/telemetry';

And finally set the payload. This operation will also publish the message.

                write_str 1002,'{A1:52}'; 

2020-11-20