This works good, but i also have front door. If i use the same script for the front door (in total 2 different scripts) only the backdoor working.
When i rename the frontdoor scripts name so the front door is above the backdoor script, only the frontdoor is working.
Can you only run one "time difference" script?
How can i merge this scripts so it checks the back and front door?
Code: Select all
-- Automatically adjust heating setpoint to 12 when back door is left open.
t1 = os.time()
s = otherdevices_lastupdate['Achterdeur']
heater = otherdevices_svalues['Toon Thermostaat']
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)
commandArray = {}
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
if (otherdevices['Achterdeur'] == 'Open' and difference > 59 and difference < 65) then
commandArray['SendNotification']='Achterdeur waarschuwing#De Achterdeur staat al meer dan 5 minuten open'
commandArray['UpdateDevice']='335|0|12.00'
print("De Achterdeur staat open, zet de thermostraat op 12 graden celsius")
end
return commandArray