I am in a roadblock since few months on this issue with my OS execute command
Do you have an idea to where i should look for ?
What is working:
This command directly from my Pi is
pi@raspberrypi:~ $ mosquitto_pub -h mqtt.xxxxxx.net -t domoticz/out/esp11_relai1 -m 1
What I see on my MQTT broker is
domoticz/out/esp11_relai1 1
My ESP perfectly handle that and my hardware relay switch on as expected
What is not working
I am trying do the same set of command but from Domoticz switch icon
To do so i wrote a small LUA script. Name of the script is
script_device_RelaisChevret.lua
--Quote
--------------------------------
------ Variables to edit ------
--------------------------------
devicename = "RelaisChevret"
--deviceIDX = 18
debug = false
--------------------------------
-- End of variables to edit --
--------------------------------
commandArray = {}
if (devicechanged[devicename]) then
print(devicename.." MQTT script running...")
if (devicechanged[devicename] == "On") then
print(devicename.." turned on!")
os.execute('mosquitto_pub -h mqtt.xxxxxx.net -t domoticz/out/esp11_relai1 -m "1"')
elseif (devicechanged[devicename] == "Off") then
print(devicename.." turned off!")
os.execute('mosquitto_pub -h mqtt.xxxxx.net -t domoticz/out/esp11_relai1 -m "0"')
end
end
for i, v in pairs(devicechanged) do print(" " .. i .. ' : ' .. v)
end
return commandArray
--Unquote
What I can see in domoticz log is
(Switch avec script lua) Light/Switch (ESP11_Relai1)
Status: User: Admin initiated a switch command (18/ESP11_Relai1/On)
Status: LUA: ESP11_Relai1 : On
What I see in MQTT with a sub command
pi@raspberrypi:~ $ mosquitto_sub -h mqtt.xxxxxxx.net -t domoticz/out/# -v
is
domoticz/out {
"Battery" : 255,
"RSSI" : 12,
"description" : "",
"dtype" : "Light/Switch",
"id" : "00014062",
"idx" : 18,
"name" : "ESP11_Relai1",
"nvalue" : 1,
"stype" : "Switch",
"svalue1" : "0",
"switchType" : "On/Off",
"unit" : 1
My problem is that it is not seen from my ESP easy
Conclusion :
My script is running correctly but
print(devicename.." turned on!") is not printed in Domoticz log
os.execute('mosquitto_pub -h mqtt.xxxxxx.net -t domoticz/out/esp11_relai1 -m "1"') is not executed
Any idea ?
Script Lua on Domoticz and OS Execute command - PI Raspbian
Moderators: grovkillen, Stuntteam, TD-er
Script Lua on Domoticz and OS Execute command - PI Raspbian
Signed XMenne from France
Re: Script Lua on Domoticz and OS Execute command - PI Raspbian
Are you sure you're checking the right devicename? I see: RelaisChevret vs ESP11_Relai1
Also have a look at ESPEasy plugin P029 Domoticz MQTT helper. Then you do not need LUA.
Also have a look at ESPEasy plugin P029 Domoticz MQTT helper. Then you do not need LUA.
Re: Script Lua on Domoticz and OS Execute command - PI Raspbian
Many thanks @wim16
I just discovered Domoticz MQTT helper and it solves my problem
Fantastic . Thanks again #wim16
I just discovered Domoticz MQTT helper and it solves my problem
Fantastic . Thanks again #wim16
Signed XMenne from France
Who is online
Users browsing this forum: No registered users and 32 guests