Change device_class icon

Hello to everyone, i need some help if is possible…
i want to change the icon of the device_class window with this icon window-closed-variant how can i do?
i have many sensors so for me is more seimple to change the class instead of the icon (with on and off change) of all sensors.
There is also a way to add more device_class? like add gate class with different icon.
Thanks a lot
Stefano

You can’t, you’d have to template the icon with a sensor template. Or you could template it on the frontend with one of the many custom cards that can do this for you.

No, device classes are currently set in stone.

Thanks a lot petro for your fast reply.
i hope in the future we can change and add some device_class :smiley:
Some suggestion for custom cards?
I need to template about 30 sensors so if custom cards is more faster i try with that…

Thanks a lot
Stefano

It depends on what you want to do for your interface. If you just want a simple row inside a entities card, use the template row card.

This seems perfect!! :smiley: thanks a lot petro!! :smiley:

Hi @petro , can you explain what that means:

I think i have the same issue: I want to replace the window-icon with its alternative.

device_class icons are static. You can’t override them. Your only option is to create a new template sensor that contains an icon template.

Thats above my capabilities, but thank you. It´s a pity simple things like icons are hardwired.

You can customize icons for patterns or domains:

  # Customize all entities in a domain
  customize_domain:
    light:
      icon: mdi:home
    automation:
      initial_state: "on"
  # Customize entities matching a pattern
  customize_glob:
    "light.kitchen_*":
      icon: mdi:description
    "scene.month_*_colors":
      icon: mdi:other

All my Nest Protect smoke detectors starts with binary_sensor.nest_* so the above was perfect for my need.

Hello,
Old subject but still alive. It is really a pain that you can change the Window class icon ! The default icon is ok for windows that open vertically (common in GB) but not for other windows that open horizontally (like in France)… Moreover, an icon variant exists for that ! Still no possibilities to tweak that even with the latest HA versions ?

If it’s not an available device_class, then you’d have to template it with a template sensor or a custom card.

Personally, I’d just make a #feature-requests for the window variant.

Thanks ! Will have a look at templates but it’s not my beginner’s priority… :wink:

Related to what is discussed here, I don’t necessarily want to change the icon, rather change the color of the icon. For example, when door is open, I would love for the icon to be RED and when closed be GREEN. When I look at the dashboard, the open door icon for my chicken coop door is not obvious to me (at a glance) that the door is open. If I could change the color to bright RED, then when I glance at the dashboard after 10 PM, let’s say, then it will be immediately obvious to me that the door is open.

I do have an automation that announces via Google Home that the door is open after sunset and that it needs to be closed, but sometimes we are in a different room, or possibly Google Home is quirky that day and it fails. Having a simple visual indicator is helpful. Is there a way to change the color of the default device_class icons without building a template? The chip card, has a setting for icon color, but this does nothing and I believe if it did work, the icon would be the same color for both ON and OFF when displaying the door sensor icon…

You can do this through themes using state-{domain}-{device_class}-{state}-color

e.g.
state-binary_sensor-door-on-color: #FF0000
state-binary_sensor-door-off-color: #00FF00