Friendly values for boolean sensor

I have a specific sensor (originating through MQTT) that has wither true or false as value. I would like to show this on my dashboard through a chips-card from mushroom. This will show the icon and value without the sensor name.

For this use-case it would be better if I could change the displayed value to “available” for true and “not available” for false.

I found templating, but somehow I can’t get that to work for me. I am quite new to HA, so I am probably overlooking something simple.

I haven’t tried it yet, but this could probably be the way: Home Assistant | Zigbee2MQTT

I don’t know if this is only possible for switches, or is it more universal (allows to override sensors as well).


This will work for sure:

  1. Settings → Devices & Services → Helpers → Create Helper → Template → Template a binary sensor.
  2. Set the Device class to something most fitting your use-case (like Presence or whatev)
  3. The template should be something like this: {{ is_state('binary_sensor.your_sensor', 'on') }}
  4. Display the new newly created sensor, instead of the original one.

EDIT:
probably a third way:

If the original sensor gives True or False and you want to show it as “Available” or “Not available”:
solution depends on where you need this presentation.

If in Entities card: use template-entity-row to show a customized state dependently on a real state.

If everywhere: create a template binary sensor (as it was suggested earlier) with a more fitting device_class. “Fitting” means that may be you will agree with using labels like “connected/disconnected” or “problem/ok”.
Alternatively : create template sensor which explicitly converts “true → available” and so on.

Customizing entities here will not help. Device classes meant for binary sensors cannot be used for sensors.

Since you want to use mushrooms - I would choose a template binary sensor with a fitting device class. Then you will get an automatic icon / icon color too (same may be achieved in template-entity-row in Entities card).

Guess the original sensor is not binary if it has true/false values.
But even it the original sensor is binary, the template then should be like

state: >-
  {{ states(‘binary_sensor.original’) }}

And in this case even no need to create a template binary sensor - customization (as you suggested) could be enough.

Thanks @DvdNwk and @Ildar_Gabdullin ! That is a lot of possibilities.

And yes, Ildar, you are right of course. It is not binary, but boolean. I mixed those terms up.

I will work through the suggestions in the coming days, and I’m sure one of them will give me the result I want :smiley: