Skip to content

About

Matterbridge plugin that bridges Wirenboard devices to the Matter ecosystem

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matterbridge Wirenboard Plugin

npm version license powered by TypeScript


Matterbridge plugin that bridges Wirenboard devices to the Matter ecosystem. Connects to the Wirenboard MQTT broker, discovers devices automatically, and exposes them to Apple Home, Google Home, Amazon Alexa, and SmartThings — all local, no cloud.

Wirenboard devices are discovered via standard WB MQTT conventions (/devices/+/meta, /devices/+/controls/+/meta). Each control is mapped to the appropriate Matter device type based on its type and units. State changes sync bidirectionally: MQTT values update Matter attributes, and Matter commands publish to MQTT /on topics.

Features

  • Automatic device discovery via MQTT meta-topics (retained messages)
  • Bidirectional state sync: MQTT → Matter and Matter → MQTT
  • Supports all standard WB control types (see mapping table)
  • Two grouping modes: per-device (fewer Matter nodes) or per-control (granular)
  • White list / black list filtering
  • Static discovery mode: wait at startup until each id in devices appears in MQTT discovery (see Static discovery)
  • TLS support: mqtts, wss, mutual TLS, self-signed certificates
  • Device overrides: rename, retype, or skip individual controls
  • Composite thermostat detection (setpoint + temperature + mode)
  • Failsafe: refuse startup if fewer than N devices are found (prevents config loss on network issues)
  • Hardware metadata extraction: serial number, firmware version, hardware revision (peripheral WB devices)
  • Controller device system: readonly text controls (e.g. Short SN, Batch No, manufacturing date) are mapped into Matter Bridged Device Basic Information on the Matter node that represents the controller — when groupingMode is device. With groupingMode: "control", the plugin does not attach that extended factory snapshot to a single controller node (each control would be its own node); use device grouping for the controller if you want serial/part number and related fields visible in the app.

Prerequisites

Requirement Version
Matterbridge >= 3.7.0
Node.js 20.19+ / 22.13+ / 24+
MQTT broker Wirenboard controller or any Mosquitto instance

Developing this plugin from source: the repo does not list matterbridge as an npm dependency. Run npm run dev:link after npm install so matterbridge is symlinked into node_modules (same idea as the official plugin template). Without that link, npm run build and tests will fail with unresolved matterbridge imports.

Installation

Via Matterbridge frontend (recommended)

Open the Matterbridge web UI, find matterbridge-wirenboard-plugin, and click Install.

Via npm

sudo npm install -g matterbridge-wirenboard-plugin --omit=dev
matterbridge -add matterbridge-wirenboard-plugin

Development (npm link / dev:link)

Install Matterbridge globally (npm install -g matterbridge) or from a local clone (cd matterbridge && npm link). Then link it into this project:

git clone https://github.com/your-org/matterbridge-wirenboard-plugin
cd matterbridge-wirenboard-plugin
npm install
npm run dev:link   # required: wires matterbridge into node_modules for tsc / jest
npm run build
matterbridge -add .

npm run dev:link runs npm link matterbridge (see package.json scripts).

Configuration

Configuration is stored in ~/.matterbridge/matterbridge-wirenboard-plugin.config.json.

All options

Field Type Default Description
mqttHost string "localhost" MQTT broker hostname or IP
wirenboardUrl string "" Full URL for the Matterbridge device Url link (Wirenboard web UI or proxy). Empty → http://<mqttHost>
mqttPort number 1883 MQTT broker port
mqttUsername string "" MQTT username (leave empty if not required)
mqttPassword string "" MQTT password
mqttProtocol string "mqtt" Transport: mqtt, mqtts, ws, wss
mqttCaPath string "" Path to CA certificate (PEM) for TLS
mqttCertPath string "" Path to client certificate (PEM) for mutual TLS
mqttKeyPath string "" Path to client private key (PEM) for mutual TLS
discoveryMode string "auto" auto — idle-based discovery complete; static — wait until each id in devices appears (startup only; see Static discovery)
discoveryTimeout number 30 Max seconds to wait for discovery (auto mode)
discoveryIdleMs number 1000 Idle time (ms) on meta-topics before discovery is considered complete
groupingMode string "device" device — one Matter node per WB device; control — one Matter node per control
includeHidden boolean false Include controls marked hidden in WB meta
ignoreSystemPrefixedDevices boolean true When true, does not bridge Wirenboard service devices whose id starts with system__ (e.g. system__networks__…), and unmappable controls on those devices (if bridged) log at debug only. Set false to expose system__* in Matter and use warn for unmappable-control skips there.
ignoreNetworkPrefixedDevices boolean true When true, does not bridge devices whose id starts with network (e.g. networks, networks_…). Independent of ignoreSystemPrefixedDevices. Set false to bridge them.
devices string[] [] Device ids required at startup when discoveryMode is static (not a registration filter; see Static discovery)
whiteList string[] [] Only expose listed devices (empty = all)
blackList string[] [] Never expose listed devices
deviceOverrides object {} Per-device overrides (see Advanced)
failsafeCount number 0 Min devices required on startup (0 = disabled)
debug boolean false Enable verbose debug logging

