Hi!
I have a template sensor that calculates the area cleaned since calling the emptying script for my vacuum. It works by subtracting the “milage” when emptying from total “milage”. My vacumm sometimes goes unavailable, and then I cannot read the total area cleaned and the sensor value is incorrect. I’ve tried to solve it from the tips in this thread LINK but it doesn’t work. Then my template sensor shows unknown.
Anyone knows what could be wrong? I’m open for better solutions as well if there are
- platform: template
sensors:
dammsugare_nere_area_since_empty:
entity_id:
- input_number.dammsugare_nere_last_emptied_milage
- sensor.dammsugare_nere_total_clean_area
unit_of_measurement: "m²"
value_template: >-
{% set last = states.input_number.dammsugare_nere_last_emptied_milage.state|float %}
{% set current = states.sensor.dammsugare_nere_total_clean_area.state| float %}
{% if states.sensor.dammsugare_nere_total_clean_area.state | float > 10 %}
{{ (current - last)|round(1) }}
{% else %}
{{ states.sensor.dammsugare_nere_area_since_empty.state }}
{% endif %}
2 posts - 2 participants