can you please tell me why this script run fine if copy/pasted in terminal while won't do anything if started from "Run Script" push button ?
Thanks, BR
Code: Select all
# RouterOS v. 7.6
# Required packages: iot
:global currentIP;
:global newIP [/ip address get [find interface="ether1"] address];
:if ($newIP != $currentIP) do={
:put "ip address $currentIP changed to $newIP";
:set currentIP $newIP;
}
:global broker "MYBroker"
:global topic "devices/mk/news"
:global message
:set $message
"{\
\"clientId\":\"$[/iot mqtt brokers get value-name=client-id \
[/iot mqtt brokers find name=$broker]]\",\
"$currentIP" \
}\
}]\
}"
:log info "$message";
:put ("[*] Total message size: $[:len $message] bytes")
:put ("[*] Sending message to MQTT broker...")
/iot mqtt publish broker=$broker topic=$topic message=$message