simple dzVents script
Posted: Friday 28 July 2017 11:19
I'm new with dzVents and I'm trying to create my first simple script with it. I think it's far more powerful then the basic lua. But i'm having some issues with some triggers and need some help.
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:
But then the light will stay on during nighttime if i'm correct. Because of the timer in the on section.
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?
I tried to found some examples, but I haven't found any.
I'm not sure if I'm doing this correct. Should I let the door trigger this script or the timer?
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?