flabbamann/aha_region

Error since latetst HA update: "Unexpected error fetching aha Region data: list index out of range"

Closed this issue ยท 9 comments

gafk commented

Since the lateste HA update, I get the following errors on HA restart and the AHA sensors don't show up. Everything was running before with the same config.

Logger: custom_components.aha_region
Source: custom_components/aha_region/coordinator.py:47
Integration: aha region ([documentation](https://github.com/flabbamann/aha_region), [issues](https://github.com/flabbamann/aha_region/issues))
First occurred: 06:28:24 (1 occurrences)
Last logged: 06:28:24

Unexpected error fetching aha Region data: list index out of range 

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/aha_region/coordinator.py", line 77, in _async_update_data
    response = await self.api.get_data()
  File "/config/custom_components/aha_region/coordinator.py", line 47, in get_data
    table = soup.find_all("table")[0]
IndexError: list index out of range
Logger: homeassistant
Source: custom_components/aha_region/sensor.py:77
Integration: aha region ([documentation](https://github.com/flabbamann/aha_region), [issues](https://github.com/flabbamann/aha_region/issues))
First occurred: 06:28:41 (1 occurrences)
Last logged: 06:28:41

Error doing job: Task exception was never retrieved 

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

Yes, I know. The aha-website was down over the weekend. It should be working again after a restart of HA ๐Ÿ‘

Hm, the website is back, but the "Abfuhrkalender" is disabled due to technical issues. We'll have to wait how that turns out. ๐Ÿ˜•

gafk commented

"Abfuhrkalender" is back online, but I keep getting errors when restarting HA and the sensors are not available.
Maybe something was changed on the AHA website that requires adjusting the integration?

gafk commented

grafik

Basically the website did not change and the component should still work (it does in my HA). But the website seemed to be a bit unreliable. I need to think of a way to get the component a bit more tolerant to errors on their end.

@flabbamann I have the same problem. Latest Home Assistant version and I can't get it to work. However, the "Abfuhrkalender" is available for me.

Hi @dennisoderwald,
If you get a timeout it is either the aha website not available or a problem with your network, so I'm afraid there is not much I can do ๐Ÿ™

If you get a different error, please provide the debug logs.

logger:
  default: info
  logs:
    custom_components.aha_region: debug
2022-12-15 01:56:31.466 DEBUG (MainThread) [custom_components.aha_region] Start async_update_data()
2022-12-15 01:56:31.466 DEBUG (MainThread) [custom_components.aha_region] Request data: {'gemeinde': 'Hannover', 'strasse': '00726@Dragonerstr. / Vahrenwald@Vahrenwald', 'hausnr': '35', 'hausnraddon': ''}
2022-12-15 01:56:32.439 DEBUG (MainThread) [custom_components.aha_region] Response: <ClientResponse(https://www.aha-region.de/abholtermine/abfuhrkalender) [200 OK]>
<CIMultiDictProxy('Date': 'Thu, 15 Dec 2022 00:56:31 GMT', 'Server': 'Apache', 'X-Powered-By': 'PHP/7.4.33', 'Content-Language': 'de', 'Cache-Control': 'private, no-store', 'Set-Cookie': 'fe_typo_user=757eb7a38cf34b5112138dc1035a13be; path=/; httponly; samesite=lax', 'Strict-Transport-Security': 'max-age=31536000', 'Access-Control-Allow-Origin': '*', 'Upgrade': 'h2', 'Connection': 'Upgrade', 'Cache-Control': 'max-age=0', 'Expires': 'Thu, 15 Dec 2022 00:56:31 GMT', 'Vary': 'Accept-Encoding,User-Agent', 'Content-Encoding': 'gzip', 'X-UA-Compatible': 'IE=edge', 'X-Content-Type-Options': 'nosniff', 'Transfer-Encoding': 'chunked', 'Content-Type': 'text/html; charset=utf-8')>

2022-12-15 01:56:32.718 ERROR (MainThread) [custom_components.aha_region] Unexpected error fetching aha Region data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/aha_region/coordinator.py", line 77, in _async_update_data
    response = await self.api.get_data()
  File "/config/custom_components/aha_region/coordinator.py", line 47, in get_data
    table = soup.find_all("table")[0]
IndexError: list index out of range
2022-12-15 01:56:32.725 DEBUG (MainThread) [custom_components.aha_region] Finished fetching aha Region data in 1.259 seconds (success: False)

Hi @dennisoderwald,
I found the problem. Your Adress needs to specify an Abholplatz to get the pickup dates. I have not seen this before, all places I lived in Hannover did not have an Abholplatz ๐Ÿค“.

I opened #25 and hope I will find some time to add support for this ๐Ÿคž.