Color of the text displayed by state-label

I’ve some ‘state-labels’ I want to change the color from, based on state.

For example:

voorbeeld

The temperatures (state-labels) are displayed, and I can change the colour also in raw-editor.
But I want them to change them (not the names, the values) automatically, based on the state values HA gets.

For state-icons, this works like a charm (I have Custom UI):

sensor.temperature:
  friendly_name: Temp
  templates:
    icon_color: >
      if (state < 2) return 'darkblue';
      if (state < 7) return 'dodgerblue';
      if (state < 15) return 'lightblue';
      if (state < 19) return 'lightgreen';
      if (state < 22) return 'green';
      if (state < 23) return 'darkgreen';
      if (state < 30) return 'orange';
      if (state < 40) return 'red';
      return 'firebrick';

To get my icons changing colour based on the different states.

I did try a lot of things by changing ‘icon-color’:

text-color, label-color, label-text-color,… But nothing seems to work.

You can’t template in customize section without custom UI. Do you have custom UI installed?

Yes, I do have custom UI installed.

Still it seems not possible to change that text-color? The icon does change the colour correct with the temperature like written in the template.

Personally, I think you should ditch Custom UI and move towards card-mod in lovelace. You’ll have a much easier time modifying all properties.

I don’t use CustomUI but I can spot the templates, which is why i asked if you installed it. Many people just haphazardly try to use the templates without the backbones.

@Mariusthvdb can probably help.

Ok, thank you. I’ll take a look at card-mod. It looks pretty good at first sight.

Oh yeah, it’s super easy too once you get the CSS down. Use chrome and check out this post to figure out css attributes.

1 Like

depending on the items that need customizing… I can help.

what would be the card you are using here?
Custom_ui uses themes, with which you can color the full line in a regular card, from icon, entity name to state.

That isn’t supported any longer in Lovelace, though when one clicks the more-info, you can still see it active:

not themed in Lovelace:
41

click more info:

50

card-mod does indeed allow for customizing almost anything, so yes, @petro is right, learn how to use it. (seldomly have to set an icon in all of the many button cards use, it is all set in customize, and has been so for over a couple of years…) saves me a lot of extra lines in the config, and makes the card configs so much cleaner.

Big disadvantage imho, is we have to style (the new customize) in each and every spot the entities are used, where custom-ui is a system-wide setting.
Meaning, eg, no matter where I use an entity in the cards, if the icon is set in customize, it is shown in all places where the entity is used.

customize_glob, which has even more power combined with custom-ui is a miracle of ease. I use it until the day it officially gets kicked out of HA. I take it the community will protest against that… :wink:
Don’t think it will come back, Ive asked many a time now…

btw, if you want the colors of ha interface text to be customized, of course use themes, and then all of that is system wide also. That hasn’t changed, in fact, the options have improved…

1 Like