Set Value to “0” if entity is not Available PV Panels


My GoodWE inverter entities change to state unavailable when the PV panels don’t produce any energy… I got an custom sensor that calculates my own usage like this:

Bereken huidig verbruik

  • platform: template
    value_template: >
    {{ ‘%0.1f’ | format(states(‘sensor.pv_power’) | float(0) -
    states(‘sensor.electricity_meter_power_production’) | float(0) +
    states(‘sensor.electricity_meter_power_consumption’) | float(0))| round(0) }}
    unit_of_measurement: ‘W’
    friendly_name: Huidig verbruik
    device_class: ‘energy’

So the problem: when I use all the entities as an meter in my dashboard, every meter is fine except the pv.power meter… I can’t handle that it is saying unavailable… I did search for some custom sensors that place the value to 0 (float) but they all don’t work in my config file… Anybody who did create such a thing?

I did try this one:


  • sensor:
    • name: “PVpower”
      unit_of_measurement: “W”
      state: "{{ states(‘sensor.pv_power’) | float | round (0) }

But I get like this error:
Invalid config for [template]: [platform] is an invalid option for [template]. Check: template->platform. (See /config/configuration.yaml, line 76).

The sensor does work but places my other sensor out of working…