Help: mushroom-chips-card: Show "0" (zero) when entity is "unavailable"

I have the following mushroom-chips-card configuration on my dashboard:

type: custom:mushroom-chips-card
chips:
  - type: entity
    entity: sensor.solarmax_total_power
    icon_color: yellow
    icon: mdi:solar-power-variant

It works well, however, when the solar panels are not producing any energy, the entity shows up as “unavailable”. Is there any way I can make show it up as a value of “0” (zero) instead?

Thanks!

I don’t know if there is a simpler way, but you could do this with a template sensor, and add that to your dashboard instead of the original entity.

The example below changes a sensor from on and off, to 100,10 and 0 if unavailable:

- sensor:
    - name: "Tado Main House Battery Level"
      unique_id: tado_main_house_battery_level
      unit_of_measurement: "%"
      device_class: battery
      state: >
          {% if is_state('binary_sensor.main_house_tado_thermostat_battery_state', 'off') %}
              100
          {% elif states('climate.main_house') not in ('unknown', 'unavailable') %}
              10
          {% else %}
              0
          {% endif %}

With a tiny tweak you could make this work for your use case.

I have templates in a separate file, if you do not, you need to start your indenting with

template: