home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.13k stars 29.18k forks source link

AirVisual: Error while setting up airvisual platform for sensor #36115

Closed petarvucetin closed 4 years ago

petarvucetin commented 4 years ago

The problem

Integration worked for a little while and than all sensors are gone. After restarting HA getting below error.

Environment

Problem-relevant configuration.yaml

Traceback/Error logs

2020-05-24 22:47:31 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up airvisual platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 295, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 444, in _async_add_entity
    await entity.async_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/airvisual/__init__.py", line 371, in async_added_to_hass
    self.update_from_latest_data()
  File "/usr/src/homeassistant/homeassistant/components/airvisual/sensor.py", line 166, in update_from_latest_data
    data = self.coordinator.data["current"]["pollution"]
TypeError: 'NoneType' object is not subscriptable
2020-05-24 22:47:32 ERROR (MainThread) [homeassistant.components.sensor] airvisual: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 322, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/airvisual/__init__.py", line 378, in async_update
    await self.coordinator.async_request_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 118, in async_request_refresh
    await self._debounced_refresh.async_call()
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 60, in async_call
    await self.hass.async_add_job(self.function)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 177, in async_refresh
    update_callback()
  File "/usr/src/homeassistant/homeassistant/components/airvisual/__init__.py", line 366, in update
    self.update_from_latest_data()
  File "/usr/src/homeassistant/homeassistant/components/airvisual/sensor.py", line 166, in update_from_latest_data
    data = self.coordinator.data["current"]["pollution"]
TypeError: 'NoneType' object is not subscriptable

Additional information

probot-home-assistant[bot] commented 4 years ago

airvisual documentation airvisual source (message by IssueLinks)

probot-home-assistant[bot] commented 4 years ago

Hey there @bachya, mind taking a look at this issue as its been labeled with a integration (airvisual) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

bachya commented 4 years ago

I’ll need more information (latitude/longitude and API key) to debug since I’m unable to reproduce this. You can reach out to me on the Home Assisstant Discord (where I have the same username).

bachya commented 4 years ago

From @petarvucetin:

I am not sure what is going on. It started working again. The error is gone from the logs and the air-visual-card is working too and I can see the sensors. I have installed development env for hass and it works there too. Go figure...

Closing this issue for now; feel free to re-open if it happens again!

petarvucetin commented 4 years ago

I just saw it again on the dev install. After I get limit reached and restarted HA I get this:

020-05-26 04:31:37 INFO (MainThread) [homeassistant.setup] Setup of domain notify took 0.0 seconds.
2020-05-26 04:31:37 INFO (MainThread) [homeassistant.components.notify] Setting up notify.mobile_app
2020-05-26 04:31:37 ERROR (MainThread) [homeassistant.components.airvisual] Error fetching geography data data: Error while retrieving data: call_per_day_limit_reached
2020-05-26 04:31:37 DEBUG (MainThread) [homeassistant.components.airvisual] Finished fetching geography data data in 1.060 seconds
2020-05-26 04:31:37 INFO (SyncWorker_3) [homeassistant.loader] Loaded air_quality from homeassistant.components.air_quality
2020-05-26 04:31:37 INFO (SyncWorker_6) [homeassistant.loader] Loaded sensor from homeassistant.components.sensor
2020-05-26 04:31:37 INFO (MainThread) [homeassistant.setup] Setting up air_quality
2020-05-26 04:31:37 INFO (MainThread) [homeassistant.setup] Setup of domain air_quality took 0.0 seconds.
2020-05-26 04:31:37 INFO (MainThread) [homeassistant.setup] Setting up sensor
2020-05-26 04:31:37 INFO (MainThread) [homeassistant.setup] Setup of domain sensor took 0.0 seconds.
2020-05-26 04:31:37 INFO (MainThread) [homeassistant.components.air_quality] Setting up air_quality.airvisual
2020-05-26 04:31:37 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.airvisual
2020-05-26 04:31:37 INFO (MainThread) [homeassistant.components.updater] Submitted analytics to Home Assistant servers. Information submitted includes {}
2020-05-26 04:31:38 INFO (MainThread) [homeassistant.setup] Setup of domain updater took 2.2 seconds.
2020-05-26 04:31:38 INFO (SyncWorker_5) [homeassistant.loader] Loaded binary_sensor from homeassistant.components.binary_sensor
2020-05-26 04:31:38 INFO (MainThread) [homeassistant.setup] Setting up default_config
2020-05-26 04:31:38 INFO (MainThread) [homeassistant.setup] Setup of domain default_config took 0.0 seconds.
2020-05-26 04:31:38 INFO (MainThread) [homeassistant.setup] Setting up binary_sensor
2020-05-26 04:31:38 INFO (MainThread) [homeassistant.setup] Setup of domain binary_sensor took 0.0 seconds.
2020-05-26 04:31:38 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up airvisual platform for sensor
Traceback (most recent call last):
  File "/workspaces/home-assistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/workspaces/home-assistant/homeassistant/helpers/entity_platform.py", line 295, in async_add_entities
    await asyncio.gather(*tasks)
  File "/workspaces/home-assistant/homeassistant/helpers/entity_platform.py", line 444, in _async_add_entity
    await entity.async_added_to_hass()
  File "/workspaces/home-assistant/homeassistant/components/airvisual/__init__.py", line 371, in async_added_to_hass
    self.update_from_latest_data()
  File "/workspaces/home-assistant/homeassistant/components/airvisual/sensor.py", line 166, in update_from_latest_data
    data = self.coordinator.data["current"]["pollution"]
