The point is that, setting an initial state is a big deal: when the HA restarts or fails, the energy panel loads up the sensor and compare with the state value and I end up with erratic consuptions! Actually, after three month of using the device, I had te restart today HA and now today consuption is 21kW (i.e. the sum of the last three months…) which lead to pricing miscomputation.
Anyone could help on this figuring why I have to set a state entry and what to set for it to work well?
How can I solve this issue? The goal is to let HA uses the latest know value instead a fixed one that goes more and more obsolete as the time passes by.
I guess I’m missing something if it is not obvious
I got a Lixee device that sends me ernergy data. This is to get that device/sensor displaying its data (in the energy panel) that I wrote that templated sensor.
Is there another way to do this?
When reading the doc about ernegy/total_increasing sensors, I see that they are expected to start at 0 or to considere the first data received as the first state for later computation (increase). But here, I have to set the initial value, which is conceptually inconsistent and actually leads to incorrect data as soon as the device disconnects/reconnects.
What should be the correct way of declaring such a device to get it used?
I got back my actual device/entity. With the values I want. Now, I’m trying to figure out how I did linked the entity to the template sensor. I don’t even understand why I did a templated sensor
I surely followed a tutorial at one point without understanding what I was doing (or where )
Soooo. Many thanks for your help as you allowed me to understand I was wrongly manipulating templates instead of actual entities! (And that I’m not really good at playing with HA!)
All that makes my system working: my data is well read and transfered to the Energy panel.
The point is that when an error occurres, or I have to reset HA, The templates are reset and take the default values. which makes the energy data to explode:
Do you have an idea how get ride of the inconsistent value attribute? Maybe replacing “allow_create: false” attribute to the zha_toolkit service data…
I see that a lot of users are making use of Zigbee2MQTT which seems to do the trick. But I don’t really want to change all my entites… (and for some reason, Z2M does not start…)
Note that is the tutorial I used, the template is using “state: unavailable” instead of an actual numeric value. I did not do that beacause I got failures… Not sure why.
I eventually deal with my issue. A few weeks ago. I take time to write here my solution :
I set a storage entry to remember the current value. Then I changed the default value to read from that entry. I works fine from then. I’m not happy with the complexity, but…
- name: lixee_zlinky_tic_metering_HP
unit_of_measurement: "Wh"
device_class: energy
state_class: total_increasing
#state: 42460988
#state: unavailable
state: >
{{ states("input_number.linky_last_hp") | int }}