Custom UI - icon color change

Changed it:

'*.*':
  custom_ui_state_card: state-card-custom-ui 
  
"device_tracker.iphone_*":
  state_card_mode: badges
  templates:
    theme: >
      if (state === 'home') return 'green_badge'; return 'red_badge';

Still got the same result, all red (with lovelace :wink: )

The funny thing is that I can see the config at customizations in the hassio ui:

i am a bit out of ideas right now.
Other than Lovelace or your version of HA has taken out further functionality of custom-ui. Or, you must have missed something in the installation of custom-ui.

I am on Ha 84.3 and have the latest version of custom-ui installed (via the ./update.sh script)

all my badges are displayed with themes, though in lovelace the themes are no longer supported in individual entities on a card:

regular HA:

31

same template sensor in Lovelace:

17

though more info shows the customization:

24

sorry, missed that question…
yes you can, click the right hand side dev-info Info button:

41

and see what is loaded:

52

No worries, I appreciate the help. This is what the information shows me:

image

strangest thing: I now notice my custom-ui is still a version behind yours :wink: I am positive though to have run the updater…

It might have to do with the Ha version, and compatibly with custom-ui. On my other HA instance the latest Custom-ui is running.
still badges are customized on that too, as explained above

Can confirm custom-ui stopped working for badges in lovelace beyond 0.85.* version of Hass.

1 Like

Told you

well, I am still on 84.3 and 84.6 as I stated earlier.

no issues on the GitHub though Issues · andrey-git/home-assistant-custom-ui · GitHub, which is remarkable if this kind of issues arise.

and what does

custom-ui stopped working for badges

imply, the regular badges as displayed on a card, extra-badges (these have issues indeed,as is on the issue tracker) or badges in a view.

My 84.6 HA instance has the extra_badge issue, but shows the regular badges and badges in a view just fine, and customizes these.

So, please be precise when saying I told you so…

1 Like

Makes sense. I am running hassio 0.87.1 and the custom UI. Followed all your great instructions @Mariusthvdb and @cameron and I can’t get it to work.

Been fighting with icon color on my cards. All my devices have a yellow icon! i even downloaded an icon from mdi in purple but it show up as yellow. I tried to use customize piece in the front end to allow the UI override and I’ve tried to add a line for icon_color in my customize.yaml where I was able to set the icon after putting the icons in my www folder. WHAT am i doing wrong???! Do I have to create what I’ve seen loosely referenced, a theme first?? pulling my hair out

Actually there is an issue which I had previously opened a while back.

I see now, thanks for alerting me.
Seems the author has left planet earth for a while… :wink: Many issues are left unanswered. Guess Lovelace takes its toll, fixing all breaking changes

So I assume it is broken (by using lovelace UI).
Two things do not work when using Lovelace and badges:

  • I have configured not to display the badge if away
  • Have colors on badges in certain states

Will it work on 0.88.2?
edit:
So it is BROKEN in classic UI and Lovelace also gets it from there.

Hi,
I’m trying to change icon colours and the following is not working, any ideas?

  • entity: light.downstairs_study
    icon: ‘mdi:ceiling-light’
    name: Study Downstairs
    templates:
    icon_color: >
    return ‘#008300’;

yes, many ideas :wink:

you should read up on how to format code in the community (use the back ticks, or the code block </> in the toolbar)

and on using custom_ui. Assuming you have installed the latter, you can then start using

homeassistant:
  customize:
    light.downstairs_study:
      templates:
        icon_color: >
          if (state === 'on') return 'yellow';
          return 'grey';

use any css accepted color styles

I want use RGB codes instead of names how can I fix this?

I tried your explanation. But the icon is not changing color

input_boolean.nest_disable_control:
  friendly_name: DNC
  homebridge_name: Disable Nest Control
  icon: mdi:nintendo-switch
  templates:
    icon_color: >
      if (state == 'on') {
        return [blue]; }
      else {
        return [red];} 
frontend:
  extra_html_url:
    - /local/custom_ui/state-card-custom-fanspeed.html
  extra_html_url_es5:
    - /local/custom_ui/state-card-custom-fanspeed.html

customizer:
  custom_ui: local

homeassistant:
  customize: !include_dir_merge_named package/customize/
  customize_glob:
    fan.*:
      custom_ui_state_card: state-card-custom-fanspeed
  auth_providers:
    - type: homeassistant
input_boolean.nest_disable_control:
  friendly_name: DNC
  homebridge_name: Disable Nest Control
  templates:
    icon: mdi:nintendo-switch
    icon_color: if (state === 'on') return 'rgb(0, 0, 255)'; else return 'rgb(255, 0, 0)';
1 Like

taking things strictly, this is not correct.

you don’t have an icon template, so you should simply set it 1 hierarchy higher.

not sure if you don’t have to quote the template, but, I always use multiline notation to get rid of that issue, using:

icon_color: >
  if (state === 'on') return 'rgb(0, 0, 255)';
  return 'rgb(255, 0, 0)';

note you don’t need the ‘else’ .

2 Likes

i single line most of mine for readability. my customize file is nearly 400 lines of similar templates. lol. probably should figure out a better way, or use glob.