OpenBK7231T_App icon indicating copy to clipboard operation
OpenBK7231T_App copied to clipboard

Suggestion : add total power for last hour

Open analystcmyk opened this issue 3 years ago • 5 comments

Suggestion:

The BL series power meters report current usage at the time of measurement.

It would be valuable to report a running total of the last hour via MQTT.

eg : PowerUsedLastHour : 1.2 KWH

That way you only need to poll power usage once per hour.

analystcmyk avatar Sep 24 '22 08:09 analystcmyk

Creating moving window would require too much RAM for storing samples. I would use it with real system time received either from MQTT or SNTP. Samples ordered by hour of day with some history.

Currently working accumulating energy at present sample rate, with posting to MQTT topic. Unfortunately device is freezing occasionally, seeking forum possible solutions Model: CB2S, BL0937, 1 Relay, 1 Button, 1 LED

Lubomir

valeklubomir avatar Sep 27 '22 10:09 valeklubomir

How many samples would we need per hour? Sample every second? 60*60=3600 samples, each one sample is 4 bytes.... it doesn't seem so bad. The option would need to be enabled by user, only then it would malloc a ring buffer.

openshwprojects avatar Oct 01 '22 18:10 openshwprojects

I think that every second is already very precise.

A setting like "Cumulative power samples per minute" [0-60] with 0 = disabled would be great.

Even fixed to 60/min would be fine, unless it would take too much processing.

analystcmyk avatar Oct 11 '22 14:10 analystcmyk

This can be kept in one variable - well 2: one for front-end (user) , another for internal counter. Just increment internal-value by power value that is read from chip, and once in hour (e.g. counting from power-on) divide the internal-value by amount of reads/per-hour.

saper-2 avatar Oct 17 '22 16:10 saper-2

This function was just in latest version released. Try it. Function must be enabled by startup command:

SetupEnergyStats [enable (0/1)] [sample interval (10..900)] [sample count (10..180)]

Example: backlog startDriver BL0942; SetupEnergyStats 1 30 120

Sampling time: 30 seconds, Sample count: 120 sample Total 1 hour data.

MQTT topics [client id]/energycounter/get [client id]/energycounter_last_hour/get [client id]/consumption_stats/get

But with configurable option it is not longer real "last_hour" but consumption within the defined parameters.

valeklubomir avatar Oct 17 '22 16:10 valeklubomir

This is implemented, tested and working correctly. And thank you @openshwprojects

analystcmyk avatar Sep 14 '23 17:09 analystcmyk