i have several motion detectors in my house wich are turning on lights, what is working perfectly well in a lua script,
but 1 device refused to go OFF after x seconds no motion detected.
Turning ON device works, like all other do:
Trigger=DEVICE:
Code: Select all
commandArray = {}
if devicechanged['Zigbee - BewegingBadkamer'] == 'On'
then
commandArray[#commandArray+1] = {['LampBadkamer'] ='Set Level 70' }
commandArray[#commandArray+1] = {['LampBadkamer'] ='Set Level 70 AFTER 1' }
print('Verlichting Badkamer AAN')
end
return commandArray
Trigger=TIME:
Code: Select all
commandArray = {}
function datetimedifferencenow(s)
s = s .. ":00"
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year = year, month = month, day = day, hour = hour, min = minutes, sec = seconds}
difference = os.difftime(t1, t2)
return difference
end
if otherdevices['Zigbee - BewegingBadkamer'] == 'Off' and datetimedifferencenow(otherdevices_lastupdate['Zigbee - BewegingBadkamer']) >= 240 and datetimedifferencenow(otherdevices_lastupdate['Zigbee - BewegingBadkamer']) <= 300
then
commandArray[#commandArray+1] = {['LampBadkamer'] ='Off'}
commandArray[#commandArray+1] = {['LampBadkamer'] ='Off AFTER 1'}
print('Verlichting Badkamer UIT')
end
return commandArray
Also tried to make a new script and also with a new name, and tried a remote switch as well, but nothing worked.
All other scripts and lights/motions are working perfectly with exactly the same scripts.
The motion is sending out the ON/OFF state correctly, and light goes ON correctly, but it does never turning OFF..
Thanks!