arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.97k stars 4.77k forks source link

ENERGY_Total gets truncated to 3 decimals on every date rollover (i.e. at midnight) #20668

Closed MaxRower closed 6 months ago

MaxRower commented 7 months ago

PROBLEM DESCRIPTION

When I view the graph of ENGERY_Total of my various NOUS A1T plugs, I can see a small drop on every date rollover at midnight. After examining the data in influxdb, I can see, the reported value of ENERGY_Total get's truncated to 3 decimal digits on every date rollover. I have configured to use 5 decimal digits.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [ ] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:
```lua
  Rules output here:
- [ ] Set `weblog` to 4 and then, when you experience your issue, provide the output of the Console log:
```lua
  Console output here:

TO REPRODUCE

Steps to reproduce the behavior: set EnergyRes 5 and wait for a date rollover

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen. The value of ENERGY_Total should increase constantly, without any drops in between

SCREENSHOTS

If applicable, add screenshots to help explain your problem. grafik Timestamps in influxdb seem to be UTC, so they are one hour off from local time.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

MaxRower commented 7 months ago

Well, I checked the values of another plug, it only decreases there, but not truncated to exactly 3 decimals. So maybe some sort of binary truncation actually. grafik

And that produces some weird results in grafana: grafik

sfromis commented 7 months ago

I'm also seeing occasional small drops in "Total" energy at midnight, on some devices, including one with a very stable consumption pattern, without the total being over the about 7 digits of available resolution with single precision floating point.

{"Time":"2024-02-04T23:56:32.323+01:00","ENERGY":{"TotalStartTime":"2022-11-08T17:55:27","Total":44.79066,"Yesterday":0.12747,"Today":0.12666,"Period":0.440,"Power":4.900,"ApparentPower":14.692,"ReactivePower":13.900,"Factor":0.33,"Voltage":233.200,"Current":0.063}}
{"Time":"2024-02-05T00:01:32.326+01:00","ENERGY":{"TotalStartTime":"2022-11-08T17:55:27","Total":44.79013,"Yesterday":0.12696,"Today":0.00013,"Period":0.430,"Power":5.100,"ApparentPower":14.692,"ReactivePower":13.800,"Factor":0.35,"Voltage":233.200,"Current":0.063}}
arendst commented 7 months ago

As designed.

On ESP8266 the total energy is stored in an uint32_t for legacy reasons with max three decimals to allow a max value of +/-2147483.647 kWh On ESP32 total energy stored as a float to allow a max value of +/-262143.99 kWh

stefanbode commented 7 months ago

I assume that not the limited decimals are the problem, but that on midnight when storing the daily consumption into total there is a jump.

stefanbode commented 7 months ago

I was able to find this also on my devices but only on the ones with super low power consumption. If there s e.g. 50w, you see nothing.

image

sfromis commented 7 months ago

With Default TelePeriod of 5 minutes, you'd not see a fall in first payload after midnight, if consumption since midnight is more than the lost decimals. I suppose that you'd still miss up to 1 Wh in the total.

sfromis commented 7 months ago

What I gather is that the internal "Total" value always only has 3 decimals (1 Wh resolution), and when the "Total" value appearing in TelePeriod payloads can have more than 3 decimals, this is due to it being the value updated at last midnight plus the "Today" value, thus allowing extra decimals from the "Today" accumulation since midnight.

This has not been bothering me, as I hardly use the "Total" value, due to this getting low on decimals when total consuption gets into the MWh range (which would be 9 digits when wanting 5 decimals), not allowing full resolution in a float. Hence my plots are based on differences in the "Today" value accumulated over time, without lowering decimals.

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale because it hasn't any activity in last few weeks. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 6 months ago

This issue was automatically closed because of being stale. Feel free to open a new one if you still experience this problem.

BigAl66 commented 2 months ago

Did anybody found a solution? I have the same problem here. Every modnight some of my NOUS A1Z have the dame issue. Unfortunately Home Assistant cannot be configured to ignore negative values... (I didn't find at least an option for that...).