thomasloven / hass-browser_mod

🔹 A Home Assistant integration to turn your browser into a controllable entity and media player
MIT License
1.31k stars 187 forks source link

Popup Card is no longer working #719

Closed shwarnock closed 2 months ago

shwarnock commented 3 months ago

My Home Assistant version: 0.XX.X

What I am doing: I am using popup cards within browser_mod to open up remotes for my tvs when the entity for the remote is pressed. This was working fine for several months until today.

What I expected to happen: Clicking my remote entity opens the popup with my built remote control

What happened instead: The more info dialog for the entity is opened

Minimal steps to reproduce:

  1. Create a popup card
  2. Populate the popup card with a custom lovelace card
  3. Link this to any entity
  4. Click the entity
type: custom:popup-card
entity: remote.millennium_falcon
dismissable: true
card:
  type: custom:android-tv-card
  remote_id: remote.millennium_falcon
  slider_id: media_player.millennium_falcon
  media_player_id: media_player.millennium_falcon
  keyboard_id: media_player.android_tv_192_168_86_54
  rows:
    - - power
      - search
      - home
    - - emby
      - youtube
      - keyboard
    - - back
      - volume_down
      - volume_up
    - - touchpad
title: Millennium Falcon Remote

By replacing the space in the checkboxes ([ ]) with an X below, I indicate that I:

IgorSimic commented 3 months ago

I can confirm, it was stop working in version 2024.7

My simple example:

type: custom:popup-card
entity: sensor.sjenica_temperature
card:
  type: entities
  entities:
    - sensor.feels_like_sjenica
    - sensor.feels_like_sjenica_sonoff

Instead poping up this entities card on click, generic more info popup appeared.

miberecz commented 3 months ago

Came here to say the same. I just installed the addon via HACS, followed the instructions to clear the browser cache (but tried in incognito and different browser also), registered my browser(s), created the invisible pop card for an entity, but still the more info dialog opens no mater what.

type: custom:popup-card
entity: fan.toronyventillator
title: Custom popup
dismissable: true
card:
  type: markdown
  content: This replaces the more-info dialog
size: normal
rickbhs commented 3 months ago

same here

JacobDB commented 3 months ago

Glad it's not just me!

IgorSimic commented 3 months ago

Problem comes with Frontend 20240705.0 On one on my rarely used computers popups worked as allways until I become message about new frontend version and reloaded.

AndiRued commented 3 months ago

Since everything didn't work, I deleted browser_mod completely and now use bubble-cards for popups. Looks better and offers more possibilities 😬

JacobDB commented 3 months ago

I also set up a new dashboard with Bubble Cards, but I still have use for this feature; it's nice being able to override the more info box for specific entities

IgorSimic commented 3 months ago

Hi all, I want to share my finding. Despite problem with more-info popup in frontend 20240705.0, this is still working if is enclosed in bootstrap-grid-card. This means, if whatever entities in whatever cards and custom:popup-card(s) for those entities enclosed in same bootstrap-grid-card. bootstrap-grid-card This is not solution, but for me is life saver, because my dashboards heavily depends on custom more-info popups.

VDRainer commented 3 months ago

I want to share my finding

Thanks for sharing! I was wondering why some popups still work since 2024.7.x. I found that the more-info popups also work if they are enclosed in a View layout card

Be carefull with the layout syntax. https://github.com/thomasloven/lovelace-layout-card/issues/288#issuecomment-2143824572

Sxyman815 commented 3 months ago

same for me. 2024.7 and 2024.7.1 both dont work and my code hasn't changed... thought i was crazy and rolled the whole house back to 2024.6 via restore and everything was fine. then i updated and problem is back. everyonce in awhile i can get it to come up but when you exit it it seems to be gone for good.

i was wondering if it is tied to the addition of visability ????as that came with 2024.7 and would be....could be messing with it. image

Lucif3r945 commented 3 months ago

I want to share my finding

Thanks for sharing! I was wondering why some popups still work since 2024.7.x. I found that the more-info popups also work if they are enclosed in a View layout card

Be carefull with the layout syntax. thomasloven/lovelace-layout-card#288 (comment)

brooo....... That effing works wonders! I already use layout card so wrapping the popups in one took 2sec for me. You dont even need to set up areas/layout etc, you can just add a layout-card -> go directly to cards -> add popup card and done. The preview of the popup card is still broken though, but it works!

so basically just...

type: custom:layout-card
layout_type: masonry
layout: {}
cards:
  - type: custom:popup-card
  - etc etc
Spegeli commented 3 months ago

the layout-card is a work-around (until we find a fix for the popup card self) but it adds an empty space in the dashboard. Where the 2 red squares there are the 2 layout-cards. but better then no popup function currently ^^

Unbenannt

//Edit: OK with the Layout Card i grouped now all Pop-up cards into one single Layout card and simply moved it to the bottom as Last Card in the Dashboard. Problem with empty space betweens cards solved.

