dahlb / ha_hatch

Home Assistant Integration for Hatch Rest Mini
MIT License
77 stars 16 forks source link

Supervisor 2023.06.1 error #52

Closed Intecpsp closed 12 months ago

Intecpsp commented 12 months ago

I get the below error every time I reload the integration after updating to Supervisor 2023.06.1.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/ha_hatch/__init__.py", line 164, in async_setup_entry
    await setup_connection("initial setup")
  File "/config/custom_components/ha_hatch/__init__.py", line 136, in setup_connection
    _, mqtt_connection, rest_devices, expiration_time = await get_rest_devices(
  File "/usr/local/lib/python3.10/site-packages/hatch_rest_api/util_bootstrap.py", line 31, in get_rest_devices
    token = await api.login(email=email, password=password)
  File "/usr/local/lib/python3.10/site-packages/hatch_rest_api/hatch.py", line 64, in login
    await self._post_request_with_logging_and_errors_raised(
  File "/usr/local/lib/python3.10/site-packages/hatch_rest_api/hatch.py", line 19, in request_with_logging_wrapper
    if response_json["errorCode"] == 1001:
KeyError: 'errorCode'
Intecpsp commented 12 months ago

I'm thinking the problem change is https://github.com/home-assistant/supervisor/pull/4333

dahlb commented 12 months ago

released 1.15.1 to improve logging when the api is missing expected response components, might fix your concern.

however if it doesn't please turn on logging of the hatch api

logger:
  default: warning
  logs:
    custom_components.ha_hatch: debug
    hatch_rest_api: debug

and include your raw api responses from before this error to help us track down what is happening

Intecpsp commented 12 months ago

I just updated and now getting a new error.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/ha_hatch/__init__.py", line 161, in async_setup_entry
    await setup_connection("initial setup")
  File "/config/custom_components/ha_hatch/__init__.py", line 133, in setup_connection
    _, mqtt_connection, rest_devices, expiration_time = await get_rest_devices(
  File "/usr/local/lib/python3.10/site-packages/hatch_rest_api/util_bootstrap.py", line 31, in get_rest_devices
    token = await api.login(email=email, password=password)
  File "/usr/local/lib/python3.10/site-packages/hatch_rest_api/hatch.py", line 64, in login
    await self._post_request_with_logging_and_errors_raised(
  File "/usr/local/lib/python3.10/site-packages/hatch_rest_api/hatch.py", line 22, in request_with_logging_wrapper
    raise ClientError(f"api error:{response_json.get('message')}")
aiohttp.client_exceptions.ClientError: api error:None

I'm not seeing the raw responses in the log though. Where would I see those?

dahlb commented 12 months ago

fyi: I did the upgrade you mentioned for supervisor and am now experiencing this myself

dahlb commented 12 months ago

it looks like this

2023-06-06 15:02:13.775 DEBUG (MainThread) [hatch_rest_api.util_http] response json: {'timestamp': '2023-06-06 19:02:13.421', 'status': 500, 'error': 'Internal Server Error', 'path': '/public/v1/login'}

not sure why the api server started throwing 500 errors, will keep looking into when I have more time

dahlb commented 12 months ago

1.15.2 allows it to keep working but introduces a warning I'll work on fixing next week. looks like the instance of aiohttp home assistant core provides has somehow changed in an incompatible way

Intecpsp commented 12 months ago

I can confirm 1.15.2 gets me back up and running, thank you for the quick turnaround!

dahlb commented 12 months ago

real fix in 1.15.5, user agent provided by home assistant was causing the api 500 error https://github.com/dahlb/hatch_rest_api/commit/f5288ff7ea8b8185d305cf06ce23131f2725851c