Page 1 of 1
Bad value alarm/indicator for kWh meters
Posted: Sunday 13 January 2019 19:33
by kimhav
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.
Re: Bad value alarm/indicator for kWh meters
Posted: Sunday 24 February 2019 21:06
by kimhav
Would be possible to script to monitor this?
Re: Bad value alarm/indicator for kWh meters
Posted: Sunday 03 March 2019 22:58
by kimot
DzVents sripts, maybe blockly too.
Re: Bad value alarm/indicator for kWh meters
Posted: Monday 04 March 2019 10:38
by waaren
kimhav wrote: ↑Sunday 24 February 2019 21:06
Would be possible to script to monitor this?
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
}
Re: Bad value alarm/indicator for kWh meters
Posted: Wednesday 31 July 2019 9:21
by kimhav
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:
