Hi, just curious. I’d love for my templated sensors to have an icon that changes color based on their state. Trying to figure it ous, I’ve read a bunch of posts of people wanting the same, and from the responses I understand that it is not possible for a template - or you’d have to template it in a front-end card. It seems odd that it’s easy to change the icon based on state, but not the color. And many third-part integrations provide icons that change color based on the state, what is the reason templates can’t do the same? Is it on a request list somewhere I can add my vote to? Or maybe I’ve completely missed the point somewhere!
Because none of the built-in cards (well, maybe 1 does) allows templates. So you can’t template the front end theme stuff without the ability to do templates at all.
Custom cards, some of them, you can template so you have access to playing with the themes and stuff.
Use a custom card.
The icon is not part of the theme stuff, just a data file pulled in. Color is tangled in the card theme stuff. At least that’s how I understand it. Someone will correct me if I’m wrong.
Card _mod can also “address” this, in most cards
Perhaps the OP asks about templating in template sensors in Core, not in Frontend:
- We have a possibility to define an icon with templates.
- Why we cannot define an icon color as well?
My imho is that colors are a part of Frontend, not a Core.
Some entity domains like:
– binary_sensor, cover etc (which have a fixed set of possible states),
– person, device_tracker (which may have various states like “home”, “away”, “School” etc),
have icon colors depending on a state, but these colors are defined in Frontend.
Frontend may define these colors either using some common default rules (like “amber for ON, grey for OFF”) or using a user-defined custom theme.
Frontend is “executed” on a client side; every client may have own theme - this allows a young family member to use own nice color set, and an elderly family member - more contrasted colors.