core: Cannot pair any of the devices with Homekit Device integration
The problem
I was intially pairing an already configured Aqara FP2 device (on manufacture app), removed from Homekit and trying to get it integrated into my Home Assistant OS setup on my Hyper-V VM for some automation, however, I got a error prompt message when trying to configure the auto discovered Homekit device on UI says:
Error Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble.
While the logs contain only one event says:
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 101, in <dictcomp>
k.decode("utf-8").lower(): v.decode("utf-8")
^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'decode'
At the very first moment I thought such issues were caused by misconfiguration or networking when I trying to find a solution, fix, and even a diagnostic & troubleshooting guidelines, therefore I tested with my mDNS, pinging with Aqara FP2, and try to log some useful logs from Home Assistant:
- The networking seems to be fine, I used
avahi-browse, Discovery app on macOS to check the_hap._tcprecords, the Aqara FP2, and my simulated Homekit devices for test purposes are discoverable either under_aqara_setup._tcpor under_hap._tcp. For example:
Server version: avahi 0.8; Host name: gateway.local
E Ifce Prot Name Type Domain
+ eth0 IPv6 Presence-Sensor-FP2-069E _aqara-setup._tcp local
+ eth0 IPv4 Presence-Sensor-FP2-069E _aqara-setup._tcp local
hostname = [Doorbell\032Repeater-9911.local]
address = [10.0.2.71]
port = [51024]
txt = ["id=lumi1.54ef444c9911" "pv=true" "zi=0" "ui=1752996408" "cv=1" "ver=3"]
= eth0 IPv6 Presence-Sensor-FP2-069E _aqara-setup._tcp local
hostname = [Presence-Sensor-FP2-069E.local]
address = [10.0.1.217]
port = [28420]
txt = ["ver=3" "cv=1" "pv=true" "id=lumi1.54ef444f069e" "ui=1752996408"]
= eth0 IPv4 Presence-Sensor-FP2-069E _aqara-setup._tcp local
hostname = [Presence-Sensor-FP2-069E.local]
address = [10.0.1.217]
port = [28420]
txt = ["ver=3" "cv=1" "pv=true" "id=lumi1.54ef444f069e" "ui=1752996408"]
: All for now
: Cache exhausted
- Able to ping with the static IP records from mDNS.
Therefore I try to seek out a method to directly debug the code that caused the issue:
props: dict[str, str] = {
k.decode("utf-8").lower(): v.decode("utf-8")
for (k, v) in service.properties.items()
}
However, the attempt to directly modify the source code of the aiohomekit library that used by Home Assistant failed because I couldn’t find a resource that guide me to get into the Home Assistant OS and modify my desired source code file, some of the community forum says it is prohibited to exec into Home Assistant OS.
Eventually I tried to setup a fresh install with Home Assistant OS, Home Assistant Container to test this case, and concluded such issue is stable to reproduce with the following of the Homekit Devices:
- Aqara FP2
- Simulated Homekit Sensor device with Occupancy Sensor service
- Simulated Homekit Sensor device with Temperature Sensor service
These devices is discoverable and configurable, and working correctly with Home app in iOS and iPadOS once configured.
So what is the possible root cause of such issue? And where can I find resources to help to fix and diagnostic such issues? Is this a known issue?
Additional Context
- Simulated device configuration for Occupancy Sensor
- Simulated device configuration for Temperature Sensor
What version of Home Assistant Core has the issue?
core-2023.10.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Homekit Device
Link to integration documentation on our website
https://www.home-assistant.io/integrations/homekit_controller/
Diagnostics information
Cannot add any of the Homekit Device with integration, cannot get to the integration page and get the diagnostic data downloaded
Example YAML snippet
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
logger:
default: debug
logs:
aiohomekit: debug
Anything in the logs that might be useful for us?
Logger: aiohttp.server
Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:403
First occurred: 5:48:26 PM (1 occurrences)
Last logged: 5:48:26 PM
Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
return await func(self, request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 170, in get
return await super().get(request, flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 96, in get
result = await self._flow_mgr.async_configure(flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 293, in async_configure
result = await self._async_handle_step(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 394, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 439, in async_step_pair
await self._async_setup_controller()
File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 126, in _async_setup_controller
self.controller = await async_get_controller(self.hass)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/homekit_controller/utils.py", line 54, in async_get_controller
await controller.async_start()
File "/usr/local/lib/python3.11/site-packages/aiohomekit/controller/controller.py", line 85, in async_start
await self._async_register_backend(
File "/usr/local/lib/python3.11/site-packages/aiohomekit/controller/controller.py", line 77, in _async_register_backend
] = await self._tasks.enter_async_context(controller)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/contextlib.py", line 638, in enter_async_context
result = await _enter(cm)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohomekit/controller/abstract.py", line 450, in __aenter__
await self.async_start()
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 226, in async_start
await self._async_update_from_cache(zc)
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 243, in _async_update_from_cache
self._async_handle_loaded_service_info(info)
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 341, in _async_handle_loaded_service_info
description = HomeKitService.from_service_info(info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 100, in from_service_info
props: dict[str, str] = {
^
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 101, in <dictcomp>
k.decode("utf-8").lower(): v.decode("utf-8")
^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'decode'
Additional information
More logs:
Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:143
First occurred: 5:56:11 PM (1 occurrences)
Last logged: 5:56:11 PM
Error doing job: Exception in callback ZeroconfController._async_resolve_later(' 8EF584._hap._tcp.local.', AsyncServiceI...ce_index=None))
Traceback (most recent call last):
File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 295, in _async_resolve_later
self._async_handle_loaded_service_info(info)
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 341, in _async_handle_loaded_service_info
description = HomeKitService.from_service_info(info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 100, in from_service_info
props: dict[str, str] = {
^
File "/usr/local/lib/python3.11/site-packages/aiohomekit/zeroconf.py", line 101, in <dictcomp>
k.decode("utf-8").lower(): v.decode("utf-8")
^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'decode'
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 16 (8 by maintainers)
I still don’t understand why you are getting blank keys in properties for other devices. That feels like a bug, and what threw me off. But at least it doesn’t seem to be causing any problems so it’s probably fine to ignore.