zhub
A lightweight Zigbee gateway for Linux, designed to run on routers and other embedded
systems. It runs as a single Rust binary with a built-in web interface and uses
Ziggurat with an OpenThread RCP radio. MQTT with
Home Assistant discovery and the Matter bridge are optional.
Tested on Keenetic (MIPS). For other Linux hosts, build for your system and configure
the radio’s serial settings. See Build and install.
- Forms a network and keeps the network key, frame counters and stack tables in
/opt/var/lib/zhub/state.json.
- Interviews joining devices (ZDO), binds their clusters to the hub and configures
reporting.
- Lights: on/off, brightness, color temperature, startup and transition settings, and effects.
Compatible catalog profiles also support RGB, XY, and hue/saturation over MQTT,
including enhanced hue and combined brightness and color commands.
- Sensors: temperature, humidity, occupancy, IAS zones (contact, motion, water), battery.
- Remotes and switch modules: button presses become the
action value.
- Groups: lights in a Zigbee group take one multicast command (on/off, brightness,
color temperature, Identify); membership lives on the devices (Groups cluster).
- MQTT (optional), laid out like Zigbee2MQTT:
zigbee2mqtt/<name> state, …/set
commands (also state: ON/OFF/TOGGLE and brightness), …/action button presses,
bridge/state|devices|groups, and Home Assistant discovery (lights and groups as lights,
thermostats as climate, settings as number/select/switch, buttons as device triggers).
Live updates, including every button press, also stream over /api/events.
- Bindings: a device’s binding table can be read and edited (to the hub, a device or a
group), so e.g. a switch controls lights directly.
- View and change report intervals and thresholds for supported Zigbee
attributes. Requests for battery-powered devices can wait in a queue.
- Thermostats: SONOFF TRVZB (ZCL thermostat cluster) and Tuya thermostats (datapoints),
both with weekly schedules (the TRVZB takes a schedule but cannot report it, so the UI
shows what was saved from the hub).
- Hue lights can be factory reset by serial number (like the Hue Bridge).
- Network map: the hub and every router report their neighbor (and optionally routing)
tables; the UI draws the mesh with link quality, and MQTT answers Zigbee2MQTT’s
bridge/request/networkmap (raw, graphviz, plantuml).
- Web UI at
http://<router>:8099. Without a password anyone on the network can control
every device; like Zigbee2MQTT’s auth token, Settings → Web UI password protects the page
and its API (one password, remembered per browser; kept as a salted hash). A forgotten
password is removed by starting zhub once with --reset-ui-password. Do not expose the UI
to the internet.
- Settings page: hub and radio firmware info, network parameters, transmit power,
availability limits (cards show Offline), permit join duration, log level with a live
log viewer, restart, Hue reset.
- Values for sleepy devices are written at once and repeated until taken; ones still
waiting survive a restart (kept in the state file).
- Matter bridge (optional,
--features matter): lights, thermostats and temperature
sensors appear in Apple Home, Google Home or Home Assistant; a group can be shown as one
light. It uses the test vendor ID, so controllers treat it as uncertified.
Screenshots
| Devices |
Lights |
 |
 |
| Device details |
Groups |
 |
 |
