Make value 0 if unavailable

I have a solar converter from omnik.
At night it is unavailable.
Is it possible to show 0 instead of unavailable as a value.

Something like if sensor is unavailable then make 0
I don’t know how to figure this out!

Template sensor:

template:
  - sensor:
      - name: "Solar output with zero"
        state: "{{ states('sensor.your_real_sensor')|float(0) }}"

The default 0 value on the float filter will be used if the state of the other sensor can’t be converted to a number.

2 Likes

Ok but now this is only needed if the sensor goes to unavailable

Use it all the time. It’ll show the sensor value when it can be evaluated as a number.

It’s possible your original sensor can be set up to solve this for you, but as you’ve omitted to provide any details I can’t tell.

i know question was short.
i was busy too long with it
i try your solution tonight

Thank you! i figured it out at your way!