Openthread border router support

Does the thread addon support the official open thread border router build? I compiled from source and have a working OTBR but it appears that the home assistant addon is calling an API that doesn’t exist.

aiohttp.client_exceptions.ClientResponseError: 404, message=‘Not Found’, url=URL(‘http://otbr1:8081/node/dataset/active’)

The API does work but dataset seems to be missing.

http://otbr1:8081/node returns the following

{
	"State":	4,
	"NumOfRouter":	1,
	"RlocAddress":	"fd99:740b:4cbe:5bd8:0:ff:fe00:e800",
	"ExtAddress":	"3251CA60B3EAC49D",
	"NetworkName":	"*********",
	"Rloc16":	59392,
	"LeaderData":	{
		"PartitionId":	627524093,
		"Weighting":	64,
		"DataVersion":	84,
		"StableDataVersion":	32,
		"LeaderRouterId":	58
	},
	"ExtPanId":	"111111110000A107"
}

built from GitHub - openthread/ot-br-posix: OpenThread Border Router, a Thread border router for POSIX-based platforms.

2 Likes

As far as I know, it should work fine after the official release of 2023.3 on Wednesday.

Thanks! I’ll try again on Wednesday after the update.

No change after the update. I searched the Git repository for that API and didn’t see anything that standed out. It seems like maybe my OTBR build is missing something? Any ideas?

It looks like this is implemented in Agners’ fork. I can’t get it to run though because my RCP firmware is too new.

Mar  3 15:11:12 otbr1 otbr-agent[1486]: 49d.17:10:22.187 [C] Platform------: RCP API Version 8 is not in the supported range [4-6]

I’m also trying to get this working. Any tips would be appreciated!

Agners replied on another git thread and is working on it. He said a week maybe? I’ll post back here when I get it working.

1 Like

Ah, I see the PR now. I’ll keep tabs on it and try my hand as well

Hello,

I have my Pi up and running, what do I put in for the URL in the Open Thread Border Router?

The IP address is not working. I am using the Silicon Labs docker image.

I am not using the Silicon Labs docker image but their uic-* packages, so I assume that their status is the same. Take my confident statements with a grain of salt:

The otbr provided by Silicon Labs does not support the /node/dataset/active endpoint that Home Assistant expects. The first thing that Home Assistant tries to do (as @Joe_Saiko already explained) is a request to /node/dataset/active and that fails.

If it worked, then you should use the IP and the port. The default port for the otbr-agent REST API is 8081. It is not very well documented, but you can see it yourself by doing a sudo netstat -apn | grep otbr (btw never run sudo commands from strangers without understanding them).

It may seem obvious, but, what otbr software would I need to use? I am currently using the Silicon Labs Unify package (the uic-otbr). Should I migrate to something if I want to make things work?

Do I need to have border router support in Home Assistant? It is required for Matter? But, that is a requirement for the onboarding process only? Or it is required for regular operation?

It confuses me that the Thread integration does detect the “OpenThreadDemo” network, but I don’t know what this implies.

I was curious so spent a little bit of time trying to figure this out as well…
If one looks at the Dockerfile for the Multiprotocol Add-On:

  • It appears that the Thread stack and the OTBR code that the Add-On uses come from the SiLabs Gecko SDK (Currently at 4.2.2),
  • Gecko SDK contains forked versions of the official openthread/otbr source code. It appears these forked versions are a few months old (looks like they have not updated these since Gecko SDK version 4.2.0).
  • Agner has contributed to the official openthread/OTBR source with a few REST API changes. It appears the SiLab’s forked versions are too old to have picked up these REST API changes.
  • The Add-On applies several patches to these older SiLabs forked versions. And one of these patches picks up Agner’s REST API changes (note the number 1658 corresponds to the official otbr pull request from Agner).

Hope this helps.

@wmaker thanks a lot for gathering that information. That’s an awesome explanation!

Just to spell it out, to check that I understood correctly, and for future reference: Agner PR is already merged and is needed by Home Assistant. My scenario should be automatically solved as soon as SiLabs updates the Gecko SDK (more precisely, the OTBR forked version).

Merged - Yes it has been merged into the “main” branch of Openthread.
Needed - The best I can tell, is that these REST API changes are needed as a way to import and export Thread network datasets across multiple Thread networks. Not all Thread BRs support these APIs, but an HA OTBR is expected get its dataset over this API, so yes.

Since you are using Unify, it may be different, but from what I can tell here (this was updated just recently), it is using the GeckoSDK and the same version (4.2.2) as the Add-On.

1 Like

I just rebuilt off the latest git and still getting 404 errors on the API.

    4 0.000599830  172.20.4.49 → 172.20.4.65  HTTP 236 GET //node/dataset/active HTTP/1.1
    5 0.000716872  172.20.4.65 → 172.20.4.49  TCP 66 8081 → 37712 [ACK] Seq=1 Ack=171 Win=65024 Len=0 TSval=4223390037 TSecr=3445202110
    6 0.001092673  172.20.4.65 → 172.20.4.49  HTTP/JSON 455 HTTP/1.1 404 Not Found , JavaScript Object Notation (application/json)

After further review of @agners PR, it looks like the API was changed to “/node/active-dataset-tlvs” for the code that was merged. The HomeAssistant integration likely needs to be updated to reflect this.

There are several iterations around of the patchset, the ones which works with current Home Assistant Core can be found in the add-on:

I am working on upstreaming the change, so it will eventually land in vanilla OTBR. However, from first reviews I already know that it will be incompatible with the current implementation.

2 Likes

@agners: Let me tell you that I appreciate a lot that not only you contributed to the openthread/ot-br-posix main repository, but you are following it up.

I know it’s a chore, so here’s a thank you emoji for you: :love_you_gesture:

1 Like

I echo that thanks!! Also thanks for the pointer to the patchset, @agners. That was the key for me.

For those who are running a standalone OTBR and are too impatient to wait for Agners’ PR to be merged upstream (like me), you can simply apply the patchset manually to get this working:

git clone --depth=1 https://github.com/openthread/ot-br-posix.git
cd ot-br-posix
curl -s https://raw.githubusercontent.com/home-assistant/addons/master/openthread_border_router/0001-Avoid-writing-to-system-console.patch | git apply
curl -s https://raw.githubusercontent.com/home-assistant/addons/master/openthread_border_router/0001-rest-implement-REST-API-to-get-dataset.patch | git apply
curl -s https://raw.githubusercontent.com/home-assistant/addons/master/openthread_border_router/0002-rest-support-state-change.patch | git apply
git diff --name-status
# Then proceed with normal installation steps for your platform. For example:
./script/bootstrap
INFRA_IF_NAME=wlan0 ./script/setup

After this the dataset API should be working (try http:<otbr ip/host>:8081/node/dataset/active to test), and you should be able to add it to Home Assistant (enter http:<otbr ip/host>:8081 as the URL to the OTBR API).

A word of caution: I imagine this is very likely to break during a future upgrade given the differences between the patched API and what will eventually be merged as @Joe_Saiko called out.

Excited to play around with this!

1 Like

Thanks @agners for all that you do!

Thank you for that write up @bdunn44. It was pretty much cut, paste, and go. I am going to mark it as the solution so folks will have an easier time finding it.