Example config

{
  "name": "matterbridge-wirenboard-plugin",
  "type": "DynamicPlatform",
  "mqttHost": "192.168.1.100",
  "mqttPort": 1883,
  "mqttUsername": "",
  "mqttPassword": "",
  "mqttProtocol": "mqtt",
  "discoveryMode": "auto",
  "discoveryTimeout": 30,
  "discoveryIdleMs": 1000,
  "groupingMode": "device",
  "includeHidden": false,
  "ignoreSystemPrefixedDevices": true,
  "ignoreNetworkPrefixedDevices": true,
  "whiteList": [],
  "blackList": ["wb-hwmon_0"],
  "deviceOverrides": {},
  "failsafeCount": 5,
  "debug": false
}

WB MAP meters and meta.units (before updated wb-mqtt-serial templates)

The plugin chooses Matter mappings for value channels from meta.units on each control (/devices/<id>/controls/<control>/meta in MQTT). Newer wb-mqtt-serial MAP device templates include "units" on channels so this works out of the box. If your controller still runs an older wb-mqtt-serial build without those template fields, controls may have no units in MQTT and the plugin will skip them or only map legacy normalized types (e.g. deprecated power → W).

Until you upgrade wb-mqtt-serial, you can fix this in wb-mqtt-serial configuration (not in Matterbridge):

  1. Merge units in the serial device definition (recommended) In the Wiren Board UI (Settings → Serial devices) or in /etc/wb-mqtt-serial.conf, open the MAP device and add a channels array where each entry sets name exactly as in the device template (same English string as in the template file, e.g. Q L1, Urms L1, EPP) and the desired units string. Per wb-mqtt-serial docs, when a channel name matches the template, properties from the device config are merged with the template and override the template if both set the same field—so you only need name + units for each channel that is missing units.

  2. Custom template copy Copy the MAP JSON from /usr/share/wb-mqtt-serial/templates/ (e.g. config-map12e.json) into /etc/wb-mqtt-serial.conf.d/templates/, add "units": "…" under each channels[] entry that needs it, then select that template / device_type for the device. Use this if you prefer one file with full control.

Use units strings that match the sensor mapping table and your plugin version (newer releases add MAP electrical units such as var, VA, Hz, deg, ratio, kvarh, kVAh). Copy spelling exactly from the wb-mqtt-serial MAP templates when in doubt (units is case-sensitive).

Why % and “humidity” appear together: the plugin’s default for value + % is relative humidity (climate sensors). MAP may also use % for THD (harmonics). Those MAP channels are not humidity — give the control a name that matches the plugin’s harmonic keywords (THD, harm, …) so mapping goes to electrical, not humiditySensor.

MAP electrical Matter proxies (limitation of the default Matter server on the bridge): THD % (with harmonic keywords) is stored in rmsPower (scale ≈ THD×100, not true RMS watts). Phase angle deg is stored in rmsCurrent as millidegrees (×1000), not amperes. kvarh / kVAh use the same cumulativeEnergyImported struct as kWh, one Matter endpoint per WB counter channel.

After saving config, restart wb-mqtt-serial and confirm under MQTT that each control’s meta includes the expected units, then restart or reconnect Matterbridge if needed.

Supported Wirenboard Control Types

Switches & Actuators

WB meta.type Condition Matter Device Type Matter Cluster
switch writable onOffOutlet OnOff
switch readonly contactSensor BooleanState
switch name contains valve/кран waterValve ValveConfigurationAndControl
switch name contains lock/замок doorLockDevice DoorLock
switch name contains fan/вент fanDevice FanControl
switch name contains pump/насос pumpDevice OnOff + PumpConfigurationAndControl
switch name contains motion/движ/occupancy (readonly) occupancySensor OccupancySensing
range — dimmableLight OnOff + LevelControl
range name contains blind/curtain/штор/жалюзи coverDevice WindowCovering
range name contains fan/вент + speed fanDevice FanControl
rgb — extendedColorLight OnOff + ColorControl
pushbutton, wo-switch — genericSwitch Switch (MomentarySwitch)

Sensors

