Skip to content

Meter value used instead of difference when start of date range falls in a gap in the statistics #118

@rrozema

Description

@rrozema

Checklist:

  • [x ] I updated to the latest version available
  • [x ] I cleared the cache of my browser

Release with the issue:
Sankey Chart Card: 1.14.0
Home Assistant 2023.6.3
Supervisor 2023.06.4
Operating System 10.3
Frontend 20230608.0 - latest

Last working release (if known):
N/A

Browser and Operating System:
Both in Chrome on windows, in HA windows app and in Android app. It's a data collection issue, not a display issue so probably not relevant anyway.

Description of problem:
Incorrect data is shown in the chart for some sensors at some days/weeks/months.
If the statistics for a sensor have a gap -because f.e. the sensor was offline at some time- and the start of the selected date range is within this gap (i.e. there is no data available for the start of the selected period) but data is available before the end of the selected period, the running total will be too high. Instead of the running total of usage, the value of the meter is read from the first data point that is available in the selected period. The effect is best seen on meters that have not been reset recently as then the incorrectly added value will be high.

The running total should include only differences between 2 measurements, not the value of the meter itself.

For an example of the error, see this picture of June 22nd's energy usage overview. The encircled 'Keuken: Spots: Verbruik' had been offline from 21-06-2023 13:50:00.000 due to a z-wave connection issue, which I fixed on June 22-06-2023 08:05:00.000. i.e. No statistics were stored for this device in that period. The usage listed for June 22nd for this devices matches exactly the 3.5kWh that is the total usage for this device all time. When in the date picker I select June 21st, usage is listed as 0kWh, when I select June 23rd usage is 0kWh, and even when I select the week of June 19th to June 25th, i.e. the week that has June 22nd in it, the usage is listed as 0kWH. Only when the start of the range falls into a gap, the running total is incorrect.
A document containing the queries I used to verify the contents of the statistics table for this device, plus the resulting output can be found in my google drive.

Javascript errors shown in the web inspector (if applicable):
N/A

Additional information:
Above is one example I researched in depth, it happens too on more sensors on more days/weeks/months. All have in common that there is no data in the statistics for that sensor on the start of the period due to various reasons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions