Change known_devices color label

Hi All,

I have a few known_devices and i want to change the color of the label

when it’s away i want it to be in red color and when it’s home i want it to be green

is this possible ?

if so how do i do that ?

Thanks :slight_smile:

Maybe try something like this - Custom UI - icon color change

Hi

It didn’t worked but i am guessing that i just don’t know how to make it work

if you could give me an example because when i tried he said that i can’t use rgb_color:

Thanks :slight_smile:

In my customize.yaml I have entries like

sensor.door_back_status:
  templates:
    rgb_color: "if (state === 'Open') return [200, 100, 30]; else return [10, 20, 30];"

so I guess you want a similar entry for your device.WHATEVER using a suitable state

You may need to install custom UI first

2 Likes

Thanks i will try it later today :slight_smile:

for device_tracked devices this works best in my setup, change accordingly to your theme-wishes of course:

device_tracker.appletv_auditorium:
  templates:
    theme: >
      if (state === 'home') return 'green'; else return null;
    _stateDisplay: if (state === 'home') return 'Online'; else return 'Offline';

note that this is declared in a customized setting, so you’d need the customUi installed.

rgb_color works also, but that is an icon setting, theming the entity changes all of the colors (icon, name and value)

if you’d like to set it globally, create a customize_glob.yaml and enter something like this:

sensor.*_state:
  templates:
    rgb_color: "if (state === 'on') return [251, 210, 41]; else return [54, 95, 140];"

sensor.*_actueel:
  templates:
    rgb_color: "if (state > 0) return [251, 210, 41]; else return [54, 95, 140];"

Have fun!

i am unable to make it work

i am guessing i did something wrong

i install the home-assistant-custom-ui using the local install --> automatic install

after that i have add in my configuration.yaml file the following lines

customizer:
  custom_ui: local

after that in my customize yaml i’ve added this

device_tracker.my_phone:
  custom_ui_state_card: state-card-custom-ui
  templates:
    rgb_color: "if (state === 'on') return [251, 210, 41]; else return [54, 95, 140];"

but nothing happen i am not sure that i even install the custom-ui correctly

if you can direct me to the right path i will forever be your humble servant :slight_smile:

Hi - are you sure that device_tracker.my_phone has a state which is on? Mine is home or not_home

If that’s the problem you will need:

rgb_color: "if (state === 'home') return [251, 210, 41]; else return [54, 95, 140];"

(But first I guess I’d confirm that CustomUI is working ok)

Thanks for your help but this is no’t the problem

i have tried this in my customize.yaml

device_tracker.my_phone:
  templates:
    rgb_color: return [251, 210, 41]; 

and it didn’t worked

i am thinking that rgb_color is not working and because of that i am thinking that CustomUI is not working

can you please tell me what should i do in the configuration yaml to make customUI work

i have added this line to the configuration.yaml

frontend:
  extra_html_url:
    - /local/www/custom_ui/state-card-custom-ui.html
  extra_html_url_es5:
    - /local/www/custom_ui/state-card-custom-ui-es5.html

customizer:
  custom_ui: local

i also have this in known_devices.yaml

my_phone:
  hide_if_away: false
  icon:
  mac: ff:ff:ff:ff:ff:ff
  name: my_phone
  picture: /local/my_phone.jpg
  track: true
  vendor:

and in groups.yaml i have this

default_view:
  view: yes
  icon: mdi:home
  entities:
    - sun.sun
    - sensor.yr_symbol
    - device_tracker.my_phone

Thanks a lot for your help

I’m having the same problem. I can’t even get CustomUI to show in the Configuration section of Home Assistant, but CustomUI seems to be otherwise working, as I can show the last update attribute and change the colour of the badges.