Solar panel - total sum during connection timout

Hi everyone,
we recently connected our micro-inverters to HomeAssistant. Unfortunately it doesn’t give constant data output, as it is self-powered. But the integration does return a total-power of 0, shortly before going offline, which results in this graph:

Can anyone please give me a hint, how to write a template, that only updates the value, when the value “sensor.solaranlage_total_production_1” is available and bigger, than the last saved value?

Thanks for your help in advance!
Lars

template:
  - trigger:
      - platform: state
        entity_id: sensor.solaranlage_total_production_1
        not_to:
          - unknown
          - unavailable
    sensor:
      - name: Solar Energy Total
        unique_id: total_solar_energy
        state: >
          {% set x = trigger.to_state.state | float(0) %}
          {{ x if x > this.state | float(0) else this.state }}
        device_class: energy 
        unit_of_measurement: kWh
        state_class: total
1 Like

Thanks for your immediate help. I will try and report back tomorrow!

Hi,
you’re template works like a charm. Many many thanks! :+1:

1 Like