Change text labels to icons

Hi, I’m new to HA and HADashboard, so in trying to get to grips with things, I’ve created a sensor that lists my TV state. On/off. When added to HADashboard I have a widget called samsung TV but it shows text as on or off depending on the state. What I want to do is display the mdi-power icon, either coloured green if status is on and coloured red if status is off, see example pics below.
I’ve also created sunrise and sunset times, I want these to display the mdi-weather-sunset-up/down icons with the time underneath, again see example of how I want it to look.

samsungtvsamsungtxtsunrise

Are there easy ways to do this?
Thanks.

1 Like

@ReneTode create a custom widget to do this, I will be adding equivalent functionality soon, it’s on my short list at the moment.

for the TV you can use the binary_sensor widget.
a widget with a static icon and changing text beneath it isnt there.
fo that you probably need to create your own custom widget.

The binary_sensor worked perfectly for the TV status. Thanks.

I spoke too soon! I thought the binary sensor was working but that’s because the TV was off. The sensor never changes state. I suspect it’s because I don’t know what I am doing! I’ve put together the sensor from various examples I found.
When I use similar code, just as a sensor, then it works fine so I’m definitely doing something wrong with the binary_sensor.
Here’s the code I’m using.

binary_sensor:
platform: template
sensors:
tvstate:
friendly_name: Samsung TV
value_template: >-
{%- if is_state(“states.media_player.samsung_tv.state”, “off”) -%}
off
{%- else -%}
on
{%- endif %}

Help!!

worked it out! User error!

you dont need to create a binary sensor in HA.
you can use any sensor that shows on/off and put it in a binary sensor widget.

binary sensor widget will also work as a sensor widget for a switch or an input_boolean for instance.

That’s good to know. Thanks for pointing that out. I’m beginning to get somewhere. Enjoying the learning curve.

1 Like