Jump to content

Openthread: Difference between revisions

From Official NixOS Wiki
Jeantil (talk | contribs)
No edit summary
Jeantil (talk | contribs)
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:
[https://openthread.io/ Openthread] is an open source implementation of the [https://threadgroup.org/What-is-Thread/Overview Thread] IOT networking  specification.  
[https://openthread.io/ Openthread] is an open source implementation of the [https://threadgroup.org/What-is-Thread/Overview Thread] IOT networking  specification.  


This implementation provides an openthread border router server and a small webui to monitor it. It can be used to setup a thread network on your server if it is equiped with a Thread radio device.  
This implementation provides an openthread border router server and a small webui to monitor it. It can be used to setup a thread network on your server if it is equiped with a Thread radio device. The border router allows for routing IPv6 communication between a classic wifi or ethernet network and a Thread network.  


Popular Thread radio devices include Home assistant's connect ZBT-2 and SONOFF Zigbee 3.0 USB dongles among many other.  
Popular Thread radio devices include Home assistant's connect ZBT-2 and SONOFF Zigbee 3.0 USB dongles among many other.  
Line 8: Line 8:
Once your thread network is established, you can use the Matter IOT standard to control various home automation devices adhering to the standard.   
Once your thread network is established, you can use the Matter IOT standard to control various home automation devices adhering to the standard.   


The most likely configuration for nixos users will  be to use openthread in combination with the [[Home Assistant]] module and the [[Matter Server]] module.   
The most likely configuration for NixOS users will  be to use openthread in combination with the [[Home Assistant]] module and the [[Matter Server]] module.   


=== Basic Setup ===
=== Basic Setup ===
Make sure you have the required radio USB device connected to your server and note its device path which should look something like  <syntaxhighlight lang="shell">
Make sure you have the required radio USB device connected to your server and note its device path which should look something like  <syntaxhighlight lang="shell">
/dev/serial/by-id/usb-Nabu_Casa_ZBT-2_xxxxxxxxx_ifxx
/dev/serial/by-id/usb-Nabu_Casa_ZBT-2_xxxxxxxxx_ifxx
// OR
# or
/dev/serial/by-id/usb-Itead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_V2_xxxxxxxxxxxxxxxxxxxxx-ifxx-portx
/dev/serial/by-id/usb-Itead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_V2_xxxxxxxxxxxxxxxxxxxxx-ifxx-portx
</syntaxhighlight>of course these are merely examples for specific devices but you will want to use the by-id path to ensure it remains stable across configurations.
</syntaxhighlight>of course these are merely examples for specific devices but you will want to use the by-id path to ensure it remains stable across reboots and multiple device configurations.  


Then you can enable the open thread border router service in nixos using    
Then you can enable the open thread border router service in NixOS  <syntaxhighlight lang="nixos">
    openthread-border-router = {
      enable = true;
      backboneInterface = "eno1";
      # logLevel = "notice"; controls the log levels
      radio = {
        device = "/dev/serial/by-id/usb-Nabu_Casa_ZBT-2_xxxxxxxxxxx-if00";
        baudRate = 460800;   # This and flow control are hardware dependant
        flowControl = false; # check your device's documentation
      };
      rest = {
        # listenAddress = "::"; # Defaults to 127.0.0.1


 
        # It is recommended to use port 8081 as some web UI features do not work
        # with a different port
        # listenPort = 8081;
     
      };
      web = {
        enable = true; # enables the basic web interface


    
        # listenAddress = "::"; # defaults to 127.0.0.1
        # listenPort = 58082;   # this port can be altered freely
      };     
    };
</syntaxhighlight>once the service is started you should be able to access the web ui
[[File:Openthread_border_router_web_ui.png|center|frameless|938x938px]]
You can use the UI to form your own network or join an existing network provided you have the credentials for it. The module also installs the <code>ot-ctl</code> CLI tool which can achieve the same actions and allows for a deeper inspection of the thread network and routing tables 


 
Once you have formed or joined a Thread network, you should have a basic setup up and running. However at this point there is little you can do with it.


=== Integrating with Home Assistant ===
Having a thread border router by itself it not all that useful except for the most hard core power users. You will most likely want to use this network to communicate with Thread/Matter devices.  To do so the easiest option is to integrate both Thread and Matter components with [[Home Assistant]].
You will need to ensure that you have configured the relevant home assistant addons (see the [[Home Assistant]] page for a more complete configuration example)<syntaxhighlight lang="nixos">
  services = {
    home-assistant = {
      enable = true;
      extraComponents = [       
        #...
        # Components required to operate a matter-over-thread
        # network with home-assistant
        "matter"
        "otbr"
        "thread"
        #...
      ];
    }
  }
</syntaxhighlight>And you will need to enable the [[Matter Server]] module.
[[File:Home_assistant_thread_large.png|center|frameless|891x891px]]
Once restarted, home assistant should detect the Open thread border router, the corresponding Thread network and the matter server automatically and propose to add them as integrations.
At this point you should be ready to commission your first device.
[[Category:Software]]
[[Category:Software]]
[[Category:Applications]]
[[Category:Applications]]

Latest revision as of 05:41, 21 April 2026

Openthread

Openthread is an open source implementation of the Thread IOT networking specification.

This implementation provides an openthread border router server and a small webui to monitor it. It can be used to setup a thread network on your server if it is equiped with a Thread radio device. The border router allows for routing IPv6 communication between a classic wifi or ethernet network and a Thread network.

Popular Thread radio devices include Home assistant's connect ZBT-2 and SONOFF Zigbee 3.0 USB dongles among many other.

Once your thread network is established, you can use the Matter IOT standard to control various home automation devices adhering to the standard.

The most likely configuration for NixOS users will be to use openthread in combination with the Home Assistant module and the Matter Server module.

Basic Setup

Make sure you have the required radio USB device connected to your server and note its device path which should look something like

/dev/serial/by-id/usb-Nabu_Casa_ZBT-2_xxxxxxxxx_ifxx
# or
/dev/serial/by-id/usb-Itead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_V2_xxxxxxxxxxxxxxxxxxxxx-ifxx-portx

of course these are merely examples for specific devices but you will want to use the by-id path to ensure it remains stable across reboots and multiple device configurations. Then you can enable the open thread border router service in NixOS

    openthread-border-router = {
      enable = true;
      backboneInterface = "eno1";
      # logLevel = "notice"; controls the log levels
      radio = { 
        device = "/dev/serial/by-id/usb-Nabu_Casa_ZBT-2_xxxxxxxxxxx-if00";
        baudRate = 460800;   # This and flow control are hardware dependant
        flowControl = false; # check your device's documentation
      };
      rest = {
        # listenAddress = "::"; # Defaults to 127.0.0.1

        # It is recommended to use port 8081 as some web UI features do not work 
        # with a different port 
        # listenPort = 8081;
       
      };
      web = {
        enable = true; # enables the basic web interface 

        # listenAddress = "::"; # defaults to 127.0.0.1
        # listenPort = 58082;   # this port can be altered freely
      };      
    };

once the service is started you should be able to access the web ui

You can use the UI to form your own network or join an existing network provided you have the credentials for it. The module also installs the ot-ctl CLI tool which can achieve the same actions and allows for a deeper inspection of the thread network and routing tables

Once you have formed or joined a Thread network, you should have a basic setup up and running. However at this point there is little you can do with it.

Integrating with Home Assistant

Having a thread border router by itself it not all that useful except for the most hard core power users. You will most likely want to use this network to communicate with Thread/Matter devices. To do so the easiest option is to integrate both Thread and Matter components with Home Assistant.

You will need to ensure that you have configured the relevant home assistant addons (see the Home Assistant page for a more complete configuration example)

  services = {
    home-assistant = {
      enable = true;
      extraComponents = [        
        #...
        # Components required to operate a matter-over-thread 
        # network with home-assistant
        "matter"
        "otbr"
        "thread"
        #...
      ];
    }
  }

And you will need to enable the Matter Server module.

Once restarted, home assistant should detect the Open thread border router, the corresponding Thread network and the matter server automatically and propose to add them as integrations.

At this point you should be ready to commission your first device.