Automation Icon Change Based on State?

By default, automations are configured with the “mdi:robot” icon. This changes automatically to “mdi:robot-off” when the automation is disabled. When I change the icon for an automation to “mdi:watch-vibrate”, for example, it now no longer automatically updates to the expected “mdi:watch-vibrate-off”.

Is it possible to set an automation to use something other than the default “mdi:robot” icon and have it still auto-update to the “off” version of that icon when the automation is turned-off?

depending on the frontend card you use this example uses mushroom.

type: custom:mushroom-template-card
primary: Auto Led Automation
icon: |-
  {{ 'mdi:watch-vibrate-off' if 'off' in states('automation.auto_kitchen_leds')
  else 'mdi:watch-vibrate' }} 
secondary: ''

EDIT looking at it again you can streamline that with this

mdi:watch-vibrate{{'-off' if is_state(entity, 'off')}} 

if you add an entity to the template card above

Same approach as described here.
If you choose a “Custom ui way” - use “customize_glob” to customize ALL automations.

This is useful if I create a new card…but is there any way to do this in the default automations dashboard? Having to recreate a core component seems a long way to go for this simple feature.

Does anyone know where in the source the defaul “mdi:robot” icon gets switched on and off? Maybe I’ll need to do a PR so it instead automatically attempts to change the icon from “whatever” to “whatever-off” if “whatever-off” exists as the default action instead of only for “mdi:robot” and “mdi:robot-off”?

Thoughts?

@Ildar_Gabdullin: Maybe I am misunderstanding, but the method you describe is for customizing the icons inside the automation. I am trying to customize the icons of the https://homeassistant/config/automation page, where the menu of automations is listed. Can “custom ui” help on this? I do not understand.

@Frosty This looks exactly what I would like to do but cannot figure out where I would put this. Is it possible to modify the stock/default automations page? When I try and put icon: mdi:watch-vibrate{{'-off' if is_state(entity, 'off')}} in the yaml for an automation I get an error Message malformed: extra keys not allowed @ data['icon']

Not “inside” - these methods to change an icon of an automation entity on a card in a view.
As for a list of automations - ofc these changed icons will be shown:


On this screenshot a stock “customize” was used (i.e. only static icons, not dynamic), not custom ui:

homeassistant:
  customize_glob:
    automation.net_speedtest_*:
      icon: mdi:car

Note that only 2 first autos got custom icons (although all 4 should be) since a customization appears only when an entity’s state is changed, so here I only toggled on->off->on these 2 autos to demonstrate custom icons.

2 Likes

Did you ever find a method that works for this? I’m looking for the same thing.