Page 1 of 1

Short usage isn't logged

Posted: Monday 24 May 2021 12:38
by roblom
I have a Fibaro wall plug on my coffee device. Works ok and if I turn on the device the power usage (about 1250W) is shown on the tile in Domoticz. The usage is for about a minute or so.

Problem one is that the notification I set (send notification when usage is above 1000W) isn't send most of the times (sometimes it is).

Problem two (probably related) is that the usage spike isn't logged in the graph most of the times.

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?

Re: Short usage isn't logged

Posted: Tuesday 25 May 2021 13:55
by lost
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.

Re: Short usage isn't logged

Posted: Tuesday 25 May 2021 18:01
by roblom
Over used the normal notification setting from Domoticz.
It looks indeed like the graph data are intervals at some point in time and not averages or something. But also the notification is not triggered by the real-time data but checked at intervals, I think this causes the notification is not always send.

Re: Short usage isn't logged

Posted: Tuesday 25 May 2021 18:51
by lost
roblom wrote: Tuesday 25 May 2021 18:01 Over used the normal notification setting from Domoticz.
It looks indeed like the graph data are intervals at some point in time and not averages or something. But also the notification is not triggered by the real-time data but checked at intervals, I think this causes the notification is not always send.
My script is triggered at every device measure received... That's why I was asking how you manage your notifications: Scripted, this should work.