Open kodbeeck opened 3 weeks ago
Hi there,
I seem to have the exact same issue, slight differences in the logs, but almost the same. Running HomeAssistant in Docker, version 2024.7, nhc2 repo version 4.3.4, same as previous poster.
I've just upgraded my hardware to Home Control 2 today, when trying to add by IP address i also get the "unknown error". No issues installing the repo with HACS, HA was updated just before.
I did a little checking, it seems the newest version of HA does more checking on blocking calls, which happen here in the coco_profiles.php file, line 34. I tried to change the code to the recommendation in the error log https://developers.home-assistant.io/docs/asyncio_blocking_operations/#sleep, see below (instead of sleep(0.05) changed to await asyncio.sleep(0.05) ) and making the def async, but it throws errors on an underlying file then. Also tried to comment out the sleep function, but as expected it will immediately say controller not found, but no error. I have not had the time to investigate further, and i'm also not that familiar with python.
I'll leave you with my logs (starting from the ERROR message, interesting part is only in the last few lines), and hope we have a fix soon.
Many thanks and kind regards.
2024-07-05 17:59:22.977 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
return await func(self, request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
return await super().post(request, flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
return await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
result = await self._flow_mgr.async_configure(flow_id, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure
result = await self._async_configure(flow_id, user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 415, in _async_configure
result = await self._async_handle_step(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step
result: _FlowResultT = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/nhc2/config_flow.py", line 95, in async_step_manual_host
disc = CoCoDiscoverProfiles(user_input[CONF_HOST])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/nhc2/nhccoco/coco_discover_profiles.py", line 20, in __init__
self._search_for_one_host(host)
File "/config/custom_components/nhc2/nhccoco/coco_discover_profiles.py", line 54, in _search_for_one_host
CoCoProfiles(
File "/config/custom_components/nhc2/nhccoco/coco_profiles.py", line 34, in __init__
sleep(0.05)
File "/usr/src/homeassistant/homeassistant/util/loop.py", line 192, in protected_loop_func
raise_for_blocking_call(
File "/usr/src/homeassistant/homeassistant/util/loop.py", line 158, in raise_for_blocking_call
raise RuntimeError(
RuntimeError: Caught blocking call to sleep with args (0.05,) inside the event loop by custom integration 'nhc2' at custom_components/nhc2/nhccoco/coco_profiles.py, line 34: sleep(0.05). (offender: /config/custom_components/nhc2/nhccoco/coco_profiles.py, line 34: sleep(0.05)), please create a bug report at https://github.com/joleys/niko-home-control-II/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#sleep
If there is someone with knowledge of async stuff: please let me know
Just some notes for my future self:
Got the exact same stacktrace as @the-aajzkjoeb
First time setup of a new NHC installation, HA 2024.7.2 and NHC 4.3.4.
I have release v4.4.1 which has a temporary work around.
This will allow you to configure the integration with the Niko Hobby API
// cc @kodbeeck, @the-aajzkjoeb, @petermnt, @hoedtkristof
I will try to find a way to get it fixed decently. But I probably need to find someone with knowledge of executing blocking code in async. So if anyone has knowledge of this: please contact me.
Thanks for the temp fix! It works indeed as before. Hopefully someone can chime in to help with the async.
Temp fix confirmed working, I was able to integrate Niko in HA. Many thanks!
Dear all,
I have been running nhc2 for several years, without problems. Then I wanted to upgrade the repository from 4.0.0 to 4.3.4, but the update process did not seem to finish (spinning circle indefinitely). After a reboot, the nhc installation was unable to load. I then updated HA to 2024.7, removed the old nhc2 installation and reinstalled nhc2 through HACS. Although this also results in an indefinite spinning circle and several file download timeout warnings in the logs, it does seem to download and install files eventually. After a reboot, I then tried to install the repository, but it does not find a controller, even though I input the correct IP. It results in an "unknown error".
Below you can find the logs: