roblom wrote: Monday 24 May 2021 12:38
I think it's because the logging is logging on intervals and the usage spike is between those intervals. But in my opinion the notification trigger should be send at least.
Is there a way to solve this?
How's the notification done? Script?
I have the same kind of issue with my Qubino Smart-Meter monitoring my whole home eletric power use: True max power were not recorded, looks points in graphs are every 5mn and intermediate values are not stored.
The way I solved this is through setting up a dummy (or virtual) device/sensor (type "usage/electric"), named "Puissance (=power) Max" first.
A device script then feeds this (dummy) sensor with true max values (from real sensor named 'SmartMeter W') per 10mn=600s (to be over 5mn sensors sampling, otherwise I presume measurements will not remain as it's the case for true devices) time slices:
$ cat domoticz/scripts/lua/script_device_SmartMeterPeak.lua
Code: Select all
-- Smart-Meter (per 10mn/600s default time slice max) peak power consumption
-- Only use slices > 5mn Domoticz log/graph record time in DB or some max will
-- be overwritten!
--
-- Changelog:
-- 11/01/2019, YL, 1st version.
-- 13/05/2021, Record integers for Domoticz 2021.1 using math.floor().
-- User editable settings:
devSmartMeterPwr='SmartMeter W' -- Real PWR consumtion measurement device name
devPeakPwrVrtSen='Puissance MAX' -- Virtual sensor type "electricity" name
maxLastUpdateVrt=600 -- Store current power value if last max record is too old...
maxPeakPwr=13000 -- Device limit is 63A, measures exceeding are filtered.
commandArray = {}
--
-- Internal fct :
-- Get current script exec time & compute last 'device' update time.
--
local function timeLastUpdate(device)
t1 = os.time()
sT0 = otherdevices_lastupdate[device]
-- Returns a date time like 2016-12-02 15:30:10
-- => Format as os.time & compute diff :
year = string.sub(sT0, 1, 4)
month = string.sub(sT0, 6, 7)
day = string.sub(sT0, 9, 10)
hour = string.sub(sT0, 12, 13)
minutes = string.sub(sT0, 15, 16)
seconds = string.sub(sT0, 18, 19)
t0 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
tDiff = os.difftime(t1, t0)
return(tDiff)
end
--
-- Update virtual sensor
--
local function updateNum(dev, value1)
local cmd = string.format("%d|0|%d", otherdevices_idx[dev], math.floor(value1))
table.insert (commandArray, { ['UpdateDevice'] = cmd } )
end
--
-- MAIN
--
if (devicechanged[devSmartMeterPwr]) then
curPwr = tonumber(devicechanged[devSmartMeterPwr])
-- Immediately log & return on bad pwr figures...
if (curPwr > maxPeakPwr) then
print('WARNING : '..devSmartMeterPwr..' reports '..curPwr..'W !!!')
return commandArray
end
pkPwr = tonumber(otherdevices[devPeakPwrVrtSen])
tLastPk= timeLastUpdate(devPeakPwrVrtSen)
-- Debug :
--print(devSmartMeterPwr..': P='..curPwr..'W ('..type(curPwr)..')')
--print(devPeakPwrVrtSen..': P='..pkPwr..'W ('..type(pkPwr)..') ; Last : '..tLastPk..'s')
-- Peak Pwr is stored rounded...
if (curPwr > (pkPwr + 1)) or (tLastPk > maxLastUpdateVrt) then
--Debug :
--print('Update '..devPeakPwrVrtSen..' to '..curPwr..'W')
updateNum(devPeakPwrVrtSen, curPwr)
end
end
return commandArray
This should do the job for you after changing a few settings.