thomasloven / lovelace-state-switch

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

Styles in state-switched cards #69

Closed VDRainer closed 2 years ago

VDRainer commented 2 years ago

Not sure where to post this, but as it has to do with my other issue with state-switch, i post it here.

To use the latest 1.9.1 version, i changed the custom-gauges to core gauges, but as i find them too big, i tried to reduce the height with card-mod.

          - type: horizontal-stack
            cards:

              - type: custom:state-switch
                entity: binary_sensor.e3dc_net_power_stat
                states:

                  'on':
                    type: gauge
                    name: Netz Bezug
                    entity: sensor.e3dc_net_power
                    min: 0
                    max: 15000
                    theme: th_gauge_4
                    severity:
                      green: 30000
                      yellow: 30000
                      red: 0
                    card_mod:
                      style: |
                        ha-card {
                          height: 85% !important;
                        }

                  'off':
                    type: gauge
                    name: Netz Einspeisung
                    entity: sensor.e3dc_net_power_neg2pos_only
                    min: 0
                    max: 30000
                    theme: th_gauge_4
                    severity:
                      green: 0
                      yellow: 30000
                      red: 30000
                    card_mod:
                      style: |
                        ha-card {
                          height: 85% !important;
                        }

              - type: gauge
                name: Haus
                entity: sensor.e3dc_house_power
                max: 15000
                theme: th_gauge_4
                severity:
                  green: 0
                  yellow: 5000
                  red: 10000
                card_mod:
                  style: |
                    ha-card {
                      height: 85% !important;
                    }

I don't know if I did the style right, but it looks like it doesn't work in the state-switched cards. Auswahl_051

Thanks in advance!

ildar170975 commented 2 years ago

Try applying card-mod to the state-switch card itself, let's see if it helps.

VDRainer commented 2 years ago

Thanks @ildar170975 for your response. I tried the same code again and it works now. Don't know what has changed since opening that issue. Now i have a problem with a gap in the horizontal-stack to the next card, but that's not related to state-switch, i think. 20211214_213842