Page 1 of 1

LUA command to publish MQTT message

Posted: Tuesday 20 November 2018 13:59
by brjhaverkamp
Hello all,

I want to connect from domoticz to my node-red instance on the same RPI to control some MQTT systems.
I need to do this preferably from a LUA script. Does anyone have a good simple example of how to publish an mqtt message?
I understand from partial hints and wikis that it should be done with
CommandArray['OpenURL']= and then a JSON line. But I have not been able to find a working example to start experimenting from.

Any help is appreciated.

Bert

Re: LUA command to publish MQTT message

Posted: Tuesday 20 November 2018 14:02
by emme
first install mosquitto_clients

Code: Select all

sudo apt-get install mosquitto_pub
then in your script you can use:

Code: Select all

os.execute('mosquitto_pub -h 127.0.0.1 -t my/topic -m '..myPayload)