This is a duplicate of a bug report, because I didn’t yet get a response there. Maybe here somebody has an explanation of the given issues:
The problem
I have a sensor which reports me my gas meter value as a continuously increasing value:
sensor:
# Gasmeter
- platform: mqtt
name: "Gasmeter Value"
unique_id: gasmeter_value
state_topic: "gaszaehler/main/value"
unit_of_measurement: 'm³'
state_class: total_increasing
device_class: gas
icon: 'mdi:fire'
last_reset_value_template: '1970-01-01T00:00:00+00:00'
Also, I have an utility meter which resets the data once a day (its nowhere stated, but I expect it to happen on midnight, 00:00:00):
utility_meter:
utility_meter_gas_per_day:
source: sensor.gasmeter_value
cycle: daily
I now would like to have a statistics diagram which shows me the usage per day similar to what the Energy dashboard provides.
Since the Statistics Graph requires state_class: measurement
, I added a template sensor for this:
# The Statistics Graph needs to have the "state_class" set to "measurement", see https://community.home-assistant.io/t/statistics-graph-just-keeps-going-up/335516/5
- name: "Gasmeter per day"
state: "{{ states('sensor.utility_meter_gas_per_day') }}"
unit_of_measurement: 'm³'
state_class: measurement
Then I created a statistics graph with it:
I now would expect that the max starts new every day, how ever it keeps the max of the previous day and only goes over it if the consumption is higher than on the previous day (like 2. to 3. Oct.)!
It looks like as if the Statistics Graph takes the max the last time on midnight (00:00:00), how ever the Utility meter only resets a bit later (eg. on 00:00:01). This would cause the Statistics graph to take the max value of the previous day as its start value for max.
I tested this on a clean, new instance of HA.
Also I set the timezone correctly (right from the beginning):
default_config:
homeassistant:
unit_system: metric
time_zone: Europe/Zurich
Below 2 other screenshots of the next day showing the issue once more. And the Energy Dashboard, which does it correctly:
What version of Home Assistant Core has the issue?
Home Assistant Core 2022.6.5
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Statistics Graph