thomasloven / lovelace-state-switch

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

State-switch stops working since HA 2021.12 #72

Closed Spirituss closed 2 years ago

Spirituss commented 2 years ago

Lovelace doesn't show anything in lovelace. Here is the example of custom:state-switch, which is defined inside custom:layout-card, sensor sensor.priority has value 0.

views: 
- title: Title
  id: counters
  panel: true 
  visible:
    - user: xxxx
    - user: yyyy  
  cards:
    - type: custom:layout-card
      layout_type: vertical
      layout:
        width: 300
        max_cols: 2
      cards:        
        - type: custom:state-switch
          entity: sensor.priority
          states:
            0:
              type: custom:stack-in-card
              mode: vertical
              cards:
                - type: entities
                  entities: 
                    - entity: sensor.sensor 
                    ....
ASNNetworks commented 2 years ago

Duplicate ticket, already reported: https://github.com/thomasloven/lovelace-state-switch/issues/63

Spirituss commented 2 years ago

It is not. I don’t see “blank spaces”, there is no any stuff on the screen.

itsadamslife commented 2 years ago

I have the same issue inside custom:grid-layout. I can get it to work by manually typing in the #state in the URL, but only if I first use the state that is not assigned as default.

type: custom:grid-layout
path: home
layout:
  #default
  grid-gap: var(--custom-layout-card-padding)
  grid-template-columns: repeat(4, 1fr) 0
  grid-template-rows: 0 repeat(2, fit-content(100%)) 0
  grid-template-areas: |
    "sidebar  .         .         .         ."
    "sidebar  entities  entities  entities  ."
    "sidebar_buttons  footer    footer    footer    ."
    ".        .         .         .         ."
  mediaquery:
    #phone
    "(max-width: 800px)":
      grid-gap: calc(var(--custom-layout-card-padding) * 1.7)
      grid-template-columns: 0 repeat(2, 1fr) 0
      grid-template-rows: 0 repeat(4, fit-content(100%)) 0
      grid-template-areas: |
        ".  .            .               ."
        ".  sidebar      sidebar         ."
        ".  entities     entities        ."
        ".  footer       footer          ."
        ".  sidebar_buttons sidebar_buttons ."
        ".  .            .               ."
    #portrait
    "(max-width: 1200px)":
      grid-gap: calc(var(--custom-layout-card-padding) * 2.4)
      grid-template-columns: repeat(3, 1fr) 0
      grid-template-rows: 0 repeat(2, fit-content(100%)) 0
      grid-template-areas: |
        "sidebar  .            .              ."
        "sidebar  entities     entities       ."
        "sidebar_buttons  footer       footer         ."
        ".        .            .              ."

cards:
  - !include sidebar.yaml

  - type: custom:state-switch
    entity: hash
    default: rooms
    view_layout:
      grid-area: entities
    states:
      rooms:
          type: vertical-stack
          cards:
            - a bunch of stuff
      devices:
          type: vertical-stack
          cards:
            - more stuff
       media:
           type: vertical-stack
           cards:
             - more stuff

  - !include footer.yaml

When selecting the dashboard in lovelace, nothing loads in the state-switch area. When adding #rooms to the URL, again nothing loads. When adding #devices to the URL, the devices will load. From there, I can then select the button created for #rooms and #media and those entities will load. I have also tested this by changing the default: state, which confirmed that the default will not load, even when initially manually putting the # in the URL.

Spirituss commented 2 years ago

Seems to be the general issue. I use state-switch on many places in lovelace and all of them don't show anything.

Spirituss commented 2 years ago

@thomasloven Could you advice any fix of the issue, since states: <value>: condition doesn't works anymore.

Spirituss commented 2 years ago

Similar issue is here https://github.com/thomasloven/lovelace-state-switch/issues/63#issuecomment-1046300332

Spirituss commented 2 years ago

Any news here?

Spirituss commented 2 years ago

@thomasloven It works again after the last update. Thanks!