dnguyen800 / air-visual-card

A Lovelace card showing air quality data from airvisual.com. Requires the AirVisual component.
MIT License
100 stars 35 forks source link

No other cards are visible after I added this card #55

Closed digidestination closed 2 years ago

digidestination commented 2 years ago

After I added this card, this and all other cards disappear.

Swampen commented 2 years ago

Can you add your card configuration and any errors in the dev console (F12)

jaruba commented 2 years ago

@Swampen it's likely that me and @digidestination have the same issue

i recently updated ha and all the extensions including this one, under Overview -> Home i can see all the cards when i refresh the page, but while browsing around ha, the next time i get to Overview there are no cards at all..

dev tools shows this as the only error in lovelance:

air-visual-card.js?hacstag=157674859200:426 Uncaught TypeError: Cannot read properties of undefined (reading 'attributes')
    at HTMLElement.set hass [as hass] (air-visual-card.js?hacstag=157674859209:426)
    at HTMLElement.value (hui-masonry-view.ts:44)
    at HTMLElement.value (hui-masonry-view.ts:44)
    at HTMLElement.t.addEventListener.once (hui-masonry-view.ts:44)
    at i (typography.js:181)
    at ha-logbook.ts:28

which points to this line: https://github.com/dnguyen800/air-visual-card/blob/master/dist/air-visual-card.js#L426

and my card's config is:

type: custom:vertical-stack-in-card
title: Air Quality
cards:
  - type: custom:air-visual-card
    air_pollution_level: sensor.u_s_air_pollution_level_2
    air_quality_index: sensor.u_s_air_quality_index_2
    main_pollutant: sensor.u_s_main_pollutant_2
    city: Bucharest
    hide_title: true
    hide_weather: true

this error makes no sense to me though, as i don't set the weather property: https://github.com/dnguyen800/air-visual-card/blob/master/dist/air-visual-card.js#L256

which means that weatherEntity should be '', so this should be falsey: https://github.com/dnguyen800/air-visual-card/blob/master/dist/air-visual-card.js#L425

and thus the code should never reach the 426th line which is where the error is from

jaruba commented 2 years ago

@Swampen huh, i logged weatherEntity at the 426th line, and it's showing weather.home.. but I have no such entity.. and i never set weather in the card config or configuration.yaml...

jaruba commented 2 years ago

a few more tests i did:

jaruba commented 2 years ago

@Swampen I created a PR for this: https://github.com/dnguyen800/air-visual-card/pull/56

Swampen commented 2 years ago

@jaruba Great! You found a solution. I think maybe this line also might be causing some problems. https://github.com/dnguyen800/air-visual-card/blob/master/dist/air-visual-card-editor.js#L64 Did you by any chance configure it with the GUI?

I don't have contributer rights to this repo, so I can't do anything with your PR. @dnguyen800 needs to take a look at it.

dnguyen800 commented 2 years ago

i'll update it today. Thanks for finding and fixing the issue!

jaruba commented 2 years ago

@dnguyen800 thanks! works great now

@Swampen yeah, i used the GUI to add the card and configure it, that default value shouldn't be used though.. weather.home is only available for those that never changed their HA's home name, as the weather entity name changes according to the HA home name. (ex: if i set the home name to "My Home", the weather entity becomes weather.my_home)