WB meta.type meta.units Matter Device Type Matter Cluster
value deg C temperatureSensor TemperatureMeasurement
value %, RH humiditySensor RelativeHumidityMeasurement
value % + name hints THD/harm/… electricalSensor ElectricalPowerMeasurement (THD proxy, see AGENTS.md)
value Pa / mbar / bar pressureSensor PressureMeasurement
value lx lightSensor IlluminanceMeasurement
value W / V / A / mA / mV electricalSensor ElectricalPowerMeasurement
value var / VA / Hz / ratio electricalSensor ElectricalPowerMeasurement
value deg (not deg C) electricalSensor ElectricalPowerMeasurement (phase-angle proxy)
value kWh / kvarh / kVAh electricalSensor ElectricalEnergyMeasurement
value m³/h flowSensor FlowMeasurement
value ppm (CO2) airQualitySensor AirQuality + CarbonDioxideConcentrationMeasurement
value ppm (CO, by name) airQualitySensor AirQuality + CarbonMonoxideConcentrationMeasurement
value ppb (NO2, by name) airQualitySensor NitrogenDioxideConcentrationMeasurement
value µg/m³ (PM1/PM2.5/PM10, by name) airQualitySensor Pm1/Pm25/Pm10ConcentrationMeasurement
value ppb/ppm (TVOC, by name) airQualitySensor TotalVolatileOrganicCompoundsConcentrationMeasurement
alarm name contains smoke/дым smokeCoAlarm SmokeCoAlarm
alarm name contains leak/утечка waterLeakDetector BooleanState
alarm name contains freeze/замерз waterFreezeDetector BooleanState
alarm name contains rain/дождь rainSensor BooleanState
alarm (fallback) contactSensor BooleanState

Deprecated WB types (temperature, rel_humidity, voltage, power, current, etc.) are automatically normalized to value + appropriate units.

Types without a Matter equivalent (text, enum without override, sound_level, wind_speed, rainfall) are skipped with a warning in the log.

Controller Compatibility

Feature Apple Home Google Home Amazon Alexa SmartThings
On/Off outlets & lights Yes Yes Yes Yes
Dimmers (LevelControl) Yes Yes Yes Yes
Color lights (RGB) Yes Yes Yes Yes
Temperature sensors Yes Yes Yes Yes
Humidity sensors Yes Yes Yes Yes
Pressure sensors Partial¹ Yes No Yes
Air quality sensors Yes Yes Yes Yes
Electrical sensors No No No No
Flow sensors No Yes No Yes
Occupancy sensors Yes Yes Yes Yes
Contact sensors Yes Yes Yes Yes
Smoke/CO alarms Yes² Partial³ Yes Yes
Water leak detectors Yes² No No Yes
Water valve Partial⁴ No No Yes
Window coverings Yes Yes Yes Yes
Door locks Yes Yes Yes Yes
Fan control Yes Yes Yes Yes
Thermostats Yes Yes Yes Yes
Pump No Yes No Yes
Generic switch (pushbutton) Yes⁵ Partial Yes Yes
Max bridged endpoints 150 ~250 50 ~50

¹ Pressure: Apple Home has no dedicated UI tile but automations work. ² Requires iOS 18.4+. ³ Google Home: full support for Nest Protect; partial for third-party Matter smoke alarms. ⁴ Water valve pairs but has no native Apple Home UI; works via automations. ⁵ Improved in iOS 18.2 (moved to Home View).

Alexa hard limit: 50 bridged devices. Use whitelist/blacklist to stay within the limit. Apple Home limit is 150 (149 + bridge). Electrical sensors and rain/freeze detectors are not supported by any major controller.

Sources:

Grouping Modes

groupingMode: "device" (default)

One Matter bridged device per WB device. Each control becomes a child endpoint inside that device.

  • Fewer Matter nodes — better for controllers with endpoint limits
  • All relays of wb-mr6c appear as one device with multiple outlets
  • Recommended for most setups
  • Required if you want full Bridged Device Basic Information (factory metadata) on the Wirenboard controller device id system

groupingMode: "control"

One Matter bridged device per WB control.

  • Full granularity — each control appears separately in the controller app
  • Better naming and room assignment in Apple Home / Google Home
  • Reaches Matter endpoint limits faster (~250 total)
  • Recommended when you have few devices but want per-control visibility
  • For WB device system, extended controller metadata in Matter BI is not merged onto one dedicated node (see below); prefer device grouping for the controller if you rely on that metadata

Wirenboard controller (system) and groupingMode (factory metadata in Matter)

