home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.87k stars 29.55k forks source link

Adding Thread device via Homekit fails with Apple Border Router #110379

Closed richie510 closed 3 months ago

richie510 commented 6 months ago

The problem

I unpaired a HomeKit Wemo Stage Controller from the Home app. Then I got attempted to pair to Home Assistant. After inputting the homekit pairing code, I got an error from home assistant. After that error, the device would not show up to be able to pair again in home assistant.

What version of Home Assistant Core has the issue?

2024.2.1

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

2024-02-12 08:57:55.495 ERROR (MainThread) [homeassistant.components.homekit_controller.config_flow] Pairing attempt failed with an unhandled exception Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/pairing.py", line 111, in _ensure_connected await self.connection_future File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 404, in connect await self.get_accessory_info() File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 413, in get_accessoryinfo , body = await self.enc_ctx.post(OpCode.UNK_09_READ_GATT, 0x0000, b"") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 194, in post res_pdu = await self.post_bytes(req_pdu) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 171, in post_bytes response = await self.coap_ctx.request(request).response ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 606, in _run_outer await cls._run(app_request, response, weak_observation, protocol, log) File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 665, in _run blockresponse = await blockrequest.response ^^^^^^^^^^^^^^^^^^^^^^^^^^^ aiocoap.error.LibraryShutdown

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 452, in async_step_pair return await self._entry_from_accessory(pairing) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 580, in _entry_from_accessory name = await pairing.get_primary_name() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/abstract.py", line 264, in get_primary_name accessories = await self.list_accessories_and_characteristics() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/pairing.py", line 147, in list_accessories_and_characteristics await self._ensure_connected() File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/pairing.py", line 113, in _ensure_connected raise AccessoryDisconnectedError("failed to connect") aiohomekit.exceptions.AccessoryDisconnectedError: failed to connect 2024-02-12 08:57:55.577 WARNING (MainThread) [coap-server] An exception that is not an aiocoap Error was raised from a transport; please report this as a bug in aiocoap: AttributeError("'RecvmsgSelectorDatagramTransport' object has no attribute '_fatal_error'") 2024-02-12 08:57:55.579 ERROR (MainThread) [aiohomekit.utils] Failure running background task: Task-57625 Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiocoap/util/asyncio/recvmsg.py", line 126, in sendmsg self.__sock.sendmsg((data,), ancdata, flags, address) ^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'sendmsg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohomekit/utils.py", line 40, in _handle_task_result task.result() File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/pairing.py", line 169, in _process_config_changed await self.list_accessories_and_characteristics() File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/pairing.py", line 149, in list_accessories_and_characteristics accessories = await self.connection.get_accessory_info() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 413, in get_accessoryinfo , body = await self.enc_ctx.post(OpCode.UNK_09_READ_GATT, 0x0000, b"") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 194, in post res_pdu = await self.post_bytes(req_pdu) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 171, in post_bytes response = await self.coap_ctx.request(request).response ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 606, in _run_outer await cls._run(app_request, response, weak_observation, protocol, log) File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 665, in _run blockresponse = await blockrequest.response ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiocoap/tokenmanager.py", line 219, in request send_canceller = self.token_interface.send_message(msg, lambda: request.add_exception(error.MessageError)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiocoap/messagemanager.py", line 419, in send_message self._send_initially(message, messageerror_monitor) File "/usr/local/lib/python3.12/site-packages/aiocoap/messagemanager.py", line 432, in _send_initially self._send_via_transport(message) File "/usr/local/lib/python3.12/site-packages/aiocoap/messagemanager.py", line 437, in _send_via_transport self.message_interface.send(message) File "/usr/local/lib/python3.12/site-packages/aiocoap/transports/udp6.py", line 356, in send self.transport.sendmsg(message.encode(), ancdata, 0, message.remote.sockaddr) File "/usr/local/lib/python3.12/site-packages/aiocoap/util/asyncio/recvmsg.py", line 132, in sendmsg self._fatal_error(exc, ^^^^^^^^^^^^^^^^^ AttributeError: 'RecvmsgSelectorDatagramTransport' object has no attribute '_fatal_error' 2024-02-12 08:58:07.419 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request 2024-02-12 08:58:07.927 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request 2024-02-12 08:58:08.936 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request 2024-02-12 08:58:09.431 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request 2024-02-12 08:58:10.939 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request 2024-02-12 08:58:22.539 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 2 failed with error 6 (Invalid request 2024-02-12 08:58:23.049 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 2 failed with error 6 (Invalid request 2024-02-12 08:58:24.052 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 2 failed with error 6 (Invalid request 2024-02-12 08:58:24.547 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 2 failed with error 6 (Invalid request 2024-02-12 08:58:26.056 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 2 failed with error 6 (Invalid request 2024-02-12 08:58:40.147 WARNING (MainThread) [aiohomekit.controller.coap.pdu] Transaction 0 failed with error 6 (Invalid request

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 6 months ago

Hey there @jc2k, @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit_controller) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `homekit_controller` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign homekit_controller` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


homekit_controller documentation homekit_controller source (message by IssueLinks)

Jc2k commented 6 months ago

It looks like you had a network problem during the pairing sequence - after the wemo considered itself paired but before Ha did. The wemo will only pair once, so can no longer pair again. When this happens you need to do a hard reset of the wemo to try again. Keep the wemo close to your border router during pairing.

richie510 commented 6 months ago

@Jc2k I tried it again. I still got several errors, but this time it worked. Thanks for the help!

Jc2k commented 6 months ago

The transaction errors are nothing to worry about and will go away at some point when I have time.

I have 2 of these and they are very erratic. One didn't even ship as new with a working pairing code in the box. Had to decode the NFC tag to even add it to HA. Ended up replacing them with hue remotes.

issue-triage-workflows[bot] commented 3 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.