Detecting meters that no longer update

Moderator: leecollings

Post Reply
WebSpider
Posts: 5
Joined: Sunday 29 March 2015 3:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 4834
Contact:

Detecting meters that no longer update

Post by WebSpider »

Hi!

I have a meter (Everspring AN181, Z-Wave) that measures power in a shed. However, sometimes someone accidentally turns off the power to the shed, and stuff like a fridge doesn't like that.

Is there any way I can fire events on the latest update of a device, or the absence of a Z-Wave node from the mesh?
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Detecting meters that no longer update

Post by Egregius »

If you have a look at my pass2php script you'll find examples of that.
I receive message if a node is marked as dead and also when a devices hasn't sent anything for 4 hours.
WebSpider
Posts: 5
Joined: Sunday 29 March 2015 3:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 4834
Contact:

Re: Detecting meters that no longer update

Post by WebSpider »

Thanks for the reply. I just looked at it, and if I get it right, you are using lua, to pass openzwave values to php, which then starts influencing Domoticz .. Why not use the commandArray['SendNotification'] (for me) or commandArray['UpdateDevice']?

Anyway, thanks a bunch for pointing out Lua can catch this :)
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Detecting meters that no longer update

Post by Egregius »

Because I don't know anything about lua and I love PHP code.
the pass2php lua script passes all statusses, updatetimes, svalues etc to a php script. There it's put in arrays so they can be used to trigger anything you can imagen.
WebSpider
Posts: 5
Joined: Sunday 29 March 2015 3:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 4834
Contact:

Re: Detecting meters that no longer update

Post by WebSpider »

This turned out to be very doable in the native LUA, please find snippet below :)

Code: Select all

commandArray = {}

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

upd_delta = timedifference (otherdevices_lastupdate['Verbruik Vrieskist'])
print("Vrieskist not updated since "..upd_delta.." seconds");

if (upd_delta > 900) then
        commandArray['SendEmail']='Vrieskist problemen#Al '..upd_delta..' seconden geen update van de vrieskist meer ontvangen#[email protected]'
end
User avatar
bizziebis
Posts: 182
Joined: Saturday 19 October 2013 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805
Location: The Netherlands
Contact:

Re: Detecting meters that no longer update

Post by bizziebis »

This works, however if the condition is true it will send you an email every minute (if used as a time script).

I've added an uservariable which is set when the email is sent. From this variable I check if the time difference since last update is > 1800. So I get an email every 30 minutes.
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

Re: RE: Re: Detecting meters that no longer update

Post by havnegata »

bizziebis wrote: I've added an uservariable which is set when the email is sent. From this variable I check if the time difference since last update is > 1800. So I get an email every 30 minutes.
Can you please post the code for this! I have a couple of scripts with notifications beeing sent every minute, and would really like to avoid this Image
User avatar
bizziebis
Posts: 182
Joined: Saturday 19 October 2013 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805
Location: The Netherlands
Contact:

Re: Detecting meters that no longer update

Post by bizziebis »

Sure, just like this:

Code: Select all

difference = timedifference(otherdevices_lastupdate['Sensor1'])

if difference > 3700  then
    if timedifference(uservariables_lastupdate['Sensor1 Notification']) > 3600 then
		print('No data received for '..difference ..' seconds')
		send_notification('Tom','No data received from sensor 1')
		commandArray['Variable:Sensor1 Notification']='TIMER'
	end
end	
send_notification() is my own function, just replace it by something that will send you a notification.
'Sensor1 Notification' is an Uservariable of the type string which has to be created first.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest