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.
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?
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.
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).
@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.
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.
@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:
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.
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.