So, my use case: my AC is updating it’s energy consumption in more or less hourly intervals. The new state represents the energy used since the last state update. So far, so simple.
My template sensor to convert this sensor to an ever increasing energy sensor:
- sensor:
- name: Klima Energy Test
unit_of_measurement: kWh
device_class: energy
state: "{{ states('sensor.test_heat_energy_consumption') }}"
state_class: total_increasing
to my understanding of New sensor state class: total_increasing | Home Assistant Developer Docs the resulting sensor is expected to increase no matter what. Yet the sensor reads:
0.3|2022-09-21 19:56:35.261535
0.6|2022-09-21 19:56:35.262924
|2022-09-21 19:57:01.792876
0.3|2022-09-21 19:57:01.794291
0.6|2022-09-21 19:57:01.807656
|2022-09-21 20:04:10.462048
0.3|2022-09-21 20:04:10.463590
The empty values seem to result from an integration restart. I wonder where they come from.
Anyways: the main issue is that the sensor breakes his “only increasing” promise and resets to a lower value.
Any idea anyone what is happening here?
Thx
Edit: This all doesn’t make sense. Sensor Entity | Home Assistant Developer Docs gives a totally different explanation of the sensors - it seems from there that total_increasing is not correct here at all. It should be total/last_reset, but last_reset is no more in current HA versions.
It is noted that total_increasing is set to replace this combination, but above link also states that changes <10% will be ignored in total_increasing. Which is not functionally equivalent to the “older” method at all.
What a mess.
Edit 2: Reading further it seems from Home Assistant Statistics | Home Assistant that the state_class does not affect the state itself but the way the statistics module uses the saved states. Is this correct?