PiotrMachowski / Home-Assistant-Lovelace-Local-Conditional-card

This card can show and hide a specific card on current device while not affecting other windows. It does not require any integration to run.
MIT License
61 stars 6 forks source link

Doesn't work with popup-card #20

Closed AINER closed 1 year ago

AINER commented 1 year ago

I found compatibility issue with custom component popup-card: https://github.com/thomasloven/hass-browser_mod When pop up is open,, tap action doesn't work for card which in the pop up.

PiotrMachowski commented 1 year ago

Can you show your config?

AINER commented 1 year ago

I wanted to make a simplified config for you with main Home Assistant cards. But I found that the addon works correctly with them. However, my idea cannot be realized on the cards from the Mushroom cards add-on.

I made config with two examples of my use case. The second one (cards above second markdown card) is the closest representation of what I want to achieve. But tap action of mushroom cards doesn't work in popup.

views:
  - title: Home
    cards:
      - type: markdown
        content: |-
          Thats works OK in main dashboard view and in pop up

          Tap weather card to switch, hold to open pop up
        title: 1. Standart cards of HA
      - type: custom:local-conditional-card
        id: lc-time
        default: hide
        card:
          type: entity
          entity: sensor.time
      - type: custom:local-conditional-card
        id: lc-date
        default: show
        card:
          type: entity
          entity: sensor.date
      - show_current: true
        show_forecast: false
        type: weather-forecast
        entity: weather.forecast_home_assistant
        tap_action:
          action: fire-dom-event
          local_conditional_card:
            action: toggle
            ids:
              - lc-time
              - lc-date
        hold_action:
          action: more-info
        name: Tap to switch, hold to open pop up
      - type: custom:popup-card
        entity: weather.forecast_home_assistant
        dismissable: true
        title: Pop up
        card:
          type: grid
          square: false
          columns: 1
          cards:
            - type: custom:local-conditional-card
              id: lc-time
              default: hide
              card:
                type: entity
                entity: sensor.time
            - type: custom:local-conditional-card
              id: lc-date
              default: show
              card:
                type: entity
                entity: sensor.date
            - show_current: true
              show_forecast: false
              type: weather-forecast
              entity: weather.forecast_home_assistant
              tap_action:
                action: fire-dom-event
                local_conditional_card:
                  action: toggle
                  ids:
                    - lc-time
                    - lc-date
              name: Tap to switch
      - type: markdown
        content: >-
          I was trying to create a dynamic button with Mushroom cards using your
          addon. This works in the main dashboard, but doesn't work in the
          popup.

          Tap Chips card to switch.

          Tap Date & Time card to open pop up.
        title: 2. Custom Mushroom cards (chips)
      - type: horizontal-stack
        cards:
          - type: custom:local-conditional-card
            id: kabinet_media_filter_disabled
            default: show
            card:
              type: custom:mushroom-chips-card
              alignment: end
              chips:
                - type: template
                  content: text
                  icon: mdi:motion-play-outline
                  icon_color: cyan
                  use_entity_picture: false
                  tap_action:
                    action: fire-dom-event
                    local_conditional_card:
                      action: set
                      ids:
                        - kabinet_media_filter_disabled: hide
                        - kabinet_media_filter_enabled: show
          - type: custom:local-conditional-card
            id: kabinet_media_filter_enabled
            default: hide
            card:
              type: custom:mushroom-chips-card
              alignment: end
              id: kabinet_media_filter_enabled
              default: hide
              chips:
                - type: template
                  icon: mdi:close
                  tap_action:
                    action: fire-dom-event
                    local_conditional_card:
                      action: set
                      ids:
                        - kabinet_media_filter_disabled: show
                        - kabinet_media_filter_enabled: hide
                - type: template
                  content: text
                  icon: mdi:motion-play-outline
                  icon_color: cyan
                  use_entity_picture: false
                  tap_action:
                    action: fire-dom-event
                    local_conditional_card:
                      action: set
                      ids:
                        - kabinet_media_filter_disabled: show
                        - kabinet_media_filter_enabled: hide
      - type: entity
        entity: sensor.date_time
        name: Tap to open pop up
      - type: custom:popup-card
        entity: sensor.date_time
        title: Custom popup
        dismissable: true
        card:
          type: horizontal-stack
          cards:
            - type: custom:local-conditional-card
              id: kabinet_media_filter_disabled
              default: show
              card:
                type: custom:mushroom-chips-card
                alignment: end
                chips:
                  - type: template
                    content: text
                    icon: mdi:motion-play-outline
                    icon_color: cyan
                    use_entity_picture: false
                    tap_action:
                      action: fire-dom-event
                      local_conditional_card:
                        action: set
                        ids:
                          - kabinet_media_filter_disabled: hide
                          - kabinet_media_filter_enabled: show
            - type: custom:local-conditional-card
              id: kabinet_media_filter_enabled
              default: hide
              card:
                type: custom:mushroom-chips-card
                alignment: end
                id: kabinet_media_filter_enabled
                default: hide
                chips:
                  - type: template
                    icon: mdi:close
                    tap_action:
                      action: fire-dom-event
                      local_conditional_card:
                        action: set
                        ids:
                          - kabinet_media_filter_disabled: show
                          - kabinet_media_filter_enabled: hide
                  - type: template
                    content: text
                    icon: mdi:motion-play-outline
                    icon_color: cyan
                    use_entity_picture: false
                    tap_action:
                      action: fire-dom-event
                      local_conditional_card:
                        action: set
                        ids:
                          - kabinet_media_filter_disabled: show
                          - kabinet_media_filter_enabled: hide
PiotrMachowski commented 1 year ago

Thank you for your in-depth investigation!

It looks like the problem is on the side of the mushroom card: it seems to use fire-dom-event in a different way compared to standard lovelace cards.

You can check it by opening browser's console, entering the following code:

window.addEventListener('ll-custom', (e) => console.log(e));

and performing some actions that should trigger fire-dom-event. If the event is triggered correctly the message should be displayed in the console.

AINER commented 1 year ago

The problem is caused by the incompatibility of the browser-mod and hass-action from new HA update. But I found and started using your add-on just after the update and did not see any problems in the browser mod.

Sorry for wasting your time and thanks for feedback and the great addon! 😉