Im trying to get a night light script going.
We have a switch that we toggle when we go to sleep. Virt_SLEEP
So when this switch are on and there are motion in the kithchen or hallway so should the light go on and 35sec after no motion so should they go off.
But when Virt_SLEEP are off so will the script go on any way.
Code: Select all
----------------------------------------
-- Night Light in Hallway and Kitchen --
----------------------------------------
return {
on = { devices = {'PIR*','Virt_SLEEP'} },
execute = function(domoticz)
if domoticz.devices('Virt_SLEEP').state == "On" and
domoticz.devices('PIR_Kök').state == "Off" and
domoticz.devices('PIR_Hall').state == "Off" and
domoticz.devices('Presence detection - Anyone').state == "On" then
domoticz.devices('Kök: Led MI').switchOff().afterSec(35)
domoticz.devices('Hall: Led MI').switchOff().afterSec(35)
print("Night Light Off")
end
if domoticz.devices('Virt_SLEEP').state == "On" and
domoticz.devices('PIR_Kök').state == "On" or
domoticz.devices('PIR_Hall').state == "On" and
domoticz.devices('Presence detection - Anyone').state == "On" then
domoticz.devices('Kök: Led MI').dimTo(40)
domoticz.devices('Hall: Led MI').dimTo(40)
print("Night Light 40%")
end
end
}Regards Magnus Svensson