thomasloven / lovelace-state-switch

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

Nesting not possible? #57

Closed derandiunddasbo closed 2 years ago

derandiunddasbo commented 2 years ago

With the following card configuration, the button card on the nested state-switch card only becomes visible after saving the card (and of course only if the binary sensor is 'off'). On page reload, the button card disappears, only the two weblinks stay visible:

type: custom:state-switch
entity: deviceID
states:
  01234567-89abcdef:
    title: Apps
    type: vertical-stack
    cards:
      - type: custom:state-switch
        entity: binary_sensor.galaxy_tab_a_eg_kiosk_mode
        states:
          'off':
            type: custom:button-card
            show_label: true
            icon: mdi:cellphone-lock
            label: Kiosk-Modus ein
            tap_action:
              action: call-service
              service: rest_command.galaxy_tab_a_eg_kiosk_rest_command
              service_data:
                cmd: setBooleanSetting
                key: kioskMode
                value: true
      - type: entities
        entities:
          - name: Spotify
            type: weblink
            url: javascript:fully.startApplication('com.spotify.music')
          - name: Philips Hue
            type: weblink
            url: javascript:fully.startApplication('com.philips.lighting.hue2')

Is this expected behaviour? Is nesting of state-switch cards not supported?

Versions used:

derandiunddasbo commented 2 years ago

I don't know, if this issue will be processed sometime, but if anyone faces a similar problem, here's a possible workaround without nesting two state.switch cards and instead using a conditional card:

type: custom:state-switch
entity: deviceID
states:
  01234567-89abcdef:
    type: vertical-stack
    cards:
      - type: conditional
        conditions:
          - entity: binary_sensor.galaxy_tab_a_eg_kiosk_mode
            state: 'off'
        card:
          type: custom:vertical-stack-in-card
          cards:
            - type: custom:button-card
              show_label: true
              icon: mdi:cellphone-lock
              label: EG Kiosk-Modus ein
              tap_action:
                action: call-service
                service: rest_command.galaxy_tab_a_eg_kiosk_rest_command
                service_data:
                  cmd: setBooleanSetting
                  key: kioskMode
                  value: true
              show_empty: false
thomasloven commented 2 years ago

Please try release 1.9.0