marcokreeft87 / room-card

Show multiple entity states, attributes and icons in a single card in Home Assistant's Lovelace UI
MIT License
228 stars 38 forks source link

Add a state_color_value variable to make it easier to change icon colours when an entity is 'on' #345

Closed lennon101 closed 2 months ago

lennon101 commented 2 months ago

Is your feature request related to a problem? Please describe.

You already have a show_state and state_color variables which is great, it feels like the only thing that is missing to clean up the code is ability to quickly change the colour of an icon. At the moment the only way I found to do this is using templates (not currently working for me issue #344 ) or styling the icon by checking for the state of the entity using jinja templates per entity. Gets messy. Why not just have a variable to change the colour of the icon if the entity is on? It seems like this is something that everybody is going to want to do.

Have you tried if it is already a feature? Have you checked the wiki?

Currently the way I'm achieving this is:

  - entity: group.bathroom_motion_lights
    name: Auto Lights
    tap_action:
      action: toggle
    show_icon: true
    icon:
      template:
        styles: |
          if (entity.state == 'on') return 'color: yellow';  

Describe the solution you'd like

It would be so much cleaner if I could do something like this:

  - entity: group.bathroom_motion_lights
    name: Auto Lights
    show_icon: true
    icon_color_value: yellow  

Describe alternatives you've considered

I've already tried templating the card but it appears the template engine has bugs. See issue #344

Additional context none

marcokreeft87 commented 2 months ago

That's not possible because the text gets parsed to javascript. Your suggestion won't work than.