Entity is currently unavailable

Hi,

I have configured my PV converter (SMA Sunnyboy 5) which works when it has data.
the sensor.pv_power (the current generated power) works when the device is actually generating power.
However, as soon as there is no more power generated, then i get an error: “Entity is currently unavailable: sensor.pv_power”
The day after, as soon as the device starts to generate power again, all is fine, until… sun down.

Since i use this value for calculating other sensors, these sensors also turn into this error state.

Any ideas on how to:

  • Debug this?
  • OR how to do error handling in the configuration.yaml file with calculated sensors? (then i could work around this issue…)

In fact, i noticed the same behaviour for all the other related sensors, as soon as sun down

image

image

You can set it to zero when unavailable will that do?

If so, use a template sensor like this:

sensor:
  - platform: template
    sensors:
      pv_power_corrected:
        friendly_name: "PV Power Corrected"
        unit_of_measurement: 'W'
        value_template: "{{ states('sensor.pv_power') |float }}"

If your sensor returns anything other than a string composed of numbers the floating point conversion filter | float will set it to 0.

1 Like

Many thanks! this does the trick!

Hello.
Today in Newest HA, this {{“unavailable”|float }} dosent work anymore.

Gives error:
ValueError: Template error: float got invalid input ‘unavailable’ when rendering template ‘{{“unavailable”|float }}’ but no default was specified

Yes there are many posts like this year old post that have been made redundant by changes to the core.

It is best to refer to the official documentation.

Can you help me, how i can use this now?

Here’s a good explanation of the changes required: