Airvisual - unable to get it working

Hi Guys,

When trying to get the Airvisual component working I get the following errors…

2017-09-10 14:49:37 ERROR (MainThread) [homeassistant.components.sensor.airvisual] Unable to update sensor data
2017-09-10 14:49:37 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/sensor/airvisual.py”, line 252, in async_update
symbol = self._data.pollution_info.get(‘main{0}’.format(self._locale))
AttributeError: ‘NoneType’ object has no attribute ‘get’
2017-09-10 14:49:37 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/sensor/airvisual.py”, line 226, in async_update
self._state = self._data.pollution_info.get(
AttributeError: ‘NoneType’ object has no attribute ‘get’
2017-09-10 14:49:37 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/sensor/airvisual.py”, line 202, in async_update
aqi = self._data.pollution_info.get(‘aqi{0}’.format(self._locale))
AttributeError: ‘NoneType’ object has no attribute ‘get’

My configuration is as follows…

- platform: airvisual
  api_key: !secret airvisual_api_key
  monitored_conditions:
    - us
  latitude: xxx
  longitude: xxx
  radius: 1000

Any ideas what I’m doing wrong?

I am getting the same. Keep increasing the radius but still get the error.

Mine works fine without the coordinates and radius. Haven’t tried with them

Just tried taking them out and it made no difference :frowning:

Also not working for me, have tried with no lat, long and radius and also with then explicitly configured, same error as above from memory.

Weird not sure why it works for me!

Hi there - platform author here. Would you be willing to message me your latitude and longitude so I can debug further?

Hi all – in talking with @cdp181, it looks like the AirVisual API isn’t returning the nearest city for some coordinates (for some reason). Per this thread, I’m going to add a feature that’ll allow for a HASS configuration in which city/region/country is explicitly specified; I’ll also document how you can look for a city near you with valid air data.

FYI, PR has been submitted: https://github.com/home-assistant/home-assistant/pull/9436

Hi Bachya,

Since upgrading HA to 53.1 it’s now working :smiley:

1 Like

Great! Whenever you are browsing the docs, make sure to check out the sidebar: that will always show you the minimum version you need for that particular component/platform.

Yep but it should have worked for 53.0 I don’t see any changes that would have affected it in 53.1 I just did the update as it may fix other things, that I’m having an issue with.

Hi all – 0.54.0 (released today) has this update.

Thanks for the update @bachya!

But now the AQI is shown as PSI. For me it now looks like: U.S. Air Quality Index 73 PSI

Same for Chinese 36 PSI

That is the Pollutant Standard Index (PSI) and it was introduced by design: without a unit, the sensor’s history data would display a quite-useless stacked bar graph, rather than the much-more-useful line graph.

The state is still numeric, however:

…so, if you don’t want to see “PSI”, you can always create your own template sensor.

OK, I understand, thanks for the great work on this :smiley:

1 Like