A feature which would be to have a alarm/notification for meters when a certain value is meet. Could be for example when the meter receives for example an update for kWh usage which deviates more than a certain percent or goes higher than a certain per-defined value.
Bad values seems to be an issue once a while for various reasons and sometimes I do notice them and other time I miss them and get bad statistics. So this request would also support this and this one.
Bad value alarm/indicator for kWh meters
Moderators: leecollings, remb0
-
- Posts: 154
- Joined: Tuesday 01 October 2013 8:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Sweden
- Contact:
Re: Bad value alarm/indicator for kWh meters
Would be possible to script to monitor this?
-
- Posts: 105
- Joined: Saturday 25 November 2017 17:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v3.8153
- Location: Czech Rep.
- Contact:
Re: Bad value alarm/indicator for kWh meters
DzVents sripts, maybe blockly too.
RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Bad value alarm/indicator for kWh meters
Can you try this and report your findings ?
Thx.
Code: Select all
-- updateAlarm
--[[
enter in the description fields of the sensors you want to check the string
updateAlarm:
followed by a JSON formatted string with the dzVents fields you want to check and the max. percentage that an update can deviate without sending a notification
like
updateAlarm: { "WhTotal": "0.5%","WhActual": 5000 } -- example is for a kWh device meaning the WhTotal can deviate max 0.5% and WhActual can deviate max 5000
updateAlarm: { "usage": "0.1%","usageDelivered": 200 } -- example is for a P1 device meaning the usage can deviate max 0.1% and usagedelivered can deviate max 200
updateAlarm: { "counter": "3", "counter": "20" } -- example for counter or Gas devices; the counter can deviate max 3% and also for max 20
updateAlarm: { "temperature": "10" } -- example for temperature-sensor; the temperature can deviate max 10 degrees
]]--
local updateAlarmDevices = { 1636,1628 } -- List of all devices you want to have monitored by this script
return {
on = { devices = updateAlarmDevices },
logging = { level = domoticz.LOG_DEBUG,
marker = "updateAlarm"
},
data = { updateAlarms = { initial = {} }}, --Array with deviceNames, fields and last seen values
execute = function(dz,item)
local function logWrite(str,level) -- Support function for shorthand debug log statements
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
local myNotificationTable = { -- table with one or more notification system.
-- Can be one or more of
-- dz.NSS_GOOGLE_CLOUD_MESSAGING,
dz.NSS_PUSHOVER,
-- dz.NSS_HTTP,
-- dz.NSS_KODI,
-- dz.NSS_LOGITECH_MEDIASERVER,
-- dz.NSS_NMA,
-- dz.NSS_PROWL,
-- dz.NSS_PUSHALOT,
-- dz.NSS_PUSHBULLET,
-- dz.NSS_PUSHOVER,
-- dz.NSS_PUSHSAFER,
} -- uncomment the subsystem(s) you want to be used
controlSettings = item.description:match("updateAlarm: ({.*})") or "" -- look for line with updateAlarm: { "fieldName" : "maxDelta setting" } in description field
controlSettings = controlSettings:gsub("updateAlarm:","") -- extract JSON string from line with updateAlarm: from description field
if controlSettings == "" then
logWrite('No controlSettings found in description field. I expected something like updateAlarm: {"usage":"0.1","usageDeliverd":"2%" } ',dz.LOG_ERROR)
return
end
rt = dz.utils.fromJSON (controlSettings) -- load json in table
for key, value in pairs(rt) do
if dz.data.updateAlarms[item.name] == nil then
dz.data.updateAlarms[item.name] = {} -- init var as table
end
if dz.data.updateAlarms[item.name][key] ~= nil then -- If we have a value
local maxDelta = tostring(value):gsub("%%","") -- remove % if any
if tostring(value) == tostring(maxDelta) then
maxDelta = maxDelta * dz.data.updateAlarms[item.name][key] / 100 -- maxDelta is defined as percentage
end
if math.abs((dz.data.updateAlarms[item.name][key] - item[key])) > tonumber(maxDelta) then
logWrite("delta > " .. value .. " You have been warned.")
dz.notify("Update alarm","device " .. item.name .. "; old " .. key .. ": " .. dz.data.updateAlarms[item.name][key] .. "; Now: ".. item[key] ,nil,nil,"", myNotificationTable )
else
logWrite("delta < " .. value .. "; All OK")
end
end
dz.data.updateAlarms[item.name][key] = item[key] -- load value in dz.data table
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 154
- Joined: Tuesday 01 October 2013 8:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Sweden
- Contact:
Re: Bad value alarm/indicator for kWh meters
Thanks for the above and I've missed this response totally and haven't played around with DzVents, yet. About the alarm triggering and actually rethinking this. Why would I actually want an alarm where it would be better to have the system to react on totally bad sensor input. in 100% of my so called erroneous sensor data it's ridiculous values which the system could react on by itself by either 1) just ignore the value and set the value to zero (0) or 2) replace the value with an average input over a certain period or just re-use the last know value.
Whether this would be possible DzVents that would be nice but even better if it was built into Domoticz as an auto error correction feature which could be enabled for a device/sensor.
Typicall error which I see from my pulse counters is often something like this:

Whether this would be possible DzVents that would be nice but even better if it was built into Domoticz as an auto error correction feature which could be enabled for a device/sensor.
Typicall error which I see from my pulse counters is often something like this:
Who is online
Users browsing this forum: Bing [Bot] and 1 guest