thomasloven / lovelace-card-mod

🔹 Add CSS styles to (almost) any lovelace card
MIT License
1.16k stars 168 forks source link

Interaction between card-mod 3.0 and the custom button card results in no color until entity state update #105

Closed rccoleman closed 3 years ago

rccoleman commented 3 years ago

My Home Assistant version: 2021.3.0b0

My lovelace configuration method (GUI or yaml): YAML

What I am doing:

I have a dashboard that consists mostly of Custom Button Cards (https://github.com/custom-cards/button-card), some of which change color based on the state and some with a static color. Most have no card-mod styling at all, just what's available in the Custom Button Card. As soon as I update to card-mod 3.0, my custom button card elements start white and only reflect the proper color when the underlying entity changes state. These custom button card elements have no card-mod styling at all, so I don't understand why there's a relationship between the two.

I detailed my findings at https://github.com/custom-cards/button-card/issues/440 and then realized that simply backing card-mod down to v2.0.3 brings back my custom button card colors and behavior. I don't think this is related to the HA beta, but can't easily back down to check.

What I expected to happen:

Colors assigned to the custom button card should be reflected on page load and restart.

What happened instead:

Custom button card elements start white and only reflect the proper color when they change state.

Minimal steps to reproduce:

type: 'custom:button-card'
entity: input_boolean.test1
color: green

Note that there's no card-mod styling there at all, but the behavior changes based on whether I also have card-mod 2.0.3 or 3.0 installed. You must clear the cache after installing card-mod 3.0 to see the change in behavior (i.e., the icons that are initially white).

Error messages from the browser console:

There are no errors in the console.


By putting an X in the boxes ([]) below, I indicate that I:

RomRider commented 3 years ago

The problem sits here: https://github.com/thomasloven/lovelace-card-mod/blob/master/src/patch/ha-icon.ts#L15-L18

No test if the color of the icon needs to be applied.

thomasloven commented 3 years ago

Correct. The very last change I implemented.

Surely such a simple thing doesn't need integration testing... 😡 3.0.1 coming up in a minute

genehand commented 3 years ago

Been using this with fully kiosk browser on a slow tablet. Before, switching between dashboard views was painfully slow. After updating to the new syntax, it's completely responsive. OT but wanted to say thanks!

rccoleman commented 3 years ago

Works great, thanks for the quick turnaround!