aex351 / home-assistant-neerslag-card

Display Buienalarm and/or Buienradar data in a graph for Home Assistant.
29 stars 3 forks source link

Can't get it working with Home Assistant Cast #29

Closed rubenni closed 2 years ago

rubenni commented 2 years ago

Hello! Thank you for this good-looking card! But as the title states, I got a little issue with it. I can't get it working using Home Assistant Cast on my Nest Hub 2. Looking at the FAQ of Home Assistant Cast, it states that the most common mistake is that the LitElement is extracted from an element that is not available on the page. I got a lot of other custom cards working on the Nest Hub like the custom button card. So I guess it should be possible.

Would someone mind taking a look? If someone needs help with testing, you can contact me!

Regards!

aex351 commented 2 years ago

Home Assistant does not provide a mechanism for custom integrations to use the already present Lit-element package. This means custom integrations have 2 options. 1) Embed the Lit-Element package within the custom integration (massive overhead) or load the Lit-element package from an external URL (massive overhead and requires internet connectivity) or 2) Use the already present Lit-element that is bundled and used within Home Assistant. This is formally not supported by Home Assistant, because of how things are loaded internally and that they probably don't want to maintain such dependencies.

The Neerslag Card uses option 2. It uses the Lit-element package that is bundled with Home Assistant. This option will only work if certain official Home Assistant elements are being rendered on your screen.

It seems the Home Assistant Cast integration is not loading the required elements or these elements are not accessible by the Neerslag Card. I will need to do a bit of research to see if option 2 can be continued. Otherwise the Neerslag Card needs to switch to option 1. This will increase the overhead, however at the same time it will make the Neerslag Card more robust as it isn't depended on Home Assistant anymore for Lit-element.

rubenni commented 2 years ago

Thank you for the quick reply and extensive explanation! If you got a beta version or think it's fixed (or know a way to fix the issue), I'm here to try it out and test it. Due to a lack of time atm, I won't be able to check out the code myself...

aex351 commented 2 years ago

LitElement is now being imported from a CDN (unpkg.com). This should resolve the issue with Home Assistant Cast as there is no longer a dependency on internal Home Assistant components. This is also one of the recommended methods in the developer document of Home Assistant for using LitElement.

rubenni commented 2 years ago

LitElement is now being imported from a CDN (unpkg.com). This should resolve the issue with Home Assistant Cast as there is no longer a dependency on internal Home Assistant components. This is also one of the recommended methods in the developer document of Home Assistant for using LitElement.

Yes, I just tested it and the issue is resolved. Thank you!