Thread border router on NixOS

I bought one of the HomeAssistant Connect ZBT-1 dongles a while ago, hoping to run a Thread border router on NixOS. I was disappointed to find out that this dongle is rather complicated to setup for Thread use, and has upstream support only when running the HomeAssistant OS.

I have some partial progress towards making this work. This is going to take a lot more refinement for a nice nix package and module. I wanted to share what I have working for anyone else who wants to hack on this.

To start hacking:

  1. Enable avahi on your server, probably with IPv6
{
  services.avahi = {
    enable = true;
    ipv4 = true;
    ipv6 = true;
    nssmdns4 = true;
    nssmdns6 = true;
    publish = {
      enable = true;
      userServices = true;
    };
    allowInterfaces = ["br0"]; # CHANGEME
  };
}
  1. Add “matter”, “thread”, and “otbr” modules to services.home-assistant.extraComponents.
  2. Build otbr from my branch: ot-br: init at unstable-2024-12-22 ¡ newAM/nixpkgs@5ab846d ¡ GitHub
  3. Run otbr-agent, something similar to this, substituting br0 with your network inface that has IPv6, and substituting the skyconnect dongle path. You need to have port 8081 free for this. This port seems to be hard-coded in few places.
sudo result/bin/otbr-agent -I wpan0 -B br0 --rest-listen-address "::" -d7 -v 'spinel+hdlc+uart:///dev/serial/by-id/usb-Nabu_Casa_SkyConnect_v1.0_fffff-if00-port0?uart-baudrate=460800' trel://br0
  1. Start otbr-web, smilar to:
sudo result/bin/otbr-web -p 1111 -d6 -s -I wpan0
  1. Go into the otbr webui, form a network. If you do not form a network home-assistant will fail to initialize the otbr addon with the error “Invalid dataset”
  2. Go into home-assistant, add the open thread border router device at http://127.0.0.1:8081
  3. In home-assistant Thread integration “OpenThreadDemo” will appear. Make this your preferred network.

There’s a lot more work to be done before this will be ready:

I’m curious if anyone else is working on running a Thread border router in NixOS, or if you have suggestions for a better open hardware/software stack.

Happy hacking!

2 Likes

Isn’t python-matter-server already packaged and made into a service?

Also, it looks like someone else already made a pr that handles creating the systemd unit:

you may want to look there.

I think the Thread home-assistant integration only creates/deletes the active dataset (thread lingo for the network configuration). When I did my setup, I just created the network with openthread-border-router and then chose the “Add dataset from TLV” menu item inside the home-assistant Thread integration. This allows the HA mobile app to share it with iOS and I could then provision thread devices to join the network from their 3rd party app.

Once the networks are bridged Matter will use SRP/mDNS and doesn’t need to change any Thread-level settings.

You can use ot-ctl to create a dataset and start the router, then get your TLVs with ot-ctl dataset active -x

1 Like

Oh, I missed that!

I started looking into this back in June 2024 and got sidetracked with a different project. I made the mistake of not checking nixpkgs again when I got back to it, thanks for the pointer!

@newAM did you have any success getting the correct (RCP) firmware installed on the device?

Yes, I don’t recall how I did it though.
I checked my shell history but it didn’t go that far back.