flabbamann/aha_region

TypeError: 'NoneType' object is not subscriptable in AhaWasteSensor class constructor

Closed this issue · 5 comments

When attempting to use the aha_region in Home Assistant, I am encountering the following error message:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
tasks = [
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in <listcomp>
tasks = [
File "/config/custom_components/aha_region/sensor.py", line 73, in <genexpr>
AhaWasteSensor(coordinator, wastetype, baseid) for wastetype in ABFALLARTEN
File "/config/custom_components/aha_region/sensor.py", line 90, in __init__
native_value = self.coordinator.data[self._attr_name]
TypeError: 'NoneType' object is not subscriptable

This is how the definition in configuration.yaml looks like, I tried both my own address and the one used as an example in the README, with the same result (the error above):

- platform: aha_region
  gemeinde: "Hannover"
  strasse: "00152@Am Küchengarten / Linden-Mitte@Linden-Mitte" # value from dropdown
  hausnr: 11
  hausnraddon: "a" # optional, remove if not needed for your address!

I guess I must've done something wrong, as it works now? Closing.

Maybe a temporary issue with the aha-website 🤔. I'm happy that it's working for you now 👍

Reopening, as this has appeared once again - without me touching anything.

Seems like it indeed has trouble fetching the website:

2023-04-08 15:21:06.819 DEBUG (MainThread) [custom_components.aha_region] Finished fetching aha Region data in 12.810 seconds (success: False)

Hm, so sometimes it is working and sometimes not? Maybe a connection issue on your network or the aha website being unreliable? I don't really have an Idea here... 😞
I want the Integration to be more robust, so it can tolerate connection issues and will try again later, but I don't have much time to work on this currently.

Latest release has some improvements to be more fault tolerant. Feel free to open a new issue if you encounter any problems.