Utility meter counting double after restart of HA

This is because sensors take time to initialise.

Say you had a pulse count of 5 in your utility meter (and the template sensor).

You restart home assistant.

The history stats sensor starts as unknown which is converted to 0 by the |float filter in the template sensor, then is restored to 5.

The utility meter sees this as an increase of 5, updating itself to 10 (double what it was)

You should be able to prevent this by including an availability template in your template sensor. Try this:

  - platform: template
    sensors:
      regenval_in_mm:
        friendly_name: Regenval in mm
        unit_of_measurement: "mm"
        icon_template: 'mdi:weather-pouring'
        value_template: >
          {{ (states('sensor.regenmeter_puls') | float * 0.254) | round(1) }}
        availability_template: "{{ states('sensor.regenmeter_puls') not in ['unknown', 'unavailable', 'none'] }}"
3 Likes