How to have input boolean icon change color when switched?

Hi, is this working without any additional instalation? Or should I install something else?

what are you referring to?

I’m trying to make this code working with no luck :roll_eyes:

please use the </> code blocks…

did you install custom-ui ? https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/installing.md

1 Like

Thank you, this is it! It works now

Hello there! Thanks for this great advice. I have put it into my configuration.yaml but it doesn’t seem to do anything. Does this solution still work? I am running 0.89.2 of Hassio. (No custom UI installed as I am using lovelace)

Otherwise, is there any way to check if this is doing anything, yes or no?

Thanks again!

not sure what you’ve ‘put in’ but if you’re referring to the template, it won’t work unless you install custom-ui. Using Lovelace is by no means any reason not to install custom-ui.

Thanks for the quick response. I was indeed referring to your template. I will have a look again into custom-ui. I was in the opinion I read somewhere on their github that lovelace wasn’t supported yet, so I cancelled the idea of installing it.

Thanks for the confirmation the above script doesn’t work without custom-ui. I was trying to get it working for quite some time already.

we’re all hoping a dedicated custom-ui for Lovelace might (soon) see the light, but for now, many customizations do work under Lovelace. Not all though, and even if HA in its latest version deprecates some of its features, it is imho a valuable extra to the default ui/ux Ha offers without it.

You actually want this option:

          state_color: true

no, this only for a single entity, or per card.
What is want (and have for now…) is this:

homeassistant:

##########################################################################################
# Domain
##########################################################################################
  customize_domain:

    automation:
      templates: &state_color
        icon_color: >
          if (state == 'on') return 'gold';
          return 'steelblue';

    binary_sensor:
      templates:
        <<: *state_color

    input_boolean:
      templates:
        <<: *state_color

    switch:
      templates:
        <<: &toggle_icon
          icon: >
            if (state == 'on') return 'mdi:toggle-switch';
            return 'mdi:toggle-switch-off';
        <<: *state_color

custom-ui makes this and other customizations globally available to the entities.

It works to turn the icon highlight on, and was actually mentioned in the release notes awhile back when they changed the behavior.