brandensilva commented 2 months ago

Same issue here. I'm using the latest layout changes in 2024.7.x which I assume is part of the issue.

Honestly wish HA would just support a native solution for this given people want to have more control over their interfaces.

AgentP38 commented 2 months ago

same for me

keeema commented 2 months ago

...and me

jouster1974 commented 2 months ago

also come to report that in 2024.7.0, 1 and 2, browser mod seems to have disappeared with zero changed my end, winding back to 2024.6.* resolves the issue instantly

AlenHodnik commented 2 months ago

Dead for me too ...

StKais commented 2 months ago

Same Here - since the update, nothing works anymore

liorpapir commented 2 months ago

I'm having the same issue

jdgiddings commented 2 months ago

Same issue here

oxymoron1629 commented 2 months ago

I'm just piling on, I'm having the same issue.

sanderabbink commented 2 months ago

@thomasloven Could you look into this problem and fix it? Since the last update, the popups no longer work via the "more info" way.

sebastian-bartkowiak commented 2 months ago

OK, I poked around to find the cause of the issue.

The core issue for me seems to be located in file js/plugin/popup-card.ts There you can find two functions - connectedCallback & disconnectedCallback - their primary goal is to attach event listener to window instance listening for hass-more-info events being fired by the DOM. Now, the issue is - the event listeners are attached in connectedCallback properly, but immediately after that they are being detached by disconnectedCallback called from HA itself. It seems to me that disconnectedCallback is called because of newly added functionality on HA side, which is "visibility". The code checking whether a card is visible or not looks at "popup" card and desides that it is, in fact, not visible (which is frankly true), and because of that it disconnects it from the rest of the frontend. Furthermore, when you try to edit "popup" card via GUI you will notice that it's preview is not rendered at all. I suspect that the nature of this card (normally hidden, and only shown programmatically in specified conditions) just does not go along with how "visibility" was implemented on HA side. Quick dirty fix I can think of is just removing window.removeEventListener("hass-more-info", this.popup); line, but I am sure that will have some further implications down the line.

Full disclaimer - I have no experience with HA frontend coding, so I might get something of it wrong :)

sebastian-bartkowiak commented 2 months ago

The part responsible for calling disconnectedCallback in HA frontend repo is over here - src/panels/lovelace/cards/hui-card.ts - line 219, function _updateVisibility, which as far as I can tell desides that "popup" card is not visible, so it desides to call _setElementVisibility function, which in turn calls removeChild on popup card itself.

I can see that _updateVisibility function optionally takes forceVisible boolean parameter, which looks promising for our use-case, but I am not (yet) sure how and where from is it being passed.

sebastian-bartkowiak commented 2 months ago

OK, so I have successfully got rid of the issue by commenting out two lines in js/plugin/popup-card.ts file - this.removeAttribute("hidden"); and this.setAttribute("hidden", "");.

My understanding is - this parameter hides LitElement from the view, which (just recently) started to be respected by HA frontend (with "visibility" tab). The thing is - popup element is either way being displayed differently (with window.browser_mod?.service("popup", ...) method), so we don't really have to tell HA frontend whether popup element is displayed or not.

As far as I can tell there are no side effects of this, but then again - I have zero experience with HA frontend, so I might overlook some things.

redford-jones commented 2 months ago

Yes, can confirm the above fix from @sebastian-bartkowiak works for me too.

Lucif3r945 commented 2 months ago

Aight... I'll have to make a fool out of myself.... Where is that file located on the HA server? Or is it compiled into something when browser_mod is installed...?

anipad commented 2 months ago

Aight... I'll have to make a fool out of myself.... Where is that file located on the HA server? Or is it compiled into something when browser_mod is installed...?

I will out myself too ;)

sebastian-bartkowiak commented 2 months ago

Yea, so actually it's not that simple to fix it by yourself. The distributed file is transpiled and bundled together with the rest of TS files. As far as I can see there are three options:

Lucif3r945 commented 2 months ago

Weird, file changed and saved properly, cache cleared, can't find any *gz file associated with BM - across the entire system, and the fix/change seems to have changed nothing functionality-wise.

Ah well, I'm fine using the layout-card bodgefix, lets hope option 3 happens soon :>

Thanks for taking the time of typing all that down though! I have a bit better understanding on how this whole file library thingy works now.

mellamomax commented 2 months ago

I´ve made a fork that fixes this issue until/if we ever get an actual update. https://github.com/mellamomax/hass-browser_modpop/

This is a combined fork of:

_NOTE: Pop-up cards still show as blank in edit mode__

Steps to implement:

  1. Remove the original Browser_mod in HACS by clicking "ignore".
  2. Then delete it under "devices & services"
  3. Restart HA
  4. Install the fork as a custom repo within HACS
  5. Restart HA
  6. Add "Browser_mod" under "devices & services" as usual
  7. EDIT: refresh cache on mobile

Done! It should work immediately.