Matterbridge + OpenThread => how to commission Matter devices over Thread

Hi Olivier, and welcome! :waving_hand:

Great job on the OTBR work, your repository is very well documented :clap:

To be transparent with you: for now, this kind of setup (a home OTBR, with manual commissioning) is not really managed in Gladys. What we recommend today is an external Thread Border Router that handles Bluetooth pairing itself (Apple TV / HomePod, Google Nest, or the IKEA DIRIGERA hub since your devices are IKEA), and then shares the devices with Gladys. I show the whole process in this video: https://youtu.be/WqiGv9O018g

That said, managing an OTBR directly from Gladys is part of our plans :slightly_smiling_face:

In the meantime, your diagnosis is correct. If you want to continue with your OTBR, here are some leads.

1. Matterbridge is not useful here

In Gladys, the Matter controller is the Matter integration (Integrations → Matter). Matterbridge does the opposite: it exposes non-Matter devices as Matter, thanks to its plugins, so that they can then be added to Gladys. It cannot commission your IKEA devices. You can disable it if you don’t use it for anything else.

2. What Gladys can do today

Gladys commissions only by IP: it does not perform the Bluetooth step, and therefore does not transmit the Thread identifiers to the device. For a new Thread device, two steps are therefore required:

  1. A first controller performs the Bluetooth pairing and makes the device join your Thread network.
  2. This controller opens a pairing window (the “Matter” share, or multi-admin) and gives you a new code, which you enter in Gladys.

Small correction on what Mistral told you: chip-tool is not really “the path used by the Gladys community”. It is feasible, but we are clearly off the beaten track. @prohand has paved the way here: Mise en place openthread avec la clé SLZB-MR01
He paired a device on his OTBR with chip-tool, then added it to Gladys once Matter.js was updated. Gladys is now on Matter.js 0.17, so that block no longer exists.

3. If you want to try with chip-tool

Beware, this is not an official Gladys procedure. On your Pi (the built-in Bluetooth of the Pi 4 is sufficient):

sudo apt install snapd bluez
sudo snap install chip-tool
sudo snap connect chip-tool:bluez
sudo snap connect chip-tool:avahi-observe
sudo snap connect chip-tool:process-control

Retrieve your OTBR dataset:

sudo docker exec otbr ot-ctl dataset active -x

Then, one device at a time (in pairing mode, near the Pi), with a different node-id each time (1, 2, 3, 4):

sudo chip-tool pairing code-thread 1 hex:<DATASET> <CODE> --storage-directory /var/snap/chip-tool/common
  • <CODE> is the 11-digit code printed under the QR code, or the content of the QR code (MT:...).
  • Don’t forget the hex: before the dataset: that’s what was blocking @prohand.
  • If you get an error Failed Device Attestation / Unable to find PAA, add --bypass-attestation-verifier true. This disables the verification that the device is a certified product, which remains acceptable at home.

Once the device is visible in your OTBR topology, open a pairing window for Gladys:

sudo chip-tool pairing open-commissioning-window 1 1 300 1000 3840 --storage-directory /var/snap/chip-tool/common

chip-tool then displays a Manual pairing code: [xxxxxxxxxxx]. You have 5 minutes (300 s) to enter it in Gladys → Integrations → Matter → « Add a device ».

4. A few points of attention

  • chip-tool storage: by default, it is in /tmp and does not survive a reboot. That’s why I added --storage-directory, to keep identical for all commands. This storage is only used to reopen a pairing window later without resetting the device. After a factory reset, it is useless: the device forgets everything, and you simply repeat the two steps. What you really need to keep precious is the OTBR dataset (/opt/otbr/data).
  • BILRESA remotes: they are battery-powered and go to sleep. Press a button to wake them up just before each command, and during the addition in Gladys.
  • The network: Gladys must be able to reach the device in IPv6. As your OTBR runs on the same Pi in network_mode: host, it should work directly. If Gladys does not find the device, check during the pairing window that avahi-browse -rt _matterc._udp sees it well, and that you can ping it in IPv6 from the Pi. The « Settings » tab of the Matter integration also tells you if an IPv6 interface is detected.
  • Bluetooth: if another integration uses the Pi’s Bluetooth continuously, turn it off during pairings.

5. An alternative with a web interface

If you prefer to avoid the command line, @prohand also used matterjs-server (see his message here: Mise en place openthread avec la clé SLZB-MR01 - #24 by prohand). Its web interface has a « Commission new Thread device » button that asks for the code and the dataset, then it generates a sharing code for you to enter in Gladys. It is based on Matter.js, the same library as Gladys.

If you get stuck, send us the output of chip-tool and the Gladys logs at the time of addition. And if you make it to the end, a small tutorial on the forum would help a lot of people :grinning_face_with_smiling_eyes: