Delayed Notification Script

Post Reply
Jzjr
Posts: 21
Joined: Monday 05 October 2015 15:00
Target OS: Linux
Domoticz version: 4.9796
Location: UK
Contact:

Delayed Notification Script

Post by Jzjr » Thursday 11 January 2018 20:10

Hi,

I've used the script on the wiki and adjusted it slightly with the aim of sending a notification if the fridge door is open for two minutes.

The fridge door is connected via a Fibaro Universal Sensor to my z-wave network. Whilst the switch status changed the last seen time doesn't.

Because of this I am using variables in the script - Log is showing no errors but the script isn't doing anything that I can see, no variable updates or notifications.

I'm open to using dzVents rather than old Lua if it would be simpler.

Any help would be appreciated

Code: Select all

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['Fridge Door'] == 'Open' and uservariables['fridgedooropen']) == '0' then
   commandArray['Variable:fridgedooropen'] = '1'
elseif (otherdevices['Fridge Door']) == 'Closed' then
   commandArray['Variable:fridgedooropen'] = '0'
end

if (uservariables['fridgedooropen'] == '1' and uservariables['fridgedooralert'] == '0' and timedifference(uservariables_lastupdate['fridgedooropen']) > 120) then
   commandArray['SendNotification']='Fridge Open for more than 2 minutes'
   commandArray['Variable:fridgedooralert'] = '1'
elseif (uservariables['fridgedooropen'] == '0' and uservariables['fridgedooralert']) == '1' then
   commandArray['Variable:fridgedooralert'] = '0'
end

return commandArray
Thanks
-
Fred Boniface

- Dell Optiplex 390 - Ubuntu Linux 18.04.01 LTS - Aeotec Z-Wave USB - RFXtrx433 - Hue Hub 2 - LGTV Plugin -

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests