Hi,
what am i doing wrong here. My sensor “strom_zaehlerstand_kwh_total” shows the complete used power consumption. Its also a energy_class with a “total_inceasing” state_class. But sometimes i got wrong values, that are lower then the time before. To filter these values for my energy dashboard i createt an extra sensor “stromzaehler_total_test”.
This sensor should only store values from my powermeter_sensor “strom_zaehlerstand_kwh_total” that are greater like the time before. For the case, that the “strom_zaehlerstand_kwh_total” is lower then before, just use the same value, stored in “stromzaehler_total_test” from the time before.
stromzaehler_total_test:
value_template: >
{% if float(states('sensor.strom_zaehlerstand_kwh_total')) | round(3) >= float(states('sensor.stromzaehler_total_test')) | round(3) %}
{{ float(states('sensor.strom_zaehlerstand_kwh_total')) | round(3) }}
{% else %}
{{ float(states('sensor.stromzaehler_total_test')) | round(3) }}
{% endif %}
unique_id: "stromzaehler_total_test"
unit_of_measurement: 'kWh'
device_class: "energy"
attribute_templates:
state_class: total_increasing
But my sensor stromzaehler_total_test is always unavailable. It seems that the
float(states(‘sensor.stromzaehler_total_test’)) | round(3)
in my first IF clause is not correct. When i use a fix value instead, the whole if-then-else clause works as expected. Some suggenstions ?
Regards Vala