Carbu_com icon indicating copy to clipboard operation
Carbu_com copied to clipboard

Integration sometimes fails to setup

Open FRvanderVeen opened this issue 1 year ago • 0 comments

Sometimes the integration fails to setup. The following error occurs in the logs in that case:

Error while setting up carbu_com platform for sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/carbu_com/sensor.py", line 193, in async_setup_entry
    await dry_setup(hass, config, async_add_devices)
  File "/config/custom_components/carbu_com/sensor.py", line 72, in dry_setup
    await componentData._forced_update()
  File "/config/custom_components/carbu_com/sensor.py", line 322, in _forced_update
    boundingboxLocationInfo = await self._hass.async_add_executor_job(lambda: self._session.convertLocationBoundingBox(self._postalcode, self._country, self._town))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/carbu_com/sensor.py", line 322, in <lambda>
    boundingboxLocationInfo = await self._hass.async_add_executor_job(lambda: self._session.convertLocationBoundingBox(self._postalcode, self._country, self._town))
                                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ratelimit/decorators.py", line 113, in wrapper
    return func(*args, **kargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ratelimit/decorators.py", line 80, in wrapper
    return func(*args, **kargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/carbu_com/utils.py", line 166, in convertLocationBoundingBox
    orig_location = self.searchGeocodeOSM(postalcode, town, country_name)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ratelimit/decorators.py", line 113, in wrapper
    return func(*args, **kargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ratelimit/decorators.py", line 80, in wrapper
    return func(*args, **kargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/carbu_com/utils.py", line 1225, in searchGeocodeOSM
    nominatim_data = nominatim_response.json()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It results in the sensor not being present. I tried enabling debug logging to see if I could see what's going on, but then stuff magicly started working again. From the stacktrace to me it looks like something going wrong with geocoding the postal code. But I may be wrong.

FRvanderVeen avatar Jul 29 '24 13:07 FRvanderVeen