os.execute mqtt commands  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
adval40
Posts: 14
Joined: Sunday 28 May 2017 18:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11528
Location: Eindhoven (The netherlands)
Contact:

os.execute mqtt commands

Post by adval40 »

I want send commands to my mqtt server with dzvents
I think i have an error with quotes

Code: Select all

execute = function(domoticz, device)
		
		domoticz.log(device.state)
		
		if (device.state =='On') then 
	    		os.execute('mosquitto_pub -h 127.0.0.1 -t milight/0x40/cct/0 -u mqtt -P mqtt -m {"status":"on"}  ')
	    	elseif (device.state =='Off') then 
	    		os.execute('mosquitto_pub -h 127.0.0.1 -t milight/0x40/cct/0 -u mqtt -P mqtt -m {"status":"off"} ')	
	  	end
can anyone tell me the exact settings?
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: os.execute mqtt commands

Post by jvdz »

maybe ?:

Code: Select all

os.execute('mosquitto_pub -h 127.0.0.1 -t milight/0x40/cct/0 -u mqtt -P mqtt -m \'{"status":"on"}\'  ')
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
adval40
Posts: 14
Joined: Sunday 28 May 2017 18:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11528
Location: Eindhoven (The netherlands)
Contact:

Re: os.execute mqtt commands  [Solved]

Post by adval40 »

it works

thanks Jos

greetings from eindhoven
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest