I have a PIR PIRCeiling and a script script_device_PIRCeiling.lua that should be updating a user variable TIMERCeiling to the value of a var ceilingTimer each time it switches to 'On'. If the switch Ceiling is not already 'On', it should switch it on.
Code: Select all
commandArray={}
ceilingTimer=6
if (deviceChanged['PIRCeiling']=='On' then
if (other devices['Ceiling']=='Off') then
commandArray['Ceiling']='On'
end
commandArray['Variable:TIMERCeiling']=tostring(ceilingTimer)
end
return commandArray
Code: Select all
commandArray={}
if (uservariables['TIMERCeiling']==1) then
if (otherdevices['Ceiling']=='On') then
commandArray['Ceiling']='Off'
end
else
commandArray['Variable:TIMERCeiling']=tostring(uservariables['TIMERCeiling']-1)
end
return commandArray
The problem is that although the switch on happens correctly (but with a few seconds delay - any ideas about that would be welcome), even though there's significant movement that seems to be triggering the PIR, the timer is switching off the light before people leave the room. Any ideas please? (I'm hoping there's something really stupid that I am missing here, so please be brutal!
