Code: Select all
-- script_time_infraredpanel.lua
t1 = os.time()
s = otherdevices_lastupdate['Badkamer infraroodpaneel']
-- returns a date time like 2013-07-11 17:23:12
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))
-- 45 minutes translates to 2700 seconds, after being on for that time, the panel is switched off and a notification is send (if concigured in Domoticz)
if (otherdevices['Badkamer infraroodpaneel'] == 'On' and difference > 2700 and difference < 2710) then
commandArray['SendNotification']='Infrarood paneel melding#Het paneel staat meer dan 45 minuten aan en gaat nu uit!'
commandArray['Badkamer infraroodpaneel']='Off'
end
return commandArray