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
73.7k stars 30.82k forks source link

Secretlab MAGRGB Thread HomeKit Configuration Error #110081

Closed m4tthall73 closed 5 months ago

m4tthall73 commented 9 months ago

The problem

So, I am not sure whether what I am trying to do is wrong or not so apologies in advance if I am being stupid. I used the link from the system log entry to get here.

I have bought the following light which comes with my desk, which is effectively a nanoleaf https://secretlab.co.uk/products/magrgb-diffused-rgb-strip-smart-edition

I installed the nanoleaf app and added the light. During this process it connected to my thread border router, which is a Google Nest Hub. Everything seems to work fine.

I went into Home Assistant and received the notification that a new decive had been discovered and it identifies the light as a HomeKit Device.

In settings, I attempt to configure this device but it returns with the error that it cannot be configured and asks to enter a code. I try the code on the device but receive the same error "Pairing attempt failed with an unhandled exception"

I have copied the corresponding entry from the system log

My setup is

I am pretty sure I might be doing something dumb so any advice really welcome, thanks!

What version of Home Assistant Core has the issue?

core-2024.2.0

What was the last working version of Home Assistant Core?

core-2024.2.0

What type of installation are you running?

Home Assistant OS

Integration causing the issue

HomeKit

Link to integration documentation on our website

https://www.home-assistant.io/integrations/homekit_controller/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.homekit_controller.config_flow
Source: components/homekit_controller/config_flow.py:490
Integration: homekit_controller (documentation, issues)
First occurred: 08:27:05 (4 occurrences)
Last logged: 08:38:01

Pairing attempt failed with an unhandled exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 294, in do_pair_setup
    response = await self.pair_setup_client.request(request).response
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 490, in async_step_pair
    self.finish_pairing = await discovery.async_start_pairing(self.hkid)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/discovery.py", line 57, in async_start_pairing
    salt, srpB = await self.connection.do_pair_setup(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 293, in do_pair_setup
    async with asyncio_timeout(16.0):
  File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

Additional information

No response

home-assistant[bot] commented 9 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 9 months ago

Hello again :-)

m4tthall73 commented 9 months ago

Hello again :-)

Thanks again!

Jc2k commented 9 months ago

If Matter is working you should have working IPv6. But lets check. The settings should be visible in your HA settings menu. I only have a container install to hand. I have some network settings at the url /config/network but because its not HAOS, I don't know if thats where the settings you need are. If its the right place you'll be able to set your ipv4 address to static or DHCP in the same place.

m4tthall73 commented 9 months ago

OK, in the Network section of Settings IPv6 has Automatic set

Jc2k commented 9 months ago

Ok thats the 2 biggest causes of Timeout's ruled out.

Thread relies on ICMPv6 Router Advertisements. If you didn't have automatic there, HAOS would ignore them and you wouldn't be able to route packets to the mesh.

Those RA's only work within a single VLAN, which is why I asked about those. It's quite common for advanced prosumer home networks to have the BR and HA on a different VLAN, and that doesn't work at all.

In the thread integration, where you can see your border router and thread network details, there should be a hamburger "..." menu. Under there you should be able to get a diagnostics JSON report. Grab that and attach it here.

Is your Nanoleaf light close to the BR? Is the Aqara closer? Are there any walls or ceilings in the way?

Is the Nanoleaf controller near any USB3 cables? Power? HDMI? etc.

m4tthall73 commented 9 months ago

I guess the nanoleaf is a reasonable distance from the BR but the aqara was in the same room and originally set-up there, until I moved it.

I have attached the json config_entry-thread-4be984c9817f1f6ac59630591905923a.json

Jc2k commented 9 months ago

There's no border routers visible at all in that dump. Can you try again, but make sure you are on the popup where you can see the border router, see the name of the border router, its logo, etc. There's a race condition if you do it from the other place.

Jc2k commented 9 months ago

The timeout is 16s. It shouldn't take 16s for a packet to exit HA, go to the router, go to the BR, go to the device, and then come back. For a powered device, it should be sub second.

HomeKit over Thread is UDP based. Matter is either TCP or UDP with a custom "Message Reliability Protocol" on top. So if the signal is barely reaching that part of your home, Matter may just be better than HomeKit at pairing. Could you move the Nest or the light strip to rule it out? If you do, restart HA after moving them just in case the IPv6 prefix changes or anything that might distrupt the test.

