I've a dummy switch which is called "Beweging_Woonkamer". It's updated by 2 PIR's and is automatically switched off after 20 minutes. Now I have a light script for the dining room and sitting room and want to only execute the script if the status from "Beweging_Woonkamer" is changed (In my logic On > On is no status change). Because of the PIR's multiple On commands are sent if there is movement. I thought this could be achieved with the device.changed but this is not working. If I write the status of the device.change to the domzoticz log then its true even if I have multiple On commands and no change to off. Is my thinking wrong or does device.changed not work this way. Is there another solution to solve this?
Code: Select all
return {
active = true,
on = {
devices = { 'Beweging_Woonkamer',
'Beweging_Eetkamer' }
},
execute = function(dz, device)
if (device.name == 'Beweging_Woonkamer') and device.changed then
if (device.state == 'Off') then
dz.groups('Lampen_Woonkamer').switchOff()
elseif (dz.time.matchesRule('at nighttime') and device.state == 'On') then
if dz.devices('Harmony-PowerOff').state == 'On' then
dz.scenes('Avond').switchOn()
dz.log('Avond is ingeschakeld')
else
dz.scenes('TV_verlichting').switchOn()
dz.log ('TV verlichting is ingeschakeld')
dz.log (device.changed)
end
end
end
if (device.name == 'Beweging_Eetkamer') and device.changed then
if (device.state == 'Off') then
dz.groups('Lampen_Eetkamer').switchOff()
elseif (dz.time.matchesRule('at nighttime') and device.state == 'On') then
dz.groups('Lampen_Eetkamer').switchOn()
end
end
end
}