Last seen notification Topic is solved
Moderators: leecollings, remb0
-
- Posts: 14
- Joined: Sunday 06 September 2015 22:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: United Kingdom
- Contact:
Last seen notification
Not sure if the following is currently possible - if not it would be a nice feature.
Notification when last sensor time is greater than xxx.
If one of my sensors stops reporting for more than x mins I'd like to know about it as it's probably died then and needs a reboot.
Notification when last sensor time is greater than xxx.
If one of my sensors stops reporting for more than x mins I'd like to know about it as it's probably died then and needs a reboot.
- Minglarn
- Posts: 214
- Joined: Friday 21 August 2015 19:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v3.8153
- Location: Stockholm / Sweden
- Contact:
Re: Last seen notification
This is something i've been searching for!
+1 for this!
+1 for this!
“When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Last seen notification
Isn't that what's "Sensor Timeout" is for in the settings/other page?
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: Last seen notification
@gmccarthy:
Which need to reboot, your sensor/gateway or domotics?
Else domotics has a hardware time out which can be configured to restart/reboot that hardware/gateway.
Look at the settings of your hardware device. If you mean a specific sensor, it depends i would think. Then your suggestion would be a nice one to know which sensor needs to a (manual) reboot.
Sent from my D6503 using Tapatalk
Which need to reboot, your sensor/gateway or domotics?
Else domotics has a hardware time out which can be configured to restart/reboot that hardware/gateway.
Look at the settings of your hardware device. If you mean a specific sensor, it depends i would think. Then your suggestion would be a nice one to know which sensor needs to a (manual) reboot.
Sent from my D6503 using Tapatalk
-
- Posts: 14
- Joined: Sunday 06 September 2015 22:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: United Kingdom
- Contact:
Re: Last seen notification
Its not to reboot anything - its more of a info notification that I need to investigate a sensor that has not reported in for a while.
Found this:
viewtopic.php?f=31&t=5498
Found this:
viewtopic.php?f=31&t=5498
There is already logic inside domoticz, but the function is not completed.
function CheckDeviceTimeout
I will put it on the todo list
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: Last seen notification
Youre right. Seen that topic long time ago. Never thought of being the prob yoi wanted to know.
Guess we have to wait for Gizmocus to finish its ToDo
Sent from my D6503 using Tapatalk
Guess we have to wait for Gizmocus to finish its ToDo
Sent from my D6503 using Tapatalk
-
- Posts: 49
- Joined: Monday 07 October 2013 10:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Last seen notification
Maybe I can help .... I created the following LUA script to monitor ESIC/WT450 and other unreliable sensors. This sends me notification when selected sensors drops out, and another one if it starts responding again. You can also exclude sensors from being monitored for timeouts.
The script makes use of Domoticz user variables for configuration as follows:
A minimal setup of user variables can be as follows, but only SensorsAlerted is strictly needed. A more typical user variable setup can look like this. In this case it displays a state where one sensor has timed out Please note the needed inital word None. Just my laziness / makes the code simpler, but is required for this to work.
If you prefer, you can just use the fallback variables in the script instead of user variables. I find user variables handy as i use the same LUA script in two different houses.
The following script_time_sensormonitor.lua can also be downloaded from here
The script makes use of Domoticz user variables for configuration as follows:
- SensorTimeOut (integer) is useful to change for debugging, or undefined for defaults
- SensorsAlerted (string) - blank / undefined for no alerts. NB: Set to "None" as initial value for alerts
- SensorMonitorDevices (string) - comma separated list of substrings to match for device names
- SensorMonitorExcluded (string) - comma separated list of substrings out of the matched devices to exclude
A minimal setup of user variables can be as follows, but only SensorsAlerted is strictly needed. A more typical user variable setup can look like this. In this case it displays a state where one sensor has timed out Please note the needed inital word None. Just my laziness / makes the code simpler, but is required for this to work.
If you prefer, you can just use the fallback variables in the script instead of user variables. I find user variables handy as i use the same LUA script in two different houses.
The following script_time_sensormonitor.lua can also be downloaded from here
Code: Select all
--
-- $Id: script_time_sensormonitor.lua,v 1.2 2015/09/09 18:59:49 pi Exp $
--
logging = true
debug = false
--
-- User variables from Domoticz setup
-- SensorTimeOut (integer) is useful to change for debugging, or undefined for defaults
-- SensorsAlerted (string) - blank / undefined for no alerts, set to "None" as initial value for alterts
-- SensorMonitorDevices (string) - comma separated list of substrings to match for device names
-- SensorMonitorExcluded (string) - comma separated list of substrings out of the matched devices to exclude
--
monitordevices=uservariables["SensorMonitorDevices"];
excludeddevices=uservariables["SensorMonitorExcluded"];
sensorsalerted=uservariables["SensorsAlerted"];
devicetimeout=uservariables["SensorTimeOut"];
--
-- Fallback values
--
if not ( monitordevices ) then
monitordevices = "Temp,CPU"
end
if not ( excludeddevices ) then
excludeddevices = "egulator"
end
if not ( devicetimeout ) then
devicetimeout = 600
end
--
-- No changes should be needed below here
--
function changedsince(device)
t1 = os.time()
ts = otherdevices_lastupdate[device]
year = string.sub(ts, 1, 4)
month = string.sub(ts, 6, 7)
day = string.sub(ts, 9, 10)
hour = string.sub(ts, 12, 13)
minutes = string.sub(ts, 15, 16)
seconds = string.sub(ts, 18, 19)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difftime=(os.difftime(t1,t2))
-- if (debug) then print("Device " .. device .. " not changed in " .. difftime .. " seconds") end
return difftime
end
commandArray = {}
for device, value in pairs(otherdevices_svalues)
do
pos = nil
exclpos = nil
for matchname in string.gmatch(monitordevices, "[^,]+")
do
pos = string.find(device,matchname,1,true)
if ( pos ) then
for exname in string.gmatch(excludeddevices, "[^,]+")
do
exclpos = string.find(device,exname,1,true)
if ( exclpos ) then
if (debug) then print("Excluded device " .. device .. " matching " .. exname) end
break
end
end
if ( exclpos ) then break end
if (debug) then print("Included device " .. device .. " matching " .. matchname .. " value=" .. value) end
deltatime = changedsince(device)
if ( deltatime > devicetimeout ) then
if (logging) then print("Timeout for " .. device .. ". Not seen for " .. deltatime .. " seconds" ) end
if ( sensorsalerted ) then
pos = string.find(sensorsalerted,"," .. device,1,true)
if not ( pos ) then
sensorsalerted = sensorsalerted .. "," .. device
if (logging) then print("sensorsalterted addition: " .. device .. " added to " .. sensorsalerted) end
commandArray['Variable:SensorsAlerted']=sensorsalerted
commandArray['SendNotification']="Sensor " .. device .. " inactive"
end
end
else
if ( sensorsalerted ) then
pos = string.find(sensorsalerted,"," .. device,1,true)
if ( pos ) then
len = string.len(device) + 1
sensorsalerted = string.sub(sensorsalerted, 1, pos - 1) .. string.sub(sensorsalerted, pos + len)
if (logging) then print("sensorsalterted removal: " .. device .. " removed from " .. sensorsalerted) end
commandArray['Variable:SensorsAlerted']=sensorsalerted
commandArray['SendNotification']="Sensor " .. device .. " active again"
end
end
end
else
if (debug) then print("No match device " .. device .. " no match for " .. matchname) end
end
end
end
return commandArray
-
- Posts: 1
- Joined: Tuesday 10 November 2015 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2.3295
- Location: UK
- Contact:
Re: Last seen notification
Hi hansrune, that is really helpful and very well described. Thanks to the clear instructions and URL I was able to get it working in a matter of minutes. Looks a well designed piece of code too!
Many thanks!
Many thanks!
-
- Posts: 49
- Joined: Monday 07 October 2013 10:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Last seen notification
Good to hear that. Maybe i should make it wiki material...
-
- Posts: 279
- Joined: Sunday 03 January 2016 14:55
- Target OS: -
- Domoticz version:
- Location: Sweden
- Contact:
Re: Last seen notification
Nice work
-
- Posts: 279
- Joined: Sunday 03 January 2016 14:55
- Target OS: -
- Domoticz version:
- Location: Sweden
- Contact:
Re: Last seen notification
Since Domoticz doesn't accept empty Value for Strings you have to write None as Value
-
- Posts: 279
- Joined: Sunday 03 January 2016 14:55
- Target OS: -
- Domoticz version:
- Location: Sweden
- Contact:
Re: Last seen notification
Is there a way to make a short delay, I had 3 sensors that was too old but I only got one email.
Can the RPi be too quick or maybe the mail server took time to send the first mail so the other two emails never reached the mail server?
My SensorAlerted includes all 3 sensor that is old.
Can the RPi be too quick or maybe the mail server took time to send the first mail so the other two emails never reached the mail server?
My SensorAlerted includes all 3 sensor that is old.
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Last seen notification
Have you looked at dzVents? It allows you to do this in just a couple of lines of code.gmccarthy wrote:Not sure if the following is currently possible - if not it would be a nice feature.
Notification when last sensor time is greater than xxx.
If one of my sensors stops reporting for more than x mins I'd like to know about it as it's probably died then and needs a reboot.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 279
- Joined: Sunday 03 January 2016 14:55
- Target OS: -
- Domoticz version:
- Location: Sweden
- Contact:
Re: Last seen notification
That looks interesting and you can do a lot more with dzvents
-
- Posts: 26
- Joined: Thursday 13 October 2016 11:43
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Last seen notification
Just in case someone is coming across this thread like me.
The solution is already there:
- click on the "Notification" button from the sensor you want to monitor
- change the "type" in the pull down menu to "last Update"
- and configure the rest of the settings
The solution is already there:
- click on the "Notification" button from the sensor you want to monitor
- change the "type" in the pull down menu to "last Update"
- and configure the rest of the settings
-
- Posts: 56
- Joined: Friday 04 August 2017 16:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Last seen notification
Just in case the same someone wanted to use the above trick. Type "Last Update" is unfortunately not available for all type of devices.
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Last seen notification
On what device type did you miss it?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 198
- Joined: Thursday 06 October 2016 8:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.7243
- Contact:
Re: Last seen notification
I have such an error:dannybloe wrote: ↑Monday 04 July 2016 10:16Have you looked at dzVents? It allows you to do this in just a couple of lines of code.gmccarthy wrote:Not sure if the following is currently possible - if not it would be a nice feature.
Notification when last sensor time is greater than xxx.
If one of my sensors stops reporting for more than x mins I'd like to know about it as it's probably died then and needs a reboot.
Code: Select all
2022-04-13 06:45:00.117 Error: EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: /home/pi/domoticz/dzVents/runtime/EventHelpers.lua:464: bad argument #1 to 'pairs' (table expected, got string)
Code: Select all
local devicesToCheck = {
{ ['name'] = 'Wewnętrzna', ['threshold'] = 30 }
}
return {
active = true,
on = {
['timer'] = 'every 5 minutes'
},
execute = function(domoticz)
local message=""
for i, deviceToCheck in pairs(devicesToCheck) do
local name = deviceToCheck['name']
local threshold = deviceToCheck['threshold']
local minutes = domoticz.devices[name].lastUpdate.minutesAgo
if ( minutes > threshold) then
message = message .. 'Device ' ..
name .. ' seems to be dead. No heartbeat for at least ' ..
minutes .. ' minutes.\r'
end
end
if (message) then
domoticz.email('Dead devices', message, '[email protected]')
domoticz.log('Dead devices found: ' .. message, domoticz.LOG_ERROR)
end
end
}
-
- Posts: 56
- Joined: Friday 04 August 2017 16:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Last seen notification
Dummy devices, on/off switches, open/close sensor, motion sensor, etc ...
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Last seen notification
Yes I see now, on all switches this last update notification is not possible. Available though on most other sensors (not switches) like temperature, UV, Weather, thermostats, pressure, custom sensor, Lux etc.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest