Im have been using domoticz a long time, but new to Lua.
I am trying to get this script to turn off my lights, when there has been no movement on a sensor for a specified amount of time.
the utility lights work fine every time.
But the landing lights dont work. it doesnt even print ('Checking landing lights') in the log.
has anyone got any ideas as to why this isnt working?
is there a limit to the number of things you can use the timedifference function for in a script?
im on Version: 3.8153
Thanks,
Sion.
Code: Select all
-- script_time_Lights_out.lua
function timedifference (s)
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
commandArray = {}
if (otherdevices ['HOME_SECURED'] == 'Off') then
if (otherdevices ['Util_spot_1'] == 'On') then
print('evaluating utility room')
if (otherdevices['utility_sensor'] == 'Off') and (timedifference(otherdevices_lastupdate['utility_sensor']) > 600) then
commandArray['Utility_Dummy']='Off'
print('turning off utility lights')
end
end
end
if (otherdevices['landing_light'] == 'On' ) then
print ('Checking landing lights')
if (timedifference(otherdevices_lastupdate['landing_pir']) > 900 ) then
print ('turning off landing light')
commandArray['landing_light']='Off'
end
end
return commandArray