MarcoGos/kleenex_pollenradar

problem with data homeassistant 2024.4

Closed this issue · 7 comments

IndexError: list index out of range
2024-04-14 16:13:07.012 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity None for domain sensor with platform kleenex_pollenradar
Traceback (most recent call last):
File "/home/android/hass_venv/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 811, in _async_add_entity
unit_of_measurement=entity.unit_of_measurement,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.homeassistant/custom_components/kleenex_pollenradar/sensor.py", line 87, in unit_of_measurement
return self.coordinator.data[0][self.key]["unit_of_measure"]

Can you provide more information like the region you used on setup and which GPS coordinates you use (1 decimal precision is enough) so I can test it?

Italy
45.069
7.7041

I've installed the pollen integration on a 2024.4.2 version of HA and used your given gps position. Everytime works fine, so I don't have a clue why it doesn't work for you.

I'm running into the same issue, getting the following error in the logs on 2024.4.3:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 811, in _async_add_entity
    unit_of_measurement=entity.unit_of_measurement,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/kleenex_pollenradar/sensor.py", line 87, in unit_of_measurement
    return self.coordinator.data[0][self.key]["unit_of_measure"]
           ~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Which seems to suggest we are not getting the right data back from the API.

When looking into this I actually had a similar issue when visiting the kleenex site directly, it was giving me an error message instead of the counts, which only got resolved when I changed the location used (to the exact same value).

Is there an easy way to update the location without removing the entities? (I tried reload integration but that didn't work, will test later today whether a restart will help)

@MarcoGos I believe the issue is actually caused by the precision of the coordinates provided. I just tried to add a new hub to the integration using all 14 decimals that Home Assistant supplies, that gives the "Looks like you position isn't within the choosen region" error. Reducing the decimals one by one, it only ended up working with 4 decimal precision. (so the good thing is it is working again 🎉)

I suspect Kleenex changed the API to only accept limited precision coordinates to ensure they don't get peoples exact home addresses but just the neighbourhood. This also explains why @hocuspocus69 his coordinates worked for you, as that was only 3 decimals. (Strangely enough looking at the payload the Kleenex website is sending to the API, it actually uses 7 decimals, so there might be some extra logic going on in the background)

solved for me!
longitude 2 decimals
latitude 15 decimals
Thanks @b8vrede

Thanks for figuring this out. It seems that 15 decimals is no problem for the Dutch version of Kleenex.