Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using variables inside the card_mod part of a card #89

Closed
marcis92 opened this issue Jan 22, 2025 · 4 comments
Closed

Using variables inside the card_mod part of a card #89

marcis92 opened this issue Jan 22, 2025 · 4 comments

Comments

@marcis92
Copy link

I'm rebuilding my main dashboard to minimize my codebase. Therefore I'm using decluttering card now.

I created a card using button-card for every room of my house.
Every room is visualized with another color: bedroom entities in blue, office entities in pink for example.

Problem:
When using the variable for the color in the button card outside the card_mod part, it works like a charm and I could pass the color through the variables defined in the cards, to color the icons, background of icon. But when I use the exact same variable inside the card_mod part to change the look of the switch for example, its not working. Please see following screenshots (first one shows my issue, second one what it should look like).

Image

Image

card_mod config inside the template:

                  card_mod:
                      style:
                        hui-generic-entity-row:
                          $: |
                            state-badge {
                              display: none;
                            }
                          ha-entity-toggle:
                            $:
                              ha-switch:
                                $: |
                                  .mdc-switch__track  {
                                     --switch-checked-track-color: '[[room_color]]';
                                     }
                                  .mdc-switch__thumb {
                                     --switch-checked-button-color: '[[room_color]]';
                                        }

When replacing the '[[room_color]]' with var(--office-pink) it looks like the 2nd screenshot.

variables defined in the actual card:

type: custom:decluttering-card
template: room_template
variables:
  - room_color: var(--office-pink)

I couldnt get it to work for hours now. I'm pretty sure its just a small thing but my brain is dead right now.

@ildar170975
Copy link

This is a question, not a bug or a feature request.
Should be asked in Community.
Try without commas:
--switch-checked-track-color: [[room_color]];

@marcis92
Copy link
Author

Thanks!
Sorry for inconveniences.

@ildar170975
Copy link

@marcis92
Did it help?

@marcis92
Copy link
Author

marcis92 commented Feb 2, 2025

@ildar170975 yes it worked, I'm pretty sure I tried that too, but I think in combination with other changes, so it didnt work then for me.
Thanks for the heads-up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants