Pollen Component - Error while setting up platform pollen

So I decided to try and setup the pollen component. Seems easy and straight forward, but it’s not working for me and throwing some errors.

Here is my setup under “sensor”
- platform: pollen
zip_code: 04XXX
monitored_conditions:
- allergy_index_today
- allergy_index_tomorrow
- disease_average_forecasted

I have masked the last 3 digits of my zip code.

I get errors in the Information panel that looks like this:
Error while setting up platform pollen
12:48 PM components/sensor/pollen.py (ERROR)
An error occurred while retrieving data
12:48 PM components/sensor/pollen.py (ERROR)

Also looking at the log I see the following:
Configuration data: OrderedDict([(‘platform’, ‘pollen’), (‘zip_code’, 2115), (‘monitored_conditions’, [‘allergy_index_today’, ‘allergy_index_tomorrow’, ‘disease_average_forecasted’])])

Look at the zip_code … 2115 is not my zip.

So I decided to change my configuration to include single quotes around my zip code,
it looked like this: zip_code: "04XXX’

The error above shoed:
Configuration data: OrderedDict([(‘platform’, ‘pollen’), (‘zip_code’, 4XXX), (‘monitored_conditions’, [‘allergy_index_today’, ‘allergy_index_tomorrow’, ‘disease_average_forecasted’])])

It seems like it was dropping the “0” that starts my zip code.

Anyone else having issues?
Do you have your zip in quotes or not in your config file?

Thanks

I also have a zero as the first digit of my ZIP, and I also can’t get pollen to start correctly. When I used my work ZIP, which starts with a “1”, it seemed to be OK. Enclosing my ZIP in single quotes didn’t help.

- platform: pollen
  zip_code: 'zip code that starts with 0'
  monitored_conditions:
    - allergy_average_forecasted
    - allergy_average_historical
    - allergy_index_today
    - allergy_index_tomorrow
    - allergy_index_yesterday
    - disease_average_forecasted
Error while setting up platform pollen
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 84, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/pollen.py", line 134, in setup_platform
    data.update()
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 308, in wrapper
    result = method(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/pollen.py", line 302, in update
    self.extended_data = self._get_client_data('allergens', 'extended')
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/pollen.py", line 287, in _get_client_data
    return data
UnboundLocalError: local variable 'data' referenced before assignment

Looks like the issue may be sort of upstream in pypollencom.

I can’t create an instance of it’s client class with a zip code that starts with 0, unless I close it in single quotes and make it a string. Maybe HA should pass the zip code as a string rather than an int

Thanks for confirming that I am not the only one seeing this issue.
I wonder who’s attention we could get to take a look at this for future releases.

Should be fixed by this PR from the pypollencom dev: https://github.com/home-assistant/home-assistant/pull/12790

Great News !!! Thanks

Just installed the Pollen Componenet for the first time and am also experiencing this problem. Home Assistant is updated to 64.3 Tried 2 different zip codes neither start with 0.

2018-03-04 10:34:25 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform pollen
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 84, in async_setup
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.5/asyncio/tasks.py”, line 400, in wait_for
return fut.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/pollen.py”, line 134, in setup_platform
data.update()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/init.py”, line 308, in wrapper
result = method(*args, **kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/pollen.py”, line 330, in update
self.outlook_data = self._get_client_data(‘allergens’, ‘outlook’)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/pollen.py”, line 291, in _get_client_data
data = getattr(getattr(self._client, module), operation)()
File “/srv/homeassistant/lib/python3.5/site-packages/pypollencom/allergens.py”, line 30, in outlook
return self.get(‘forecast/outlook’).json()
File “/srv/homeassistant/lib/python3.5/site-packages/pypollencom/api.py”, line 38, in get
return self.request(‘get’, url, **kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/pypollencom/api.py”, line 30, in request
resp.raise_for_status()
File “/srv/homeassistant/lib/python3.5/site-packages/requests/models.py”, line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://www.pollen.com/api/forecast/outlook/43947

How does your configuration look like? I noticed in the example on github, that the zip code had to be in double quotes, that worked for me.

Platform author here. The last line of your logs is interesting:

requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://www.pollen.com/api/forecast/outlook/43947

This doesn’t have to do with your configuration or with the platform; it has to do with Pollen.com failing in some way. I’ll need to investigate. Opened a bug here: https://github.com/home-assistant/home-assistant/issues/12916

Thank You @berniebl & @bachya for your replies. I tried everything I could think of before I posted, single quote, double quote, no quotes, secret & no secret. I kept thinking that this interface isn’t that hard! Thank you for your replies.

I’m also seeing the problems. Config was working fine so I know it’s not on my end.

What is interesting is the disease_average_forecasted is still updating fine; it’s just the allergy side failing.

  - platform: pollen
    zip_code: 90210
    monitored_conditions:
      - allergy_index_today
      - allergy_index_tomorrow
      - disease_average_forecasted

Just added a PR that should address this issue: https://github.com/home-assistant/home-assistant/pull/12930

If you’re anxious to include it before an official release, you can always download the new pollen.py and place it into <configuration_dir>/custom_components/sensor/pollen.py.

Thanks, that sorted it out… Now I know if I need to take allergy meds in the morning or can pass for the day…