thomasloven / lovelace-state-switch

🔹Dynamically replace lovelace cards depending on occasion
MIT License
382 stars 27 forks source link

Card_mod inside state_switch doesn't work #103

Open MikeTheCleric opened 1 year ago

MikeTheCleric commented 1 year ago

Hi! I'm using state switch to contain a "vertical-stack-in-card" with a bunch of sliders in it. If I use the card_mod on the sliders it doesn't work at all. If I put the sliders outside the state switch the card_mod works like a charm. Someone knows why the card_mod doesn't work in this condition? Here's my YAML config of the page. Thanks in advice.

- type: custom:state-switch
  entity: xxxxxxxxxxxxxxxxxxxxxxxxx
  default: default
  states:
     "on":
       type: 'custom:vertical-stack-in-card'
       cards:
         - type: custom:slider-entity-row
           entity: yyyyyyyyyyyyyyyyyyyyy
           full_row: true
           hide_state: true
           card_mod:
             style:
               div.wrapper:
                 ha-slider.full $: |
                   div#sliderContainer.pin {
                     margin-left: 5px !important;
                     margin-right: 10px !important;
                   }
ildar170975 commented 1 year ago

How is that related to state-switch? Try using card-mod w/o placing your stack inside state-switch and check if it works.

MikeTheCleric commented 1 year ago

Hi! Thanks for the reply. I tried to place my card outside the state switch and it works with the card_mod.

ildar170975 commented 1 year ago

I tried to place my card outside the state switch and it works with the card_mod.

Could you post a picture with your test card and Code Inspector to check if these margin styles are applied?

OK, nevermind. It will NOT work. Even this simple will not work (i.e. style is not added in Code Inspector):

       type: 'custom:vertical-stack-in-card'
       cards:
         - type: custom:slider-entity-row
           entity: input_number.test_number
           card_mod:
             style: |
               div.wrapper {
                 color: red;
               }

One of reasons - because you are using the slider-card NOT inside Entities card (as it supposed to be used). По-русски - учим матчасть...

MikeTheCleric commented 1 year ago

Ok, thanks for the help! I'll try using the entities card.