Small LUA script for switching off an infrared panel in our bathroom after 45 minutes

For heating/cooling related questions in Domoticz

Moderator: leecollings

Post Reply
ubfssF
Posts: 59
Joined: Monday 02 November 2015 14:12
Target OS: Linux
Domoticz version: 2.2364
Location: Netherlands
Contact:

Small LUA script for switching off an infrared panel in our bathroom after 45 minutes

Post by ubfssF »

As some people in our household tend to forget putting off the panel after usage :?, which is switched on/off by a switch that's also controlled by Domoticz , I am using this script as a backup-measure:

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
It is based on a garage-door script by someone else in this forum.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests