Container + ZBT-2: No border routers were found

I’ve been trying to use ZBT-2 with HA container for a few days now and I’ve been unable to make it work.
I started with this guide: Connect ZBT-2 Thread to Home Assistant Container

With the official image I never got the border router to appear on the Thread settings page. I then swapped to the hass-otbr-docker image, with which the border router does appear, but it disappears after a couple of minutes.

I tried repeatedly to sync the credentials, which says that it successfully synced, and send them to HA on the thread page, where it says that there are no credentials to import.

Things I found:

  • When I restart the border router container, the border router reappears.
  • With both images it can still access OTBR, because I can e.g. reset the network via the Thread page.
  • I turned on logs for OTBR and Thread integrations. It seems to only create debug logs for when the UI is used, nothing in the background. When I am able to see the border router (by restarting OTBR or resetting the network), I get the following debug message: [homeassistant.components.thread.discovery] Failed to decode state bitmap in service AsyncServiceInfo(type='_meshcop._udp.local.', name='Home Assistant OpenThread Border Router #055F._meshcop._udp.local.', ...

I tried most suggestions in the linked article and more, including:

  • Making all containers privileged
  • Enabling forwarding etc. in sysctl.conf (which does the same as running the setup-host.sh script afaict)
  • Reflashing firmware, also trying a significantly older version

My host device is a Fedora, but I have disabled SELinux for now.
Only thing I can think of is that is does not have a WIFI or Bluetooth module, but I don’t think that’s needed?

Here is my docker compose:

services:
  openthread:
    container_name: openthread
    image: "ghcr.io/ownbee/hass-otbr-docker:latest"
    network_mode: host
    restart: unless-stopped
    volumes:
      - /home/homeassistant/openthread:/data/thread
    devices:
      - /dev/serial/by-id/<my-device>:/dev/ttyACM0
      - /dev/net/tun:/dev/net/tun
    environment:
      DEVICE: "/dev/ttyACM0"
      BACKBONE_IF: enp3s0
      FLOW_CONTROL: 1
      FIREWALL: 1
      NAT64: 1
      BAUDRATE: 460800
      OTBR_REST_PORT: 8981
      OTBR_WEB_PORT: 8980
      OT_LOG_LEVEL: error
      AUTOFLASH_FIRMWARE: 0
    cap_add:
      - NET_ADMIN
  matter:
    container_name: matter-server
    image: "ghcr.io/matter-js/python-matter-server:stable"
    network_mode: host
    restart: unless-stopped
    volumes:
      - /home/homeassistant/matter:/data
    security_opt:
      - apparmor:unconfined
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /home/homeassistant/homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    network_mode: host
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0

It would be greatly appreciated if anyone could give me a hand in this :slight_smile:

Not clear from your description whether the OTBR is staying up and the Thread Integration is able to talk to it in a stable manner. If not, then for sure that needs to be resolved first.

If it is stable, then in the Thread Integration, the OTBR needs to be the “Preferred” network and then you’ll need to click on the 3-dots for that entry and set it to (something like) “use for ios/android credentials”; then you can try to sync/send the credentials to the companion/app.

OTBR does not say anything about going down. The OTBR web interface also stays up and the API is accessible, because I can reset the network via HA and I can see the changes in the web interface.
It’s almost as if HA can send but not receive.

I did set it as preferred and selected it for iOS/Android credentials, I forgot to mention this.

Ok, then you should see a “key in phone” icon. Just to make sure of something else, click on the entry’s (i) to make sure there is indeed has an “active dataset tlv” showing a big long string of hex digits. This is the main data of interest for sending to the phone.

if this looks OK, then walk through the steps in more detail with your HA Companion App (I assume Android based, and would be helpful to know if you are using a regular Android OS), then per the docs:

  • To share the credentials with your Android phone, open the Home Assistant Companion app.
    • In the Companion app, go to Settings > Companion app > Troubleshooting, then select Sync Thread credentials.
    • Follow the instructions on screen.
    • Result: You will see a confirmation stating that Thread credentials from Home Assistant have been added to this device.

There has been a known bug in Android where the confirmation is not necessarily correct, which recommends repeating the syncing again, and if you get a confirmation twice in a row, then it actually worked. If you still get the “no credentials to import”, then honestly I have no clues as this should just work.

There is a TLV.

I get the message that the credentials got updated every time I try to sync, whereas the original post says that I should receive a message “HA and this device use the same network”.
After that, sending takes a long time and answers with “You don’t have any credentials to import”.

I assume I am supposed to sync/send when I can still see the router, but syncing takes so long that it disappears before I can send…