Colored Icons Based on Values

Good evening,

I’m relatively new to Home Assistant. So far, I’ve managed to build a dashboard that displays an overview of my house’s floor plan. In each room, icons allow you to switch to the detailed floor plan. Everything works fine. I’m using an Aeotech Multisensor 7 as a test sensor. In the room where this device is installed, I want to display information on both the overall floor plan and the detailed floor plan. This would take the form of icons with (temperature) values next to them. I’m using the “mdi:thermometer” icon. My problem is that I’ve been trying for days to make this icon change color based on its status. Examples: Temperature below 10°C -> blue thermometer, around 20° -> green thermometer, etc. I define the temperature status in templates.yaml. I can also see this status under “Developer Tools/States”: “icon_color -> green”. It works in the backend. But when I try to display the icon in color on the dashboard, I fail. I’ve tried a few approaches, including Java logic like:

styles:
icon:
- color: >
[[[ return states[‘sensor.xxxxxxxx’].attributes.icon_color; ]]]

No errors are reported, but the temperature icon remains “gray.” I also tried using “state(s).” The icon's color does not change. If I specify a color for the icon (- color: red), it is displayed. It works statically, but not dynamically. For your information. I am using HA version 2026.4.4, Supervisor: 2026.04.2, OS: 17.2. I do not use custom cards such as button cards, mushroom cards, etc. Apparently, it should be possible to display the icons in color. However, I have not yet found a way to correctly pass the determined attribute to the frontend. Perhaps it would be good to first find out whether a dashboard with image elements is capable of generating state-dependent icon colors. If that is the case, I would be happy to contribute some information on exactly how to do it.

It would be great if anyone has any ideas about this.
Best regards, Gigabaron

Post to Moderator.
Hello,
my post was automatically hidden and I’m not sure why.
I’m a regular user and simply asked a technical question.
Could you please check and restore it?
Thank you!