Energy Template Help

Hi, was wondering if someone could fix this template up. When my Solar Inverter stops producing power (ie After dark), then the below template sensor becomes unavailable probably because its not taking into effect that the Inverter is 0, i just dont know where to update the template?

#### Live Power Consumption As a Positive
      - name: "Live Power Consumption As a Positive"
        icon: mdi:transmission-tower-import
        unit_of_measurement: "kWh"
        state: "{{ states('sensor.fronius_inverter_utilisation_kwh')|float(0) +  states('sensor.fronius_live_power_flow_kwh')|float(0) }}"
        device_class: energy
        state_class: total_increasing
        availability: "{{ states('sensor.fronius_inverter_utilisation_kwh')|float(0) != 0 and states('sensor.fronius_live_power_flow_kwh')|float(0) != 0 }}"

Your availability-template tells the sensor to become “unavailable” when one of the referenced sensors has a state of 0.

Instead you might test if it’s any number (incl. 0):

availability: "{{ states('sensor.fronius_inverter_utilisation_kwh')|is_number and states('sensor.fronius_live_power_flow_kwh')|is_number }}
3 Likes

Legend mate, im slowly saving all these examples of how to use templates, so appreciate the response

2 Likes