Comissioning Matter over Thread devices?

I’m having difficulty adding Matter over Thread devices. Sometimes it works perfectly in a couple of minutes, sometimes it can take more than an hour - repeated attempts and re-pairing.
Bare metal HAOS, ZBT-2 Border Router, mostly Ikea devices, adding via the ifficial Matter integration as “new device” (factory reset between attempts), Android companion app.

When it works, I get the various steps:

Add new device
Scan QR code
Connecting to device
Generating Matter Credentials
Checking connectivity to Thread network
Light flashes several times
Connecting to Home Assistant
Light flashes several times
Done

When it fails, I get a single flash, then it sits at “checking connectivity”, and fails with “can’t reach device, check you have phone wifi”, or just “try again”

Without changing anything, just resetting the device and doing it again, eventually it will work.

I’ve tried looking for exactly what “connections” are needed for the device, HA, and mobile device so that I can pin down what’s going wrong:

Do I need bluetooth between the device and the Android tablet?
What wifi connection is it complaining about when it fails?
Do the device and the Android tablet have to be close to the HA Border Router, or just within range of any Thread router device?

I’ve got a Deco Mesh wifi, which is both 2.4 and 5GHz (same SSID), and the router’s own WI-FI which is a different SSID - used as a fall-back during power cuts (router is on a UPS).
Android device is on the Mesh wifi, HA is obviously on ethernet.
Does the un-paired Thread device even need wifi? I thought the commisioning was initiated by Bluetooth?

Not sure if this wifi stuff is relevant, as sometimes the orocess works fine

Is wifi6 addressing enabled on the local network?

If its a case of sometimes it works, sometimes it doesn’t and nothing else has changed with the network, phone, Thread credentials, then about the only thing that I can think of is IGMP/MLD Snooping is turned on.

Anyway, what is happening, is that the Android device has handed the Thread credentials to the Matter/Thread device (via Bluetooth) and is now waiting for mDNS advertisements to show up on the LAN advertising that the device is now commissionable, but the Android is not seeing these advertisements.

I had to google what IGMP/MLD snooping was.
Am I correct in thinking that this is only used in network switches?

I’ve got two fairly basic TP Link switches that have IGMP snooping turned on.
No mention of MLD snooping that I can see.

However, my HA PC is connected directly to my BT Hub Router, as is the main Deco Mesh device, so anything set on the network switches shouldn’t affect what happens while adding a Matter device?

I suppose I could try connecting my Android device to the Router’s onboard wifi, rather than the Mesh wifi?

Yes its a Layer-2 function which is mostly implemented in Ethernet Switches.
MLD is just the IPv6 version of IGMP. If your phone used for commissioning is on a WiFi networks that ends up with packets going through an Ethernet Switch with snooping enabled, it could be a problem. The best thing to try would be simply to disable snooping. (Snooping may not actually be the problem, as its just a guess of mine as snooping sometimes goes through periods of allowing and then blocking multicast traffic and mDNS advertisements are multicasted)

I tried it by connecting my tablet to the router’s own wifi network (so no chance of going via my switches) and I still had the same issues.
I had a play around with where the device and tablet are placed relative to my HA PC and ZBT border router, and it seems like they all need to be within 2 metres of each other to work at the first or second attempt.
I appreciate that the tablet needs to be within bluetooth range of the device and have a good wifi signal, but does the device really need to be within touching distance of the border router?
If i try it with the device and the tablet close to each other, but in the next room from the PC (but close to an Ikea smart plug) it can take an hour to commission one device - multiple attempts and multiple factory resets.

Do companion app credentials “expire”?

I had another 6 Ikea ddvices to add yesterday, which took me over 3 hours of multiple device resets and swapping between Android tablet and iPhone.
Device and mobile device wer both within 3 feet of the ZBT-2.

I eventually discovered that if I went into the debug/troubleshooting section if the comoanion app and resynced credentials it would probaly work first time:

Resync
Add device using iPhone
Resync again
Add anither device using iPhone

This looks like it was being caused by my Apple TV repeatedly trying to join my HA Thread network. Fixed that, now commisioning works pretty much first time, and I don’t have to sit right next to the ZBT.
I guess devices were getting confused by the "rogue " Border Router?

I want to make some notes about your experience, so correct me here:

  • You are using HA’s OTBR/ZBT and it is intended to be the only TBR.
  • However there is an Apple TV also acting as a TBR but it is not being used for such.
  • With the iOS Companion App and HA’s OTBR Thread credentials on the iPhone, the companion app can pair Matter/Thread devices, but it may take a few or many many minutes to complete.
  • The next time another device was to be paired, the Thread credentials had to be re-synced.
  • However when unplugging the Apple TV, the pairing is consistent to just a few minutes and no re-syncing is needed.

[EDIT] I see you started another Thread on this (I recommend you keep it to a single Thread as it makes it hard to track). So along the way, your iPhone probably gave the Apple TV the Thread credentials for the HA OTBR and this allowed the Apple TV to join the HA Thread network. There are known issues with Apple TV TBRs and HA OTBR on the same Thread network in terms of which TBR is HA suppose to actually connect with.

Yes, your points sum up what was happening.

I’ll add though that the Apple TV was only showing intermittently in the Thread section “preferred network” panel, like it was trying to be part of the network and not becoming established.

I have now reset the ATV, and it has created its own Thread network, no longer shows at all in the “preferred network” panel.