I need some help
The purpose of this script is that when the sensor turns on, it turns on the lamp.
The lamp may only go out after 10 minutes if the sensor is also off.
So as long as the sensor is on, the lamp must also remain on.
But if the sensor switches off and on again within 10 min, the 10 min must be restarted.
Now the lamp always switches off after 10 minutes and then immediately on again.
Does anyone have the solution for me.
Or is this not possible
Code: Select all
return
{
on =
{
devices = {
'Lamp',
'Sensor',
},
},
execute = function(dz)
local sensor = dz.devices('Sensor')
local lamp = dz.devices('Lamp')
if sensor.state == 'On' then
lamp.switchOn().silent()
end
if sensor.state == 'Off' then
lamp.switchOff().afterMin(10)
end
end