thomasloven / lovelace-state-switch

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

State Switch Freezing my Browser (Possible bug) #94

Open DEADSEC-SECURITY opened 1 year ago

DEADSEC-SECURITY commented 1 year ago

Hey guys so I think I found a bug, not sure how to debug this since my browsers keeps freezing trying to load the dashboard but Ill try to explain as detailed as possible. So I'm trying to make a single dashboard with different things for mobile and desktop and this is the code I came up with but for some reason as soon as I introduce state-switch and I access the dashboard the browser freezes and after a couple seconds I get a notification asking if I would like to kill the tab or wait. It never loads so waiting is pointless.

Tested browser:

Tried in both using a Incognito tab so no cache and no cookies but still freezed.

HACS Version: 1.28.2 Frontend Version: 20220906112053 Plugin Version: 1.9.5 HA Version: 2022.10.1 Supervisor Version: 2022.10.0 OS Version: 8.1

Logs: (I'm not sure if these logs are related to the plugin but due to the time they happened might have something to do with it) Core: Seem to get a lot of the following but again I'm not 100% sure if its related: 2022-10-17 20:49:49.414 ERROR (MainThread) [homeassistant] Error doing job: Task was destroyed but it is pending!

My code:

type: custom:state-switch
entity: mediaquery
states:
  '(min-width: 800px)':
    type: horizontal-stack
    cards:
      - type: vertical-stack
        cards:
          - type: custom:button-card
            color_type: blank-card
          - type: custom:mushroom-chips-card
            chips:
              - type: menu
                icon: ''
              - type: weather
                entity: weather.home
              - type: entity
                entity: script.toti_wake_up
                icon: ''
                use_entity_picture: false
                content_info: name
                name: Wake Up
              - type: entity
                entity: script.toti_going_to_sleep
                content_info: name
                name: Sleep
              - type: light
                entity: light.toti_s_room
                use_light_color: true
            alignment: start
          - show_current: true
            show_forecast: false
            type: weather-forecast
            entity: weather.home
          - initial_view: dayGridMonth
            type: calendar
            entities:
              - calendar.amng835_gmail_com
              - calendar.meetings
              - calendar.work
              - calendar.school
      - type: vertical-stack
        cards:
          - type: vertical-stack
            cards:
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
          - type: custom:mushroom-title-card
            title: Room
          - type: custom:mini-media-player
            entity: media_player.spotify_tmg_macg
            artwork: cover
            scale: 1.3
            hide:
              volume: true
              source: true
              power_state: true
              power: true
            shortcuts:
              columns: 4
              buttons:
                - name: TT
                  type: playlist
                  id: spotify:playlist:1s56g7xwzPwqGEHTFyAIjh
                - name: NF
                  type: playlist
                  id: spotify:playlist:1All5I9pyXjJ2ArZt4zuCX
                - name: Badass
                  type: playlist
                  id: spotify:playlist:4UqRJvzsQ2YTeWAzT7L9V0
          - type: custom:mushroom-climate-card
            entity: climate.mc2_cloud_402933
            name: Electric Heater
          - type: horizontal-stack
            cards:
              - type: custom:mushroom-entity-card
                entity: sensor.toti_room_temp_humidity_sensor_temperature
                name: Temperature
              - type: custom:mushroom-entity-card
                entity: sensor.toti_room_temp_humidity_sensor_humidity
                name: Humidity
          - type: custom:mushroom-cover-card
            entity: cover.curtain
            fill_container: false
            show_position_control: true
            show_buttons_control: true
          - type: custom:mushroom-title-card
            title: Safety
          - type: horizontal-stack
            cards:
              - type: custom:mushroom-entity-card
                entity: sensor.toti_s_fume_extractor_temperature
                name: Fume Extractor Temperature
              - type: custom:mushroom-entity-card
                entity: switch.toti_s_desk_kill_switch
                icon: mdi:hazard-lights
                name: Desk Kill Switch
      - type: vertical-stack
        cards:
          - type: vertical-stack
            cards:
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
          - type: custom:mushroom-title-card
            title: Desk
          - type: horizontal-stack
            cards:
              - type: custom:mushroom-entity-card
                entity: switch.toti_s_upper_table_plug_1
                name: Table Plug 1
                icon: mdi:power-socket-eu
              - type: custom:mushroom-entity-card
                entity: switch.toti_s_upper_table_plug_2
                name: Table Plug 2
                icon: mdi:power-socket-eu
          - type: custom:mushroom-entity-card
            entity: switch.toti_s_fume_extractor
          - type: horizontal-stack
            cards:
              - type: custom:mushroom-entity-card
                entity: switch.toti_s_station
              - type: custom:mushroom-entity-card
                entity: switch.toti_s_soldering_station
          - type: horizontal-stack
            cards:
              - type: custom:mushroom-entity-card
                entity: switch.toti_s_smd_rework
              - type: custom:mushroom-entity-card
                entity: switch.toti_s_dc_station
          - type: vertical-stack
            cards:
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
              - type: custom:button-card
                color_type: blank-card
          - type: custom:mushroom-title-card
            title: Bathroom
          - type: horizontal-stack
            cards:
              - type: custom:mushroom-entity-card
                entity: sensor.toti_s_shower_water_temperature
                name: Shower Temperature
              - type: custom:mushroom-entity-card
                entity: switch.toti_s_electric_heater
                name: Electric Heater
  all:
    type: vertical-stack
    cards:
      - type: custom:mushroom-chips-card
        chips:
          - type: menu
            icon: ''
          - type: weather
            entity: weather.home
          - type: entity
            entity: script.toti_wake_up
            icon: ''
            use_entity_picture: false
            content_info: name
            name: Wake Up
          - type: entity
            entity: script.toti_going_to_sleep
            content_info: name
            name: Sleep
          - type: light
            entity: light.toti_s_room
            use_light_color: true
        alignment: start
      - show_current: true
        show_forecast: false
        type: weather-forecast
        entity: weather.home
      - type: horizontal-stack
        cards:
          - type: custom:mushroom-light-card
            entity: light.garage
            use_light_color: true
          - type: custom:mushroom-light-card
            entity: light.toti_s_room
            use_light_color: true
      - type: horizontal-stack
        cards:
          - type: custom:mushroom-entity-card
            entity: switch.pool_light_group
            icon: mdi:lightbulb-group
            name: Pool
            tap_action:
              action: toggle
          - type: custom:mushroom-entity-card
            entity: sensor.toti_s_shower_water_temperature
            name: Shower
            fill_container: false
      - type: custom:mushroom-cover-card
        entity: cover.main_garage_gate
        show_buttons_control: true
        show_position_control: false
        tap_action:
          action: none
      - type: picture-glance
        title: Garage
        camera_image: camera.garage_high
        camera_view: auto
        entities:
          - entity: cover.main_garage_gate
hitnrun30 commented 1 year ago

Yeah what is up with this. I like that it will make it easier for mobile to desktop but I am frozen.

DEADSEC-SECURITY commented 1 year ago

I think this is a bug. Possibly the javascript that parses the YAML is not optimized for long YAMLS?

hitnrun30 commented 1 year ago

Shame it is a real good card

DEADSEC-SECURITY commented 1 year ago

When i have more time I might try to debug it but currently too busy to work on this. @hitnrun30