I think it's a very simple script, but I'm not sure that I use the correct timer triggers. I want to turn on my hallway light when the front door is open. But only during nighttime. When the door is closed, the light must go off after 30 seconds. First I had this:
Code: Select all
return {
active = true,
on = {
devices = {
'front door'
},
timer = {
'at nighttime'
},
},
execute = function(domoticz, door)
local light = domoticz.devices('Hallway')
if (door.state == 'Open') then
light.switchOn()
else
light.switchOff().afterSec(30)
end
end
}
So now I thought of this script, but I'm not sure how to use the boolean 'domoticz.time.atNightTime'. So should this do the trick?
Code: Select all
return {
active = true,
on = {
devices = {
'front door'
},
},
execute = function(domoticz, door)
local light = domoticz.devices('Hallway')
if (domoticz.time.isNightTime and door.state == 'Open') then
light.switchOn()
else
light.switchOff().afterSec(30)
end
end
}I'm not sure if I'm doing this correct. Should I let the door trigger this script or the timer?