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?
Detecting meters that no longer update
Moderator: leecollings
- 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
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.
I receive message if a node is marked as dead and also when a devices hasn't sent anything for 4 hours.
-
- 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
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
Anyway, thanks a bunch for pointing out Lua can catch this
- 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
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.
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.
-
- 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
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
- 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
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.
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.
- 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
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 thisbizziebis 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.
- 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
Sure, just like this:
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.
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
'Sensor1 Notification' is an Uservariable of the type string which has to be created first.
Who is online
Users browsing this forum: No registered users and 0 guests