The other thing I want to know is if the discovery is still there if you restart HA? Does it come back almost immediately?

m4tthall73 commented 9 months ago

In the Thread Integration page, I click on Configure and the next page shows NEST-PAN-4AD3.

If I click the "i", it pops up the following:

Network name: NEST-PAN-4AD3 Channel: 12 Dataset id: 01HG0RZHEZ7WAZK4A6NHFNJVV8 Pan id: 4ad3 Extended Pan id: b99fb654c6953656

Below, there is an entry with the Google logo showing my Google Nest Hub Max,

If I click the ... next to this it simply pops up with "Used for Android and iOS credentials", which is greyed out. There are no other options on the menu.

I will move the Nest Hub Max and try again, although that might need to be a bit later.

I just tried restarting Home Assistant to see if the discovery found the device again but it didn't appear to automatically show up.

Thanks again for your assistance/time on this, much appreciated.

Jc2k commented 9 months ago

So the discoveries don't currently time out. So if the device only has intermittent thread connectivity, or it has decided to switch thread off and go back to bluetooth, you might catch an old stale discovery. Restarting and it not coming back is consistent with this sort of thing. Hopefully moving the nest closer will sort things out, in which case you'll need more router capable Thread devices or more BRs.

m4tthall73 commented 9 months ago

So, I restarted HA with the Nest Hub Max literally a couple of feet away from the light. It didn't automatically find the light.

I therefore deleted it from nanoleaf and then factory reset the light itself. I then added the light back into nanoleaf.

I went back to HA and it discovered the light. I pressed configure and it prompted for code, which I entered. It then asked me for where the light was located and added it fine.

I now have a new HomeKit controller integration with the device on it.

I guess it was the distance of the Google Nest Hub and will need to put it back in it's original location to see if it continues working.

Many thanks for your help, much appreciated. I should have probably recognised distance might have been an issue myself but you live and learn huh!

m4tthall73 commented 9 months ago

Final point, now seems to be working fine even when I return the Google Nest Hub back to it's original location, thanks once more @Jc2k!

Jc2k commented 9 months ago

The initial setup is likely one of the heavier exchanges it will do so not too surprised.

If you have any more problems with it - adding more mains powered routers or BRs should help.

I'd strongly suggest asking on our discord if you go down that route, not all vendors products make great routers.. some are very crashy.

m4tthall73 commented 8 months ago

Hi @Jc2k, sorry to bother you again. This had been working perfectly for the last 3 weeks without any problems. A couple of days back it seems to have stopped working. It may have coincided with a Home Assistant update but I cannot be sure.

Anyway, so I went back to the beginning and removed the light from nanoleaf, moved the google nest hub closer, reset the light and went through the set-up procedure again. It got to the point in Home Assistant where it asks for the code and I enter this but now receive the error "This accessory is already paired to another device. Please reset the accessory and try again".

I have reset the device numerous times now and gone through the above in a variety of different ways e.g., after restarting HA, removing things in different orders. However, I simply can't get past this error. Do you have any idea how to get past this one?

FYI, I have pasted some log entries (3 of them) that occur at the time this happens in case that provides any help.

ERROR LOG ENTRY 1

Logger: aiohomekit.utils Source: /usr/local/lib/python3.12/site-packages/aiohomekit/utils.py:45 First occurred: 09:47:34 (1 occurrences) Last logged: 09:47:34

Failure running background task: Task-7598 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'

WARNING LOG ENTRY 1

Logger: coap-server Source: runner.py:188 First occurred: 09:47:34 (1 occurrences) Last logged: 09:47:34

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'")

ERROR LOG ENTRY 2

Logger: homeassistant.components.homekit_controller.config_flow Source: components/homekit_controller/config_flow.py:452 Integration: homekit_controller (documentation, issues) First occurred: 09:47:34 (1 occurrences) Last logged: 09:47:34

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 440, in get_accessory_info results = await self.enc_ctx.post_all(OpCode.CHAR_READ, iids, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/coap/connection.py", line 201, in post_all 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

issue-triage-workflows[bot] commented 5 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.