Motion timer overrules dzvents
Posted: Thursday 23 November 2017 11:56
Hi,
I have this code which turns on lights in one of my kids bedroom when motion detected (i use Aeotec Multisensor 6). I configured the multisensor motion detection to 60 seconds. this part seems to work oke. I wanted to add a variable when time is between x and y that the lights should stay on for 5 minutes instead of the 60 seconds on no motion. I used the forMin(5) for that, but that does not seem to work. I should probably do something different but i have no clue what, can anyone help me in the right direction?
This is my code so far:
Thanks!
I have this code which turns on lights in one of my kids bedroom when motion detected (i use Aeotec Multisensor 6). I configured the multisensor motion detection to 60 seconds. this part seems to work oke. I wanted to add a variable when time is between x and y that the lights should stay on for 5 minutes instead of the 60 seconds on no motion. I used the forMin(5) for that, but that does not seem to work. I should probably do something different but i have no clue what, can anyone help me in the right direction?
This is my code so far:
Code: Select all
return {
active = true,
on = {
devices = {
'Sensor_SK_Jop'
}
},
execute = function(domoticz, device)
if (device.state == 'On') and (domoticz.devices('Lamp_SK_Jop').state == 'Off') and (domoticz.devices('Lux_SK_Jop').lux <= 27) then
if (domoticz.time.hour >= 9) and (domoticz.time.hour <= 19) then
domoticz.scenes('Lamp_SK_Jop_Overdag').switchOn()
domoticz.log('Motion sensor Kamer Jop is aan, Lamp is aangezet op 100% met korte timer')
elseif (domoticz.time.hour >= 19) and (domoticz.time.hour < 20) then
domoticz.scenes('Lamp_SK_PenM_Overdag').switchOn().forMin(5)
domoticz.log('Motion sensor Kamer Jop is aan, Lamp is aangezet op 100% met langere timer')
else
domoticz.devices('Lamp_SK_Jop').switchOff()
domoticz.log('Motion sensor Kamer Jop is aan, Lamp is niet aangezet')
end
elseif (device.state == 'Off') and (domoticz.devices('Lamp_SK_Jop').state == 'On') then
domoticz.devices('Lamp_SK_Jop').switchOff()
domoticz.log('Motion sensor Kamer Jop is uit, Lamp is uitgezet')
end
end
}