zhub and Zigbee2MQTT
zhub follows Zigbee2MQTT’s device model and MQTT interface, but
is built for a smaller machine. Zigbee2MQTT is the mature choice with far wider device
support; zhub trades that for a footprint that fits on a router.
|
zhub |
Zigbee2MQTT |
| Runtime |
One static binary (Rust), no runtime to install |
Node.js (22 or later) application with npm dependencies |
| Size |
7.99 MB with the Matter bridge (static MIPS build) |
npm package 1.6 MB plus 19 dependencies and Node.js; Docker image about 48 MB compressed |
| Memory |
6.2 MB resident, 15 devices, with Matter (measured on the router) |
about 50–60 MB in one user’s report (Raspberry Pi 4, 21 devices) |
| Hardware |
Linux hosts, including embedded systems. Tested on Keenetic (MIPS 1004Kc, 256 MB RAM) |
Raspberry Pi, PC, NAS, Docker: anywhere Node.js runs |
| Zigbee stack |
Ziggurat on the host; the dongle is only a radio |
zigbee-herdsman; the stack runs on the adapter |
| Adapter firmware |
OpenThread RCP (Spinel) on Silicon Labs EFR32, e.g. SONOFF ZBDongle-E |
EmberZNet (Silicon Labs), Z-Stack (Texas Instruments), deCONZ (Dresden Elektronik); ZiGate, ZBOSS |
| Network data |
Kept by the host (state.json): reflashing or replacing the dongle needs no re-pairing |
Kept on the adapter; backup and restore when changing adapters |
| Supported devices |
2,237 profiles in the generated catalog build, including 2,145 automatically converted profiles and 92 maintained Tuya profiles. Zhub also includes built-in definitions and generic support for standard Zigbee clusters. |
Current Zigbee2MQTT device list |
| Web UI |
Built in |
Built in (separate frontend package) |
| MQTT |
Optional; Zigbee2MQTT topics, payloads and Home Assistant discovery |
Required; the main interface |
| Matter |
Built-in bridge (optional build feature) |
Not built in |
| Groups, scenes and bindings |
Yes |
Yes |
| Reporting configuration |
Yes, on supported Zigbee attributes |
Yes |
| OTA firmware updates |
Manual from the web UI or MQTT for compatible images in the Zigbee OTA index |
Yes |
| Network map |
Yes (web UI and MQTT: raw, Graphviz, PlantUML) |
Yes |
| Touchlink |
Hue factory reset by serial number |
Scan, identify and factory reset |
| UI password |
Yes (one password) |
Yes (auth token) |
| Maturity |
New; used in one home |
Mature, large community |
| License |
Apache-2.0 |
GPL-3.0 |
Web controls and MQTT bridge
Device details and group scenes use the same mobile dialog controls. The main
pages show their contents when the data is ready and offer Retry if loading
fails. The light cards show the latest brightness reported to zhub as a percentage.
Exposes shows that level in Zigbee units. Setting a nonzero brightness on a
light that is off turns it on at the requested level.
Identify appears on a group card when a member supports it. A compatible MQTT
client, such as Homey’s Zigbee2MQTT app, can send {"identify":"identify"} to
<base_topic>/<group-name>/set. Zhub sends one native Zigbee Identify command for
three seconds.
The MQTT base topic defaults to zigbee2mqtt. Homey’s bridge controls use
<base_topic>/bridge/request/permit_join to open or close joining and
<base_topic>/bridge/request/restart to request a Zhub restart. On Keenetic the
Entware service starts Zhub again. For other Linux hosts, run Zhub under a
supervisor that restarts it after a clean exit if you use this command.
MQTT uses one topic segment for each device or group name. Zhub replaces /,
+ and # with _. New names must be unique after that conversion. Rename any
existing duplicates so MQTT commands resolve to a single target.
Reporting
Open a device’s Reporting tab and select an attribute. The minimum interval limits
how often reports are sent. The maximum interval controls how long the device can go
without sending a report. For numeric attributes the change threshold is shown in the
attribute’s unit, such as °C or W. Supported attributes depend on the device and its
firmware.
During the initial interview, zhub tries to read the device’s settings before applying
its own defaults. Restore initial settings uses the values read at that point when
available. Restore defaults uses zhub’s device definition. For paired battery devices,
missing settings are read at the next wake-up. Pending changes also wait for the
device to respond. Confirmed settings are saved with device state and shown immediately
when the tab opens.
TS011F variants that use polling expose Measurement polling interval. The default
is 60 seconds and -1 disables periodic reads.
The MQTT bridge accepts Zigbee2MQTT-style bridge/request/device/reporting/read and
bridge/request/device/reporting/configure requests under the configured base topic.
The configure response includes data.pending: true when the change is queued for a
sleeping device. MQTT change thresholds use raw Zigbee attribute units.
Scenes
Lights with a Scenes server (0x0005) can keep their settings on the device.
Open a device’s Scenes tab (choose its endpoint and device/group scope), or
use Scenes on a group card. Store current state captures the lights as
they are without changing their output. Specify values and transition writes
only the supplied light attributes. A group may store different values and
transition times on each member; recalling it sends one group command.
The MQTT interface follows Zigbee2MQTT. Publish one operation per message to
zigbee2mqtt/<device-or-group-name>/set:
{"scene_store": {"ID": 1, "name": "Normal"}}
{"scene_add": {"ID": 2, "name": "Night", "state": "ON", "brightness": 38, "color_temp": 400, "transition": 0.2}}
{"scene_recall": 2}
{"scene_rename": {"ID": 2, "name": "Evening"}}
{"scene_remove": 2}
{"scene_remove_all": ""}
scene_store, scene_recall and scene_remove also accept a bare numeric ID.
The ID range is 0–255; ID 0 in device scope (group 0) is reserved. For a
multi-endpoint device, pass ep in the operation object. To modify just one
member’s entry in a group scene, send the operation to that device with
group_id and its endpoint. It must already be a member of that group.
For example:
{"scene_add": {"ID": 2, "group_id": 3, "ep": 11, "brightness": 80, "transition": 0.2}}
scene_add accepts state (ON/OFF), brightness (0–254), and either
color_temp (mireds, clamped to the light’s range) or color (#RRGGBB,
{"x":0.3,"y":0.3} or {"hue":180,"saturation":80}). Color temperature
is encoded as XY for compatibility with older scene servers, as in Z2M.
Integer transition times use Add Scene (seconds); fractional times use Enhanced
Add Scene (tenths of a second, rounded down, maximum 6553.4 seconds).
An unsupported Enhanced Add is reported as an error. Store Scene preserves the
existing scene’s transition. Saving the same ID replaces its previous settings.
Opening the scene list loads Zhub’s saved entries. Within the same browser tab,
reopening shows the last loaded list immediately while Zhub refreshes it. Use
Read from devices to query the lights and discover scenes, including scenes set
by another controller. Names and confirmed per-endpoint settings are kept in
zhub’s state file; MQTT bridge device/group lists include the known scene names.
Management commands check each device’s response. Partial group installations
are shown explicitly and cannot be recalled until every current member has
that scene. Retry the operation or read the device tables after an error.
Deleting scenes is scoped to the selected group and endpoint. Changing group
membership may leave a scene incomplete until saved on the new members.
For zauto, zhub also publishes a retained <base>/bridge/scenes array of
complete scene predictions (target, id, state, transition). This is a
zhub extension. Only attributes set on every group member are predicted;
brightness uses the group’s maximum and on/off uses any-on, matching group
state reporting. The payload is published on changes and on broker reconnect.
HTTP API (protected by the existing UI password):
GET /api/scenes?target=group%3A3 (or a device IEEE/name, optional ep and group_id).
POST /api/scenes/refresh with {"target":"group:3"}.
POST /api/scenes with {"target":"group:3","command":"scene_recall","value":2}.
This adds Zigbee scenes and MQTT/UI management. It does not expose scenes to
Matter controllers or change existing zauto rules automatically.
Architecture
Following Zigbee2MQTT: the hub knows no device types; devices are defined as data under
src/devices/.
- Definition: fingerprint (model or manufacturer name), vendor and description,
card layout, features, extra bindings, time base.
- Feature: key, label, description, kind (numeric/binary/enum/schedule), access,
where it shows in the UI, and its source (a ZCL attribute, a light command or a Tuya
datapoint). Decoding, writing and the UI schema all come from the same definition.
- Common building blocks (
devices/common.rs): features of the standard clusters;
devices without a definition get one built from the clusters they offer.
- Configuration (binding, reporting, reads) is derived from the features; writes to
sleepy devices are queued and performed when the device wakes up.
Adding a device: open its definition in Zigbee2MQTT (zigbee-herdsman-converters),
write the same information as a Definition in devices/<vendor>.rs and add it to the
list in devices/mod.rs. Feature labels and descriptions are taken from Zigbee2MQTT.
Defined devices: Philips Hue LTA005, LTA009, LWA017, RDM001/RDM004 (wall switch module), SONOFF SNZB-02D,
SNZB-02P, TRVZB, Tuya ZWT07 (_TZE200_g9a3awaj).
Hardware
SONOFF ZBDongle-E (“Zigbee 3.0 USB Dongle Plus V2”, EFR32MG21) with Nerivec’s OpenThread
RCP build sonoff_zbdonglee_openthread_rcp_2026.6.2_3.1.2_460800_sw_flow.gbl: 460800 baud,
XON/XOFF flow control (--baudrate 460800 --flow-control software; both must match the
firmware build). On Keenetic the “USB to Serial Port Converters” component must be
installed. The dongle is a USB 2.0 device; a USB 3 port only adds 2.4 GHz noise.
The Matter bridge announces itself through Avahi static service files in
/tmp/avahi/services. Configure Avahi to read that directory on the host.
Known issue: some sleepy devices (SONOFF TRVZB) cannot join the dongle directly with a
MAC association; pair them through a router (e.g. a Hue light). After that they can
rejoin the dongle directly.
Install OpenThread RCP from the web UI
If the configured serial port doesn’t answer as an OpenThread RCP at startup, open
Zhub’s web URL. The Dongle firmware screen identifies the attached USB model
and asks for an OpenThread RCP .gbl file for that model.
| Dongle |
Entering the bootloader |
| SONOFF ZBDongle-E, Dongle-PMG24, Dongle Lite MG21 (LMG21) |
Automatic |
| SMLIGHT SLZB-07, SLZB-07MG24 |
Hold FLSH to GND while reconnecting USB, following SMLIGHT’s instructions |
Some ZBDongle-E units use a shared USB identifier and may require model confirmation.
Zhub validates the image for the detected model, shows when the flash completes
and the dongle restarts, and opens its normal interface after the radio answers
over Spinel. It saves the image’s serial settings for subsequent starts.
The setup page can identify EmberZNet, Z-Stack, Spinel, Silicon Labs CPC and Gecko
bootloader responses on the configured serial port. Firmware upload requires a
supported dongle model.
Build and install
Linux
Build with cargo +nightly build --release. Add --features matter to include the
Matter bridge. Run target/release/zhub with the serial port, baud rate and flow
control for your OpenThread RCP firmware. Use --state to choose a writable location
for the network state file.
Startup configuration
Zhub loads /opt/etc/zhub.toml by default. Use --config /path/to/zhub.toml
to select a different file. If you supply --state and the default TOML
file is absent, Zhub uses zhub.toml beside the state file. Explicit startup
arguments override matching TOML values. For the log filter, RUST_LOG has
the highest priority. The included Entware service supplies defaults that
TOML can override. An older service script with explicit flags still takes
precedence for those fields.
# device = "/dev/ttyUSB0"
# baudrate = 460800
# flow_control = "software" # none, software, or hardware
# listen = "0.0.0.0:8099"
# state = "/opt/var/lib/zhub/state.json"
[log]
# file = "/opt/var/log/zhub.log"
# level = "info,ziggurat_driver=warn"
[ota]
block_delay_ms = 250
busy_block_delay_ms = 350
max_block_size = 50
idle_timeout_seconds = 600
The OTA idle timeout defaults to 10 minutes. Known slow OTA clients have
longer minimums: 30 minutes for Legrand, and 60 minutes for Robert Bosch GmbH
and SONOFF image type 8199. The transfer still has a four-hour session limit.
The web UI saves MQTT, Matter enablement, availability, permit-join duration,
the log filter, and OTA preferences to this TOML file. Web changes apply
immediately. For manual TOML edits, stop Zhub, edit the file, and start it
again. Adapter and listen settings apply at startup. Settings shows the
file path and active startup overrides. When the log filter has an override,
the log page displays it and disables the selector.
On upgrade, Zhub imports saved preferences into [settings] and [log].
The file can contain the MQTT password and is written owner-only. Zigbee
network and device state, web authentication, Matter pairing records, and
the installed radio’s UART configuration stay with the state files. The state
snapshot also carries compatible preferences for backup and rollback. Restoring
a backup restores these preferences without replacing the destination’s
adapter, web listen address, or OTA configuration.
Each block interval accepts 50–5000 ms. The effective busy interval is at
least as long as the normal interval. The default block size limit accepts
10–64 bytes, with device requests and manufacturer-specific limits still
applied. The inactivity timeout accepts 10–3600 seconds. The OTA transfer
timer starts with the first valid block request for sleepy devices.
Keenetic and Entware (MIPS)
./build.sh builds in Docker. ./build-native.sh builds on the host instead (Rust nightly
via rustup, zig 0.15.2 in .tools/); it is faster and is the one that fits the Matter build
(rs-matter needs more memory than Docker Desktop’s default VM gives).
./build.sh
cat target/mips-unknown-linux-musl/release/zhub | ssh -p 222 [email protected] 'cat > /opt/bin/zhub && chmod +x /opt/bin/zhub'
cat deploy/S99zhub | ssh -p 222 [email protected] 'cat > /opt/etc/init.d/S99zhub && chmod +x /opt/etc/init.d/S99zhub'
ssh -p 222 [email protected] /opt/etc/init.d/S99zhub restart
MQTT broker on the router (optional; Home Assistant or another automation platform connects
to it): Entware’s mosquitto-nossl (no TLS, ~110 KB) with deploy/mosquitto.conf, which
listens on the home network and localhost only and requires a password. This build stores
passwords in plain text, so the file is readable by the broker user only:
opkg install mosquitto-nossl
cat deploy/mosquitto.conf | ssh -p 222 [email protected] 'cat > /opt/etc/mosquitto/mosquitto.conf'
# on the router: one line per user, "name:password"
mkdir -p /opt/var/lib/mosquitto && chown nobody:nobody /opt/var/lib/mosquitto
umask 077; echo "zhub:<password>" > /opt/etc/mosquitto/passwd; chown nobody:nobody /opt/etc/mosquitto/passwd
/opt/etc/init.d/S80mosquitto restart
Then Settings → MQTT in zhub: broker 127.0.0.1, user zhub.
The bridge publishes a retained health snapshot on <base_topic>/bridge/health
when it connects and every 10 minutes. It includes Zigbee2MQTT-style system,
process, MQTT and device metrics, plus zhub’s radio timeouts and offline counts.
The service writes to /opt/var/log/zhub.log and keeps one previous file
(zhub.log.1), rotating at 1 MiB while it runs. Process exits and stderr go to
zhub.log.service. --sniff logs MAC command frames for diagnostics (the
radio does not acknowledge frames while sniffing; use it only briefly).
Backup and restore
In Settings → Backup & Restore, use Download backup to save a ZIP to your
computer. It contains the Zigbee network and device state, zhub settings, groups,
scene records, and Matter controller records when present. Keep this file private
because it contains network credentials.
To restore, select the ZIP to see its date and contents, then choose Restore backup.
Zhub saves the previous state before applying the backup during restart. The previous
archive is kept as .last-restore/before-restore.zip beside the state file. A Zigbee-only
ZIP can be restored with Matter disabled. If the destination has Matter disabled, a
restore leaves it disabled and keeps any Matter records included in the archive.
Built-in device profiles
The bundled SONOFF catalog covers the SNZB-02P and
SNZB-02D sensors and the TRVZB radiator valve. It includes feature descriptions,
measurements, calibration and reporting defaults. The TRVZB profile also defines
external sensor selection, valve settings, boost and timer modes, and weekly
schedule limits. Zhub reads these profiles directly from the binary.
Tuya device support
The Tuya profile catalog contains 92 profiles for
relays with up to 12 channels, environmental sensors, presence radars and
motion sensors with night lights. Zhub matches profiles by Zigbee model and
manufacturer identifier.
The catalog lists the exact identifiers and features for each profile.
Relay profiles include per-channel countdowns and power-on behavior where
the device exposes these settings.
The downloadable device catalog includes these 92 profiles. Existing stock
copies in device-profiles.json defer to the exact fingerprint in the
installed catalog and remain available when that fingerprint is missing,
including offline use and rollback. Edited profiles and other local
entries continue to take priority as custom overrides. Zhub preserves the
legacy file on disk.
Catalog mappings are derived from
Zigbee2MQTT definitions.
The latest simulation audit covered 174 Tuya profiles. Of these, 122 met
the Fully Supported criteria. The audit checks Exposes, converter behavior,
configuration, lifecycle events and OTA where applicable. Hardware testing
coverage varies by model.
Generated device catalogs
The audited catalog contains 2,237 profiles, including 2,145 automatically
converted Zigbee2MQTT profiles and 92 maintained Tuya profiles. Catalogs with
device-reported color temperature ranges require a Zhub build that advertises
the physical_color_temp_range_v1 capability. The generated CO₂ profiles use
the float_measurements_v1 capability to convert reports to ppm and preserve
floating-point reporting thresholds. Standard color profiles retain the active color
mode and merge split X/Y reports. Matching white-label fingerprints can change
the display model and vendor while keeping the original Zigbee identity.
The build passed 1,485 incoming and 309 outgoing regression comparisons against the
upstream converters.
These tests cover selected behavior using simulated Zigbee frames. Automatic
conversion includes Philips On/Off plugs, Hue light wrappers with supported
options, and IKEA lights. Mixed light groups send color-temperature commands
to the enrolled endpoints using the protocol each light supports. The IKEA module restores reporting and selected
settings after an announce and sends Level Control Stop when a color transition
can leave the light frozen. It also supports IKEA temperature-via-XY variants.
Philips2 atomic control can be opted into for directly addressed Hue lights
that advertise the Philips2 cluster. The Philips extension supports Gradient
colors, styles, fades, named scenes and vendor-specific startup commands.
Standard lights without a fixed color-temperature range read their physical
limits from the Color Control cluster. Until valid limits are available, Zhub
uses the 150–500 mired fallback. Definitions with unresolved converter logic
remain outside the generated catalog.
Zhub starts with the catalog already on disk. On a fresh installation it
uses built-in profiles while checking GitHub Releases in the background. When
online, it installs the latest compatible catalog automatically and checks
again every 24 hours. With an existing catalog, automatic installation also
requires a release published after the local catalog file was installed. This
protects locally installed builds from being replaced with an older release.
GitHub checks require curl and working HTTPS certificates. A failed check or
download leaves the current profiles available.
In Settings → Device catalog, choose the device-catalog.zpc package from
a catalog release, paste the checksum from its matching
device-catalog.zpc.sha256 file and install it. Zhub checks file integrity,
profile data and supported write mappings before switching catalogs. Roll back
restores the preceding catalog. These operations work offline once you have the
files. Paired devices keep their identities and show their selected profile
source in About.
The built-in SONOFF and Philips profiles ship inside the Zhub binary and
remain available offline. The Philips catalog includes Hue White and White
Ambiance bulbs and Hue wall switches.
Custom device-profiles.json overrides, built-in profiles and native Rust
definitions retain their priority. The compiler enables upstream definitions only
when it can translate their behavior. The release report lists partial matches
and custom converters that need a Rust implementation. The development and
benchmark commands are in the catalog architecture notes.
Zigbee device firmware updates
Open a device’s Details → About panel and choose Check for update.
If Zhub finds a newer compatible image, choose Update firmware. The radio
must be able to reach the device during the update. For sleepy devices, wake
the device when checking or starting. Zhub never starts an update automatically
and handles one device at a time.
Zhub streams the firmware from the
zigbee-OTA index, checks its SHA-512
and Zigbee header, then serves small blocks from a temporary file beside its
state file. The process needs curl with working HTTPS certificates and
disk space for the image plus 2 MiB. If it cannot confirm the new version
after a completed transfer, it reports the result as unverified.
For Zigbee2MQTT-style MQTT control, send {"id":"device name or IEEE address"}
to <base>/bridge/request/device/ota_update/check, …/update or
…/update/abort. Progress is published under update on the normal device
state topic. Custom OTA providers, downgrades and scheduled updates are
currently outside this implementation.
Roadmap
- More device definitions: ported from zigbee-herdsman-converters, starting with
common sensors, plugs, switches and lights. Devices without a definition already work
through a generic definition built from their clusters.
Credits
zhub builds on the work of these projects:
- Ziggurat (Apache-2.0): the Zigbee stack zhub runs
on, from the zigpy project.
vendor/ziggurat-spinel is a modified copy of its Spinel
client (see vendor/ziggurat-spinel/ZHUB-CHANGES.md).
- rs-matter (Apache-2.0): the Rust Matter
stack behind the Matter bridge.
- Zigbee2MQTT and
zigbee-herdsman-converters (MIT) by
Koen Kanters and contributors: the device definitions, feature names and descriptions, and
the light command behavior are derived from zigbee-herdsman-converters; the MQTT topics
and payloads follow Zigbee2MQTT so that tools made for it work with zhub.
- Nerivec’s silabs-firmware-builder:
the OpenThread RCP firmware zhub is tested with.
License
Apache License 2.0, see LICENSE. Third-party notices are in NOTICE.
评论