dnguyen800 / air-visual-card

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

Unavailable sensor inside card crashes whole view #15

Closed jacekpaszkowski closed 4 years ago

jacekpaszkowski commented 4 years ago

Hi,

I've noticed that if any of sensors configured in air-visual-card is unavailable (does not exist in HA registry) whole view crashes - becomes blank.

this is my sample config:

- air_pollution_level: sensor.u_s_air_pollution_level
   air_quality_index: sensor.u_s_air_quality_index
   city: Warszawa
   hide_title: true
   main_pollutant: sensor.u_s_main_pollutant
   temp: weather.dark_sky
   type: 'custom:air-visual-card'

when the problem occours there is an exception in browser console

Uncaught TypeError: Cannot read property 'attributes' of undefined
    at HTMLElement.set hass [as hass] (air-visual-card.js:235)
    at HTMLElement._createCardElement (hui-stack-card.ts:79)
    at HTMLElement._rebuildCard (hui-stack-card.ts:96)
    at HTMLElement.t.addEventListener.once (hui-stack-card.ts:85)
    at r (fire_event.ts:76)
    at create-card-element.ts:111
dnguyen800 commented 4 years ago

i'll look into it, hopefully this weekend.

dnguyen800 commented 4 years ago

i just released a new version, can you see if the issue is still present?

jacekpaszkowski commented 4 years ago

Hi, thank you, now it's ok. View works, and visual card just displays "0".