question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

accept entities icon_color attribute

See original GitHub issue

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I’m always frustrated when […]

Using custom_ui, next to templating existing attributes, we can set (and template) an additional icon_color attribute for an entity.

per domain, per _glob, or per entity. Just like any other customization in HA.

regular entities card in HA respects that, as do many other cards in HA. More-info popup does.

Unfortunately, custom button-card does not.

Schermafbeelding 2021-01-12 om 11 48 37 Schermafbeelding 2021-01-12 om 11 49 37

Describe the solution you’d like A clear and concise description of what you want to happen.

Next to the formatting options button-card does offer (which are huge and great, don’t get me wrong, use them all over) it would be really nice if button-card could accept the icon_color attribute if available ( when set by custom_ui)

Describe alternatives you’ve considered A clear and concise description of any alternative solutions or features you’ve considered.

Additional context Add any other context or screenshots about the feature request here.

set an icon and icon_color, based on the state of the entity. Icon is respected in button-card, unfortunately, icon_color isnt.

One huge advantage would be that the glob customizations we can set using custom_ui, would prevent all individual per entity styling in button cards.

eg check all that is necessary for my battery sensor coloring:

    sensor.*_bewegingssensor:
      templates: &battery_color
        icon_color: >
          if (state > 75) return 'green';
          if (state > 50) return 'gold';
          if (state > 25) return 'orange';
          if (state > 10) return 'brown';
          return 'red';

    sensor.*_dimmer:
      templates: *battery_color

    sensor.*_afstandsbediening:
      templates: *battery_color

    sensor.*_remote:
      templates: *battery_color

    sensor.*_battery_level:
      templates: *battery_color

    sensor.*_battery:
      templates: *battery_color

    sensor.battery*:
      templates: *battery_color

This makes the magic happen on all core entities cards, but also in auto_entities and others. Now imagine having to write buttons for all of those button cards…

the magic line:

this._iconStyle = {color: stateObj.attributes.icon_color;}

is what made it work in custom_ui. maybe that could be used here too?

please consider? thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Mariusthvdbcommented, Jan 14, 2022

sure, check all the glob examples in https://github.com/Mariusthvdb/custom-ui/blob/master/EXAMPLES.md

this FR should be closed though, thanks for reminding me 😉

0reactions
rob196commented, Jan 14, 2022

@Mariusthvdb @andrey80nik

Old issue, but hope will be useful still

Not sure if this would work for you, but I am using Customizing entities

The customize_glob specifically makes life a lot easier

I don’t have an icon_color attribute, but the below should give you an example

homeassistant:
  customize_glob:
    sensor.yahoofinance_*:
      templates:
        icon_color: >
            if (entity.attributes['trending']=='up') return 'green';
            if (entity.attributes['trending']=='down') return 'red';
Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity Icon color & custom icon color based on state ...
Should be really simple though, replace icon_color with another attribute/option. Icon can still be templated, so the main framework still holds ...
Read more >
Can we have the entity icon color customize template? #300
I wanna to customize the mdi icon color depends on the state of a entity. for example when the dimming light color is...
Read more >
How to set the color of an icon in Angular Material?
That's because the color input only accepts three attributes: "primary" , "accent" ... In the component.css or app.css add Icon Color styles
Read more >
How to style icon color, size, and shadow by using CSS
Example 1: This example set the size, color and shadow of icon using CSS.
Read more >
Lightning : Icon color is not changing using the fill CSS
Actually the issue is which element you are applying the "fill" property to. Meaning when you declare something like <lightning:icon class="icn" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found