The WB MQTT device id system represents the Wirenboard controller (factory info: Short SN, Batch No, firmware strings, etc.). The plugin maps readonly text controls from that device into Matter Bridged Device Basic Information — but only when it can attach them to one Matter bridged device that stands for the whole controller.

  • groupingMode: "device" — there is exactly one Matter node per WB device, including system. All service controls are child endpoints under that node (or the node is root-only if there are no mappable controls). The plugin sets systemBiEndpoint to that node and writes the extended BI snapshot there. Use this mode if you want serial/part number and related fields visible in Apple Home / Google Home for the controller.

  • groupingMode: "control" — each WB control becomes its own Matter bridged device. For system that means many small devices (one per text/control), and there is no single “controller” node the plugin currently uses for the full extended BI block. Factory metadata is therefore not merged into one dedicated controller card in this mode (implementation detail: systemBiEndpoint is only set in the device aggregation path).

Practical rule: need factory/controller info in Matter → groupingMode: "device" (default). Fine-grained per-control exposure for other WB devices can still be a reason to use control elsewhere, but for system specifically, prefer device.

Advanced

deviceOverrides

deviceType: use Matterbridge export names (e.g. onOffOutlet, onOffLight), not Matter DeviceTypeDefinition.name strings (e.g. MA-onoffpluginunit). The allowed values are exactly the Matter device types that appear in CONTROL_MAPPINGS in controlMapping.ts. The same list is written into the deviceType enum in matterbridge-wirenboard-plugin.schema.json when you run npm run build (from MATTER_DEVICE_TYPE_BY_NAME). Types that only exist on composite code paths are not valid here — for example you cannot set deviceType: "thermostatDevice" on a single arbitrary control; a thermostat is created when Thermostat composite detection matches your WB metadata.

Per-device keys are WB device ids. Each value must include controls (object). Optional name sets the Matterbridge UI / registration title for that device. Under controls, each key is a WB control name; the value may set deviceType (string, as above) or skip: true (no endpoint, no “unmappable control” warning for that control).

Example full config:

{
  "deviceOverrides": {
    "wb-mr6c_28": {
      "name": "Lighting Panel",
      "controls": {
        "Relay 1": { "deviceType": "onOffLight" },
        "Relay 2": { "deviceType": "onOffLight" },
        "Temperature": { "skip": true }
      }
    },
    "wb-map12e_42": {
      "controls": {
        "Channel 1 Power": { "skip": true }
      }
    }
  }
}

Thermostat composite detection

If a WB device has controls matching this combination, the plugin creates a thermostatDevice instead of separate sensor/range endpoints:

Required WB control name contains WB type Maps to
Yes temperature (readonly) value, deg C localTemperature
Yes setpoint or target range, deg C occupiedHeatingSetpoint / occupiedCoolingSetpoint
No mode or system_mode enum systemMode (Off/Heat/Cool/Auto)

Heating-only or cooling-only is detected automatically from available controls. Min/max setpoint bounds are taken from meta.min/meta.max of the setpoint control.

This path is automatic — deviceOverrides cannot turn a single control into a thermostatDevice; that string is not in the override enum because it is not a row in CONTROL_MAPPINGS for individual controls.

Static discovery

With discoveryMode: "static" and a non-empty devices array, startup waits (up to discoveryTimeout) for each listed Wiren Board device id to show up in retained MQTT discovery — instead of using the idle-based “discovery complete” condition from discoveryIdleMs.

Registration is unchanged: registerDiscoveredDevices still iterates every device present in the in-memory map (everything the broker retained on /devices/+/meta). The devices list is not a filter that hides other devices from Matter. Use whiteList / blackList if you need to restrict what gets bridged.

For a checklist of ids you care about before bridging starts, combine static + devices with the MQTT inventory CLI (it annotates whether an id is in devices when discoveryMode is static).

{
  "discoveryMode": "static",
  "devices": ["wb-mr6c_28", "wb-msw-v3_42", "thermostat-room1"]
}

TLS / mqtts

{
  "mqttProtocol": "mqtts",
  "mqttPort": 8883,
  "mqttCaPath": "/etc/ssl/certs/my-ca.pem",
  "mqttCertPath": "/etc/ssl/certs/client.pem",
  "mqttKeyPath": "/etc/ssl/private/client.key"
}

MQTT inventory CLI (mb-wirenboard-verify-mqtt)

Compiled from this package as dist/mqttInventoryCliEntry.js (thin entry; core logic in mqttInventoryCli.js). It connects to the same MQTT broker fields as the plugin (mqttHost, mqttPort, TLS paths, …), walks /devices/# like the platform, and prints human or --json output with annotations: how whiteList / blackList, deviceOverrides, includeHidden, prefix skips, discoveryMode + devices, and groupingMode would affect Matter exposure — using the same helpers as WirenboardPlatform / WirenboardDevice (not a second implementation).

