The first part (updating variable to ON if any of the sensors is on) is working fine.
However, I am having issues with the other part - if all sensors are off, then update variable to off
My script:
Devices I need to loop through
Code: Select all
--list of all my motion sensors
motion_triggers ={
'OB_MS6 - Motion Sensor',
'LO_FGMS001 - Sensor',
'KP_FGMS001 - Sensor',
'CH_FGMS001 - Sensor',
}
Code: Select all
for i, motion_trigger in ipairs(motion_triggers) do --loop through motion_triggers
if devicechanged[motion_trigger] then --any sensor changed
if otherdevices[motion_trigger] == 'On' then --any sensor is ON
if uservariables['PRESENCE_DETECTED'] ~= 'on' then --only update variable if it is not equal to on (to keep update time)
commandArray['Variable:PRESENCE_DETECTED'] = 'on' --update PRESENCE_DETECTED variable to ON
break
end
end
end
end
I have spent all day on this, so any help would be welcome.