How To Prevent Entity From Resetting To 0?

I have a similar issue with my SMA solar inverter. Every week or so it goes offline momentarily in the middle of the night (no idea why - it has non persistent logs!) and this changes the kWh counter to a low value then 0, then back up to the normal > 4000kWh count when it comes back online. This introduces a massive spike in energy use in home assistant. I have created a filtered version of the raw sensor (sensor.total_yield) to fix the issue:

template:
  - sensor:
      - name: "total_yield_filtered" 
        icon: "mdi:counter"
        unit_of_measurement: "kWh"
        state: "{{ states('sensor.total_yield')|float(0) }}"
        availability: "{{ states('sensor.total_yield')|float(0) > 4000 }}"

This filtered sensor is then used in a utility meter that is fed to the energy dashboard (as I want access to the daily total). But you could feed the filtered sensor directly to the energy dashboard.

5 Likes