Run (after npm run build):

npm run verify:mqtt -- --help
node dist/mqttInventoryCliEntry.js --json

When the package is installed with a global or local node_modules/.bin, the mb-wirenboard-verify-mqtt binary points at the same file.

Config file resolution (plugin JSON shape, same filename as Matterbridge):

  1. --config <path> if given
  2. MATTERBRIDGE_WIRENBOARD_PLUGIN_CONFIG if set
  3. First existing readable file among: /root/.matterbridge/matterbridge-wirenboard-plugin.config.json, then $HOME/.matterbridge/matterbridge-wirenboard-plugin.config.json

MQTT overrides for a single run (highest precedence first): CLI flags → WB_MQTT_* env (table in AGENTS.md) → values from JSON → defaults.

Output: --json writes a single JSON object to stdout (no ANSI). Otherwise, text mode prints a short Legend, effective annotation flags (includeHidden, prefix-ignore toggles), then per device: separator line ── id ──, human-readable title, control counts (total / mappable / unmappable), a single plain-English matter: line (registration outcome), optional static devices[] note, a note when prefix-skip still lists mappable controls (inventory vs Matter), then control rows with badges. It uses ANSI background badges for categories (256-color palette), unless stdout is not a TTY, NO_COLOR is set, or --no-color is passed — then badges render as plain [label] brackets. Mapping: hidden (purple-gray), override (green), skip (orange), blacklist / whitelist (reds / greens), prefix (purple), static (blue), mappable / unmappable (green / gray).

Annotation scope: the CLI explains bridge-relevant options (MQTT connection, lists, overrides, hidden, discovery, groupingMode). It does not diagnose unrelated knobs such as failsafeCount, discoveryTimeout timing semantics beyond what is printed, unregisterOnShutdown, or wirenboardUrl — treat those as out of scope for inventory output.

Authoring workflow: edit ~/.matterbridge/matterbridge-wirenboard-plugin.config.json, run the CLI against it (--config or default paths), adjust whiteList / deviceOverrides / etc. using real device ids (── … ── in human output or devices[].id in --json) and control names from the report. Valid deviceType strings for overrides are the same enum matterbridge-wirenboard-plugin.schema.json regenerates on npm run build ($defs.matterDeviceTypeEnum).

Minimal fragments (merge into your plugin JSON alongside mqttHost and other keys):

{
  "whiteList": ["wb-mr6c_28", "wb-msw-v3_42"],
  "blackList": ["wb-hwmon_0"]
}
{
  "deviceOverrides": {
    "wb-mr6c_28": {
      "name": "Hall relays",
      "controls": {
        "Relay 1": { "deviceType": "onOffLight" },
        "Temperature": { "skip": true }
      }
    }
  }
}

Development

Build

npm install
npm run build        # compile TypeScript → dist/; refresh matterbridge-wirenboard-plugin.schema.json (deviceType enum from CONTROL_MAPPINGS)
npm run watch        # watch mode
npm run cleanBuild   # clean + build

During startup, SIGINT / SIGTERM aborts further device registration (and stops MQTT) so the service does not stay blocked until every Matter endpoint is created. A single long registerDevice call may still run until Matterbridge finishes that call.

Tests

npm test             # run all tests
npm run test:watch   # watch mode
npm run test:verbose # verbose output

Project structure

src/
  module.ts            # WirenboardPlatform — entry point, lifecycle
  wirenboardMqtt.ts    # MQTT client, topic parsing, event emitter
  wirenboardDevice.ts       # Matter endpoint construction, bidirectional state sync
  systemMetadataMapping.ts  # WB `system` controller → Bridged Device Basic Information
  wirenboardTypes.ts        # TypeScript interfaces for WB MQTT conventions
  controlMapping.ts         # WB control type → Matter device type mapping table
test/
  *.test.ts            # unit tests (Jest)

Adding a new control type mapping

Edit src/controlMapping.ts. Each entry specifies the WB type/units match, the target Matter device type, cluster setup, and value converters (MQTT string → Matter attribute and reverse).

Matter 1.5 Roadmap

The following device types are planned for future releases pending Matter controller support:

WB Device / Use Case Planned Matter Type
Soil moisture sensors soilMoistureSensor
Gate / garage door controls closureSensor, closureDevice
Irrigation zone valves irrigationSystem

License

Apache-2.0 — see LICENSE.

About

Matterbridge plugin that bridges Wirenboard devices to the Matter ecosystem

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages