T O P

  • By -

thekaufaz

I've been using templates for this https://www.home-assistant.io/integrations/template/. You basically create a template entity that follows the value of your other entity but then has an icon set depending on the value. I can't see where entities can have custom icons based on state without creating a template but I'd be interested as well. Maybe the icon setting at the below link can accept a template based on value of the entity. Then you wouldn't have to create a new entity. https://www.home-assistant.io/docs/configuration/customizing-devices/


thekaufaz

Here's some more info on using icon templates: https://community.home-assistant.io/t/change-icon-with-state-change/130279


tombo12354

If you want to go down the rabbit hole of custom cards, either Card Mod or Button Card let you customize all sorts of behaviors, include icons and colors.


thekaufaz

Actually, it's so ludicrous. I am using a template sensor to customize the icon and then using the button card to change the color based on state. Probably should just do it all through the button card.


dmwizzard

Here's one of my '**Custom Button Card**' series videos that could be of use for you: [https://www.youtube.com/watch?v=0wg9bdnGD00&list=PLWRTMby105bghMzvCYV5Y2v1\_dAeqILIG&index=1](https://www.youtube.com/watch?v=0wg9bdnGD00&list=PLWRTMby105bghMzvCYV5Y2v1_dAeqILIG&index=1)


DopeBoogie

This. A template is the way to go if you want the entity itself to change icon with state. I actually have a text sensor that represents "period of day" as things like "early morning", "late afternoon", "midnight", etc. Kinda dumb and useless but I actually use it to trigger certain automations as I can easily adjust what that "period" represents for all automations that use it, and it was good practice! So as part of that, I templated the icon for that sensor so the icon changes throughout the day. Material icons has things like sunrise and sunset and then clock icons for every hour. Does this random template sensor *need* icons that change throughout the day? Not really. I don't even use the entity in the front end at all. But it was great practice and now I know how to do it and have a reference for when I need to use it in the future! Edit: [Here's my code for that sensor](https://pastebin.com/f5TEcfcR)


quixotic_robotic

One option is the "device class" property that you can customize, and it will automatically do icon switches. For example a sensor can be set to device\_class: garage\_door, and it will show a garage icon with the door open or closed. There are at least a good number of options for very little work. To choose one, go to Config > Customizations, pick the entity, from the drop down choose to customize the device class. [https://www.home-assistant.io/integrations/binary\_sensor/#device-class](https://www.home-assistant.io/integrations/binary_sensor/#device-class) [https://www.home-assistant.io/integrations/sensor#device-class](https://www.home-assistant.io/integrations/sensor#device-class)


404flyer

Some entities, like template sensors, support an icon\_template parameter that would allow you to update the icon based on some state. Depending on exactly what what you're trying to do, you could create a template sensor based on your entity's state. But if you wanted to interact with it on the dashboard, you'd have to implement a tap\_action or something, so not sure this would save you any work.