I have the following problem.
I have a doorswitch installed in Domoticz.
I installed with this youtube video https://www.youtube.com/watch?v=Oq-hN-RJ2sA
The switch is working with the following code to turn on the light.
Code: Select all
return {
active = true,
on = {
devices = {
['Achterdeur'] = { 'at nighttime' }
}
},
execute = function(domoticz, door)
local light = domoticz.devices('Buitenlamp achter')
if (door.state == 'Open') then
light.switchOn()
end
end
}
But when the door is closed i want to turn off the light, but it doesn't work.
It looks like the only state of the door is open.
I used the following code to turn off the light.
Code: Select all
return {
active = true,
on = {
devices = {
['Achterdeur'] = { 'at nighttime' }
}
},
execute = function(domoticz, door)
local light = domoticz.devices('Buitenlamp achter')
if (door.state == 'closed') then
light.switchOff().afterSec(10)
end
end
}