Turn of dummy switch if no motion after 30 min.
Posted: Friday 06 October 2017 13:43
Hi, how can i get this script to turn off HouseSw, only if any of the other switches is off, and have not been turned on again within 30 minutes?
Also the notification gets sendt immediately, I wan't it to wait until the HouseSw is off.
Thanks 
Also the notification gets sendt immediately, I wan't it to wait until the HouseSw is off.
Code: Select all
return {
active = true,
on = {
devices = {'Bevegelse Stue'},
devices = {'Bevegelse Gang'},
devices = {'Test'},
},
execute = function(domoticz, device)
-- your script logic goes here, something like this:
local HouseSw = domoticz.devices('Bevegelse i Huset')
local LvgrmSw = domoticz.devices('Bevegelse Stue')
local HallSw = domoticz.devices('Bevegelse Gang')
local TestSw = domoticz.devices('Test')
if (HouseSw.state == 'Off') and ((TestSw.state == 'On') or (LvgrmSw.state == 'On') or (HallSw.state == 'On')) then
HouseSw.switchOn()
domoticz.notify('Bevegelse', 'Noen beveger seg i huset.', domoticz.PRIORITY_LOW)
domoticz.log('Noen beveger seg i huset.')
elseif (HouseSw.state == 'On') and (TestSw.state == 'Off') and (LvgrmSw.state == 'Off') and (HallSw.state == 'Off') then
HouseSw.switchOff().afterMin(30)
domoticz.notify('Ingen bevegelse', 'Ingen bevegelse i huset.', domoticz.PRIORITY_LOW)
domoticz.log('Ingen bevegelse i huset.')
end
end
}