TypeError: 'NoneType' object is not subscriptable
2020-05-26 04:31:38 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.updater
2020-05-26 04:31:38 INFO (SyncWorker_7) [homeassistant.loader] Loaded google_translate from homeassistant.components.google_translate
2020-05-26 04:31:38 INFO (MainThread) [homeassistant.setup] Setting up tts
2020-05-26 04:31:38 DEBUG (MainThread) [homeassistant.components.airvisual] Finished fetching geography data data in 0.144 seconds
2020-05-26 04:31:38 ERROR (MainThread) [homeassistant.components.sensor] airvisual: Error on device update!
Traceback (most recent call last):
  File "/workspaces/home-assistant/homeassistant/helpers/entity_platform.py", line 322, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/workspaces/home-assistant/homeassistant/helpers/entity.py", line 470, in async_device_update
    await self.async_update()
  File "/workspaces/home-assistant/homeassistant/components/airvisual/__init__.py", line 378, in async_update
    await self.coordinator.async_request_refresh()
  File "/workspaces/home-assistant/homeassistant/helpers/update_coordinator.py", line 118, in async_request_refresh
    await self._debounced_refresh.async_call()
  File "/workspaces/home-assistant/homeassistant/helpers/debounce.py", line 60, in async_call
    await self.hass.async_add_job(self.function)  # type: ignore
  File "/workspaces/home-assistant/homeassistant/helpers/update_coordinator.py", line 177, in async_refresh
    update_callback()
  File "/workspaces/home-assistant/homeassistant/components/airvisual/__init__.py", line 366, in update
    self.update_from_latest_data()
  File "/workspaces/home-assistant/homeassistant/components/airvisual/sensor.py", line 166, in update_from_latest_data
    data = self.coordinator.data["current"]["pollution"]
TypeError: 'NoneType' object is not subscriptable
2020-05-26 04:31:38 INFO (MainThread) [homeassistant.setup] Setup of domain tts took 0.0 seconds.
2020-05-26 04:31:42 INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in 13.30s
2020-05-26 04:31:42 INFO (MainThread) [homeassistant.core] Starting Home Assistant
2020-05-26 04:31:42 INFO (MainThread) [homeassistant.core] Timer:starting

I am trying to chase it down on my local dev install.

bachya commented 4 years ago

I still cannot reproduce this. 😕

Warter21 commented 4 years ago

If you have an air visual card it happens after 4-8 hours when you reached the api daily limits.

bachya commented 4 years ago

Based on @Warter21's comment, I'm thinking this is actually a manifestation of https://github.com/home-assistant/core/issues/34787; going to close this issue and we can continue the conversation over there.