eyesoft / home_assistant_min_renovasjon

Home Assistant integration of the Min Renovasjon app
MIT License
32 stars 22 forks source link

Glass and metal sensor is unavailable, causing timeout and deep recursion error #15

Closed robinsmidsrod closed 2 years ago

robinsmidsrod commented 2 years ago

I'm using HACS version of min_renovasjon, version 2.1.0 and I'm getting this error when trying to start up:

This happens for municipal Tønsberg (3803). I can provide you with the exact address in PM if it actually matters for debugging.

I've got the following sensors (fractions) available and working (except for the one mentioned below):

This sequence goes over and over again in very rapid succession (several per second, probably hammering the API):

2022-10-23 20:08:12.558 DEBUG (MainThread) [custom_components.min_renovasjon] Data needs refresh
2022-10-23 20:08:12.558 DEBUG (MainThread) [custom_components.min_renovasjon] _get_tommekalender_from_web_api
2022-10-23 20:08:12.595 DEBUG (MainThread) [custom_components.min_renovasjon] _get_fraksjoner_from_web_api

Until finally I get this stack trace:

2022-10-23 20:08:12.636 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform min_renovasjon
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 691, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 776, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/min_renovasjon/sensor.py", line 117, in async_added_to_hass
    await self.async_update()
  File "/config/custom_components/min_renovasjon/sensor.py", line 99, in async_update
    fraction = await self._min_renovasjon.get_calender_for_fraction(self._fraction_id)
  File "/config/custom_components/min_renovasjon/__init__.py", line 203, in get_calender_for_fraction
    entry = await self.get_calender_for_fraction(fraksjon_id)
  File "/config/custom_components/min_renovasjon/__init__.py", line 203, in get_calender_for_fraction
    entry = await self.get_calender_for_fraction(fraksjon_id)
  File "/config/custom_components/min_renovasjon/__init__.py", line 203, in get_calender_for_fraction
    entry = await self.get_calender_for_fraction(fraksjon_id)
  [Previous line repeated 959 more times]
  File "/config/custom_components/min_renovasjon/__init__.py", line 193, in get_calender_for_fraction
    calendar_list = await self.get_calendar_list()
  File "/config/custom_components/min_renovasjon/__init__.py", line 224, in get_calendar_list
    kalender_list = await self.get_calendar_list(refresh=True)
  File "/config/custom_components/min_renovasjon/__init__.py", line 211, in get_calendar_list
    tommekalender, fraksjoner = await self._get_from_web_api()
  File "/config/custom_components/min_renovasjon/__init__.py", line 131, in _get_from_web_api
    tommekalender = await self._get_tommekalender_from_web_api()
  File "/config/custom_components/min_renovasjon/__init__.py", line 105, in _get_tommekalender_from_web_api
    async with session.get(url) as resp:
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1111, in _create_connection_transport
    transport = self._make_ssl_transport(
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 73, in _make_ssl_transport
    _SelectorSocketTransport(self, rawsock, ssl_protocol,
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 772, in __init__
    base_events._set_nodelay(self._sock)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 196, in _set_nodelay
    if (sock.family in {socket.AF_INET, socket.AF_INET6} and
  File "/usr/local/lib/python3.10/socket.py", line 518, in family
    return _intenum_converter(super().family, AddressFamily)
  File "/usr/local/lib/python3.10/socket.py", line 105, in _intenum_converter
    return enum_klass(value)
  File "/usr/local/lib/python3.10/enum.py", line 385, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.10/enum.py", line 688, in __new__
    return cls._value2member_map_[value]
RecursionError: maximum recursion depth exceeded while calling a Python object
eyesoft commented 2 years ago

Fixed in new version, 2.1.1