Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why icon_color does not work? #35

Closed
Javito68 opened this issue Apr 9, 2021 · 9 comments
Closed

why icon_color does not work? #35

Javito68 opened this issue Apr 9, 2021 · 9 comments

Comments

@Javito68
Copy link

Javito68 commented Apr 9, 2021

Greetings to all,
I do not understand why this code to change the color It does not work, in : config/customize.yaml:

#Sensores Estacion Meterologica:
sensor.temperatura1:
friendly_name: "Temperatura dht22"
icon: mdi:speedometer-slow
templates:
#icon_color: green
icon_color: >
if (state < 25) return 'green';
else return 'red';

Target:
image

Entity:
image
Config-> Info:
image

image

observing the file structure I don't have the lovelace directory in www, is it normal? it is installed in docker.
Thanks for everything!!!

@Mariusthvdb
Copy link
Owner

Hi, as the screen shot shows, you haven't yet installed custom-ui.

Please check the documentation how to do that first.

@Javito68
Copy link
Author

Javito68 commented Apr 9, 2021

thanks for answering Mariusthvdb, I just installed custom-ui:
image

but it does not work, any suggestions?

image

Thanks!!!

@Mariusthvdb
Copy link
Owner

You didn't install the custom-ui in this repo, but the old and no longer working version...

Please delete this and check the docs once more.

After that show the info page with the version installed

@Javito68
Copy link
Author

Hi Marius, instalado:
image

now I have the following doubts:
- Why does it not work in the target entity and if in the target entities?

image
image

-How can I hide attributes? I have used hide_attributes in customize.yaml and it doesn't work:

sensor.temperatura1:
hide_attributes:
friendly_name: "Temperatura dht22"
icon: mdi:speedometer-slow
templates:
#icon_color: green
icon_color: >
if (state < 25) return 'red';
else return 'green';

image

thank you for your patience!!!

@Mariusthvdb
Copy link
Owner

Mariusthvdb commented Apr 10, 2021

Hide_attributes:

You didn't configure what to hide ;-) check the docs and see eg templates and icon_color, or simply set all

Color:
Could be 2 things: not always necessary, but did you also restart?

If so, it could be you need to quote the number (because it could be a string), so try '25'

Lastly, the word 'else' is not needed.

@Javito68
Copy link
Author

Hi,
Hide_attributes -> Ok

Color:
in each change restart, the data is numeric as string does not work, overridden the else:
sensor.temperatura1:
hide_attributes:
- templates
friendly_name: "Temperatura dht22"
icon: mdi:coolant-temperature
templates:
#icon_color: green
icon_color: >
if (state < 0) return 'red';
if (state < 20) return 'yellow';
if (state < 30) return 'green';
if (state < 50) return 'red';

it not work in the target entity, why?
image

Thanks!!!

@Mariusthvdb
Copy link
Owner

Mariusthvdb commented Apr 10, 2021

that card probably can't be customized by custom-ui, because it uses another way of displaying the icon_color.

you need the card-mod resource by Thomas Loven, check https://community.home-assistant.io/t/card-mod-add-css-styles-to-any-lovelace-card/120744/1396 by @ildar_gabdullin for many suggestions to do so.

@Javito68
Copy link
Author

Thanks and greetings !!!

@Mariusthvdb
Copy link
Owner

you're most welcome ;-)
closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants