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
71.14k stars 29.81k forks source link

Aqara U200 Lock Setup | Matter Commissioning Error #121941

Closed NdR91 closed 1 month ago

NdR91 commented 2 months ago

The problem

Hello guys, today I'm trying to setup my new Aqara U200 Lock on Home Assistant. I still don't have an M3 hub, but I correctly setup the lock via Matter using my Amazon Echo border router.

The problem starts when I try to connect it to Home Assistant, using the code generation feature on the Alexa app. This is what i get from the python-matter-server logs:

2024-07-14 11:20:28.165 (MainThread) INFO [matter_server.server.device_controller] Starting Matter commissioning with code using Node ID 16.
2024-07-14 11:20:28.401 (Dummy-2) CHIP_ERROR [chip.native.-] src/inet/UDPEndPointImplSockets.cpp:416: OS Error 0x02000065: Network is unreachable at src/controller/SetUpCodePairer.cpp:280
2024-07-14 11:20:58.173 (Dummy-2) CHIP_ERROR [chip.native.CTL] Discovery timed out
2024-07-14 11:20:58.174 (Dummy-2) CHIP_ERROR [chip.native.ZCL] Secure Pairing Failed
2024-07-14 11:20:58.174 (Dummy-2) WARNING [root] Failed to establish secure session to device: src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp:89: CHIP Error 0x00000003: Incorrect state
2024-07-14 11:20:58.175 (MainThread) ERROR [matter_server.server.client_handler] [139906425289296] Error while handling: commission_with_code: Commission with code failed for node 16.

I don't think that the issue could be my network or Multicast handling, because i successfully setup the lock via Apple Home app, always using the Echo as Thread border router (my Apple TV 4K is 1st gen, so no thread support).

What version of Home Assistant Core has the issue?

core-2024.7.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Matter

Link to integration documentation on our website

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

Diagnostics information

No response

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 2 months ago

Hey there @home-assistant/matter, mind taking a look at this issue as it has been labeled with an integration (matter) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `matter` 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 matter` 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)


matter documentation matter source (message by IssueLinks)

ernst77 commented 1 month ago

Having the same issue...

I use apple homepod mini, as well tried via samsung thread router as well..


2024-07-15 20:18:41.652 (MainThread) ERROR [root] [Errno 2] No such file or directory: '/data/chip.json'
2024-07-15 20:18:41.652 (MainThread) CRITICAL [root] Could not load configuration from /data/chip.json - resetting configuration...
2024-07-15 20:18:41.653 (MainThread) WARNING [root] No valid SDK configuration present - clearing out configuration
2024-07-15 20:18:41.653 (MainThread) WARNING [root] No valid REPL configuration present - clearing out configuration
2024-07-15 20:18:41.906 (MainThread) WARNING [CertificateAuthorityManager] Loading certificate authorities from storage...
2024-07-15 20:18:41.906 (MainThread) WARNING [CertificateAuthority] New CertificateAuthority at index 1
2024-07-15 20:18:41.918 (MainThread) WARNING [FabricAdmin] New FabricAdmin: FabricId: 0x0000000000000002, VendorId = 0x134B
2024-07-15 20:18:41.919 (MainThread) INFO [matter_server.server.stack] CHIP Controller Stack initialized.
2024-07-15 20:18:41.921 (MainThread) INFO [matter_server.server.server] Starting the Matter Server...
2024-07-15 20:18:41.929 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Fetching the latest PAA root certificates from DCL.
2024-07-15 20:18:45.869 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Fetched 62 PAA root certificates from DCL.
2024-07-15 20:18:45.870 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Fetching the latest PAA root certificates from Git.
2024-07-15 20:18:46.384 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Fetched 2 PAA root certificates from Git.
2024-07-15 20:18:46.388 (MainThread) WARNING [FabricAdmin] Allocating new controller with CaIndex: 1, FabricId: 0x0000000000000002, NodeId: 0x000000000001B669, CatTags: []
2024-07-15 20:18:46.652 (Dummy-2) CHIP_ERROR [chip.native.DL] Long dispatch time: 258 ms, for event type 2
2024-07-15 20:18:46.669 (MainThread) INFO [matter_server.server.device_controller] Loaded 0 nodes from stored configuration
2024-07-15 20:18:46.692 (MainThread) INFO [matter_server.server.vendor_info] Loading vendor info from storage.
2024-07-15 20:18:46.692 (MainThread) INFO [matter_server.server.vendor_info] Loaded 0 vendors from storage.
2024-07-15 20:18:46.693 (MainThread) INFO [matter_server.server.vendor_info] Fetching the latest vendor info from DCL.
2024-07-15 20:18:47.031 (MainThread) INFO [matter_server.server.vendor_info] Fetched 221 vendors from DCL.
2024-07-15 20:18:47.031 (MainThread) INFO [matter_server.server.vendor_info] Saving vendor info to storage.
2024-07-15 20:22:25.282 (MainThread) INFO [matter_server.server.device_controller] Starting Matter commissioning with code using Node ID 1.
2024-07-15 20:22:55.294 (Dummy-2) CHIP_ERROR [chip.native.CTL] Discovery timed out
2024-07-15 20:22:55.295 (Dummy-2) CHIP_ERROR [chip.native.ZCL] Secure Pairing Failed
2024-07-15 20:22:55.295 (Dummy-2) WARNING [root] Failed to establish secure session to device: src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp:89: CHIP Error 0x00000003: Incorrect state
2024-07-15 20:22:55.297 (MainThread) ERROR [matter_server.server.client_handler] [548148534608] Error while handling: commission_with_code: Commission with code failed for node 1.
marcelveldt commented 1 month ago

Incorrect state means the device has already been setup. Did you rescan the code ? If you want to add a Matter device to a second (or 3rd etc) controller, you need to enable sharing mode from the first controller, which will give you a code to enter on the other controller

ernst77 commented 1 month ago

Incorrect state means the device has already been setup. Did you rescan the code ?

If you want to add a Matter device to a second (or 3rd etc) controller, you need to enable sharing mode from the first controller, which will give you a code to enter on the other controller

Yes, pairing happens through HomeKit image. Tried to pair and from smartthings app, still same error.

ernst77 commented 1 month ago
2024-07-18 15:49:41.277 (Dummy-2) CHIP_DETAIL [chip.native.DIS] SRV record already actively processed.
2024-07-18 15:49:41.277 (Dummy-2) CHIP_DETAIL [chip.native.DIS] SRV record already actively processed.
2024-07-18 15:49:41.278 (Dummy-2) CHIP_DETAIL [chip.native.DIS] SRV record already actively processed.
2024-07-18 15:49:41.279 (Dummy-2) CHIP_DETAIL [chip.native.DIS] SRV record already actively processed.
2024-07-18 15:50:02.769 (Dummy-2) CHIP_ERROR [chip.native.CTL] Discovery timed out
2024-07-18 15:50:02.770 (Dummy-2) CHIP_DETAIL [chip.native.CTL] Stopping commissioning discovery over DNS-SD
2024-07-18 15:50:02.771 (Dummy-2) CHIP_ERROR [chip.native.ZCL] Secure Pairing Failed
2024-07-18 15:50:02.772 (Dummy-2) WARNING [root] Failed to establish secure session to device: src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp:89: CHIP Error 0x00000003: Incorrect state
2024-07-18 15:50:02.773 (MainThread) ERROR [matter_server.server.client_handler] [547540204304] Error while handling: commission_with_code: Commission with code failed for node 10.

Seems none of the matter devices (aqara) work, tried with aqara p2 matter door sensor as well. Better logs are needed.

marcelveldt commented 1 month ago

So, you turned on pairing mode and then copied the code to Home Assistant ? Note that you can only use the QR cod eon the device once (the initial pair to the first controller).

Please also read all our documentation about Matter, especially the part about networking requirments:

marcelveldt commented 1 month ago

Looking at the initial post, @NdR91 is running Home Assistant Container, which is not supported. I'm sorry but I can't help you. Please install the full Home Assistant OS (in a VM maybe for test) and see if you can reproduce the same issue. Thanks

ernst77 commented 1 month ago

So, you turned on pairing mode and then copied the code to Home Assistant ? Note that you can only use the QR cod eon the device once (the initial pair to the first controller).

Please also read all our documentation about Matter, especially the part about networking requirments:

  • Only Home Assistant OS is supported, so HA Container/Core are not supported. It may work if you manually patch your OS but without support from us.
  • enable IPv6 within Home Assistant OS
  • Flat network, no multicast filtering, mdns formwarders etc.

IPv6 was the issue THANK YOU. Somehow I missed that (I have multiple networks, maybe that's why). It works now. I guess there are so many things needed for matter it will cause a lot of issues in the future, there should be some checklist on add-on to check if all of the things are enabled. (like ipv6, OS'es, thread routers and etc...)

NdR91 commented 1 month ago

Looking at the initial post, @NdR91 is running Home Assistant Container, which is not supported. I'm sorry but I can't help you. Please install the full Home Assistant OS (in a VM maybe for test) and see if you can reproduce the same issue. Thanks

I'm coming back here after some tests and I have to admit that the issue was in my environment.

Currently I'm working on an Open Media Vault OS (which is basically a Debian Fork). Until today I never noticed great differences cause I'm using only docker for my stuff.

Just for your info (maybe this will help someone) those were my tests:

  1. First of all I installed HAOS on a RPi4 which wasn't in use. This worked immediately as HAOS comes with Matter already up and running.

So at this point: my local network was working fine (Matter over thread was working correctly on Alexa and Homekit) and HA OS was working too.

  1. Now we are arriving to the solution (My -unsupported- solution). Why I'm saying this: at the moment i prefer to go with the HA Container solution. Having a spare RPi4 i installed a Raspberry Pi OS, Docker and only the python-matter-server container.

Sure: this isn't a great solution if someone has to buy a brand-new device only for a single container. Probably a better Linux user has enough expertise to fix the networking stuff on OMV to get it working, but it isn't my case :)

Hope this will help someone.

marcelveldt commented 1 month ago

Thanks for reporting back @NdR91 as that will also help others running into this.

To give a bit more context: We have put a lot of effort in tweaking Home Assistant OS to make it work correctly with Matter and especially Thread. Those (kernel) patches are absent on NAS distributions and the reason why we only officially support Home Assistant OS for Matter. You might get it to support if you can manually patch your OS but in case of OpenMediaVault (or any other NAS distro) you don't have control over that, some of them even have ancient kernels.

So, using a NAS distro is pointless for Matter. Unless you have the option to run a VM in your NAS with bridged network. That would probably work (as long as the host network stack is bypassed).