pnbruckner / ha-entity-tz

Home Assistant Entity Time Zone Sensor
The Unlicense
3 stars 0 forks source link

b7 new geopy entities cause timeout error #1

Closed Mariusthvdb closed 9 months ago

Mariusthvdb commented 10 months ago

Please see below. Also noticed a startup timeout, and a spontaneous restart. I am not 100% certain entity-tz caused this, but it occurred after having installed the new beta, and the instance got unresponsive during its first restart. Dont see those spontaneous restarts often, hardly ever tbh, so I link to to this for now. Might be caused by the same timeout error?

Deze fout is ontstaan door een aangepaste integratie.

Logger: homeassistant
Source: custom_components/entity_tz/helpers.py:142
Integration: Tijdzone van entiteit (documentation, issues)
First occurred: 11:00:03 (1 occurrences)
Last logged: 11:00:03

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/geopy/adapters.py", line 587, in _normalize_exceptions
    yield
  File "/usr/local/lib/python3.11/site-packages/geopy/adapters.py", line 544, in get_json
    async with self._request(url, timeout=timeout, headers=headers) as resp:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1187, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 500, in _request
    with timer:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/helpers.py", line 735, in __exit__
    raise asyncio.TimeoutError from None
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/entity_tz/__init__.py", line 56, in update_from_entity
    await get_location(hass, new_state),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/entity_tz/helpers.py", line 142, in get_location
    location = await etz_data(hass).nominatim.reverse(coordinates)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/geopy/geocoders/base.py", line 374, in fut
    res = callback(await result)
                   ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/geopy/adapters.py", line 543, in get_json
    with self._normalize_exceptions():
  File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/geopy/adapters.py", line 593, in _normalize_exceptions
    raise GeocoderTimedOut("Service timed out")
geopy.exc.GeocoderTimedOut: Service timed out

as a result of which all entities, so not only the new country and address entities go 'unknown':

Scherm­afbeelding 2023-12-16 om 11 01 49
pnbruckner commented 10 months ago

Thanks. I got that when I first used geopy. I increased the default timeout of 1 sec to 3 sec and it went away. Looks like I need to make it bigger. If you want to try and see what works for you, change NOM_TIMEOUT in const.py.

I'll also add something to catch that exception in case it still happens in the future.

pnbruckner commented 9 months ago

Should be fixed in 1.0.0b8.