thomasloven / lovelace-template-entity-row

🔹 Display whatever you want in an entities card row.
MIT License
224 stars 18 forks source link

Colors of icons changing with recent versions #123

Open martkopecky opened 8 months ago

martkopecky commented 8 months ago

Not sure if this is a bug or a feature, but with one of the last plugin versions & update to HA 2024.02, the colors of the icon for template-entity-rows have started changing based on the underlying entity state. I've seen yellow/amber for toggle: on and also purple in some cases.

For now, it can be cured by specifying color: var(--paper-item-icon-color) explicitly.

I can see no such behavior on the automatically generated dashboard, so I expect that this whole color changing is not something new in the core components just being inherited to the template entity row.

Sorry for the vague description. Here an example of amber icon:

image

ildar170975 commented 8 months ago

the colors of the icon for template-entity-rows have started changing based on the underlying entity state. I've seen yellow/amber for toggle: on and also purple in some cases.

This is normal & expected in Entities card with "state_color: true" defined.

martkopecky commented 8 months ago

I have no such card defined in my dashboard, they either don't have the state_color attribute at all or they are set to false. Based on the docs, false is default.

So I think the root cause is somewhere else...

thomasloven commented 8 months ago

There was some buggy behaviour around this introduced in a recent version of Home Assistant. Work is currently ongoing to determine what is the right behavior, and then to fix it.

Mariusthvdb commented 8 months ago

not sure if this is the same, but template-entity-row does not follow state_color: true when doing

type: entities
state_color: true
entities:

  - type: custom:template-entity-row
    entity: sensor.slaapkamer_hygro_temp_battery
Scherm­afbeelding 2024-03-11 om 13 25 07

while its more-info does show the correct state_color:

Scherm­afbeelding 2024-03-11 om 13 25 17

we can set an explicit card_mod on it:

      - type: custom:template-entity-row
        entity: sensor.slaapkamer_hygro_temp_battery
        card_mod: !include /config/dashboard/card_mods/battery_color.yaml

which does:

Scherm­afbeelding 2024-03-11 om 13 28 12

currently testing with

Core 2024.4.0.dev20240311 Frontend 20240308.0.dev

ildar170975 commented 8 months ago

this is the same, but template-entity-row does not follow state_color: true when doing

This was broken in 2024.3.

chemelli74 commented 8 months ago

Seems there is something more:

image

ildar170975 commented 8 months ago

@chemelli74 yes, same issue

chemelli74 commented 8 months ago

@chemelli74 yes, same issue

Sorry, I may miss something but core itself shows green color (which is correct), while template row not. Isn't it an issue on this custom card code ?

ganjakyp-hub commented 5 months ago

Is there any solution to this problem?

Mariusthvdb commented 4 months ago

getting back to this, because after testing 2024.7.beta, I now also see that the active options is not set when using below config, nor is the icon properly inherited from the entity, as the documentation explains/instructs:

      - type: custom:template-entity-row
        entity: device_tracker.private_ble_device_marijn
        active: >
          {{is_state(config.entity,'home')}}

should light up properly (it did before) and change to the connected icon:

this it the template entity row:

Scherm­afbeelding 2024-06-27 om 16 22 22

and yes, ive also setstate_color: true in the containing entities card.

this is the correct more info:

Scherm­afbeelding 2024-06-27 om 16 22 29

coloring according to the theme colors, and setting the icon according to the device

could it be relatively new Icon translations are not yet supported and we need to explicitly template those now?

ildar170975 commented 4 months ago

Imho active is not working for some long time. For instance, in 2024.6.4 it does not work:

image

image

Mariusthvdb commented 4 months ago

thanks for confirming, I wasnt sure.

However, I am sure it did work when I created this card, and that was short after the private Ble were introduced, and a bit later when the state_translated was introduced.

dont believe the template-entity-row has the state_color: option though? (the bottom example of your post.)

anyways, I really hope this magic card will see an update sometime.

maybe I should open a separate issue for the icon (didnt check yet if there already is one), to keep it as clear and clean as possible to track

ildar170975 commented 4 months ago

dont believe the template-entity-row has the state_color: option though? (the bottom example of your post.)

Added this example just in case.

ildar170975 commented 4 months ago

According to my log, "active" was not working by "06.04.23".

maximuswallis commented 4 months ago

Hi, A workaround to this problem is adding this to the entity:

color: |
  {% if is_state('switch.your_switch_here', 'on') %}
    var(--state-active-color)
  {% elif is_state('switch.your_switch_here', 'off') %}
    var(--state-inactive-color)
  {% else %}
    var(--disabled-color)
  {% endif %}

I hope this helps someone!

arigit commented 1 month ago

still an issue as of 2024.10.2; thanks @maximuswallis for the workaround!