General Styled Text Entity

I am very surprised that I can’t find a general “Text” template helper. I would like to define a template that computes text to display, with a chosen color and ideally a selected icon depending current conditions.

My immediate desire is to create a high level “Status” light that shows numbers 0 to 10 in red, yellow or green depending on various conditions. I want level 10 to be “house on fire” and level 2 might be when some battery is below 20%. I want to define this as a single entity so I can use it as a favorite on the built-in Home Overview dashboard without taking up much room. Home Overview favorites only supports entities, not cards.

I was able to build a (complex) collection of entities that shows the number 0-10 as an overview favorite, but I can’t specify the color or different icons for different values. I did that using a template number and a bunch of other helper entities.

Thanks for any pointers you can provide.

The state of a sensor entity can be any string of up to 255 characters, so a Template Text entity would be kind of redundant. If you want to limit the possibilities to a certain set of values, use a Template Select.

The colors shown in dashboard cards are determined by the specific card being used and/or the user-defined color theme that is in use. If you want the icon color to change based on the entity’s state you will need to use a card that allows that like Mushroom, Custom Button, and others. But if you plan on sticking with the auto-generated dashboard, I think you’re stuck with what it gives you.

Sounds like you just need a markdown card, where you can use html tags, like <font color=red>text</font>

HA icons, like MDI or other sets you have installed in HA can be inserted with
<ha-icon icon="mdi:snowflake"></ha-icon>

The text can also be prepared and formatted in the card with Jinja

But I can’t use cards as a favorite in the Built-In Home Assistant dashboard. The functionality has to be encapsulated in an entity. I’ve got one that shows the different status numbers, but I have not figured out the colors. I’ll try HTML and see if I can make that work.

It only works in Markdown cards and there is no way to make it work in the auto-generated dashboard.

That’s my problem, WallyR. I’ve got a custom card solution, but want a way to make it work in the auto-generated dashboard. If the whole thing could be compressed into an entity it might work. That is why I think there should be a more general entity with multiple text/color/icon style options. Or maybe states.

The auto-generated dashboard use only core-included cards and there is no way to use color in them.
Color is only when a state is on and it is the default theme color then.

You will have to take control of your dashboard to get your idea done.