Run every time if switch on
Posted: Tuesday 25 July 2017 8:04
I trying to write scrip with will be switch on and off my CWU pomp. i need condition: if switch on switch on another switch for 1 min every 10 min. My script working only when switch on but when time is triger i have info "'device' (a nil value)"
Code: Select all
return {
-- 'active' controls if this entire script is considered or not
active = true, -- set to false to disable this script
-- trigger
-- can be a combination:
on = {
devices = {
-- scripts is executed if the device that was updated matches with one of these triggers
'Testsw', -- device name
},
timer = {
-- timer triggers.. if one matches with the current time then the script is executed
'every 10 minutes'
},
},
-- actual event code
-- in case of a timer event or security event, device == nil
execute = function(domoticz,device)
domoticz.log('Alarm zmienił stan')
-- local testsw = domoticz.devices('Testsw')
if (device.state == 'On') then
local pompaCWU = domoticz.devices('Pompa CWU')
pompaCWU.switchOn()
end
end
}