I'm having a bit of trouble to do the following using dzVents:
- Shutdown a remote host using os.execute over ssh from a local host (e.g. domoticz that shutsdown another raspbeery pi)
What did I do:
- installing keys to remotely ssh without a password (

- verified from local cli on domoticz pi that command used is working to shutdown remote host (

- verified from local cli on domoticz pi that using "normal" lua without dzvents, code is working (

- Using a script on the remote host to shutdown, containing simple "sudo shutdown now" triggered over ssh from local host with
Code: Select all
ssh [email protected] sh /home/pi/shutdown.sh

- Directly triggering from local host to remote host with
Code: Select all
ssh [email protected] sh sudo shutdown now

- trying both the "os.execute" and "assert(io.popen(cmd, 'r')" way using a standard lua script on local host (

What is the problem:
When using dzvents do accomplish the same as above, it is not working. Even if relevant parts of lua codes that works in standard lua get copied to dzvents.
Full Script:
Code: Select all
return {
on = {
devices = {
'Werkkamer - Sw_L'
}
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "P3STEELSWITCH.LUA"
},
execute = function(domoticz, switch)
local cmd = "ssh [email protected] sh /home/pi/shutdown.sh"
domoticz.log(switch.state)
if(domoticz.devices('Werkkamer - P3Steel').state == 'On') then
if(domoticz.devices('Werkkamer - P3Steel').lastUpdate.minutesAgo >= 1) then
domoticz.log("3D printer powered on > 1 minute ago, shutdown")
domoticz.log(cmd)
os.execute(cmd)
--local f = assert(io.popen(cmd, 'r'))
--s = assert(f:read('*a'))
--f:close()
--print(s)
--domoticz.log(s)
domoticz.devices('Werkkamer - P3Steel').switchOff()
else
domoticz.log("3Dprinter powered on < 1 minute ago, don't shutdown.")
end
else
domoticz.devices('Werkkamer - P3Steel').switchOn()
end
end
}
Code: Select all
local cmd = "ssh [email protected] sh /home/pi/shutdown.sh"
Code: Select all
os.execute(cmd)
Code: Select all
local f = assert(io.popen(cmd, 'r'))
s = assert(f:read('*a'))
f:close()
--print(s)
domoticz.log(s)