@nielseulink/node-red-contrib-buttonplus 1.0.0
Node-RED nodes for controlling Button+ devices via MQTT
π Button+ nodes for Node-RED
Control Button+ devices from Node-RED over MQTT. Custom nodes with a shared config, configurable output properties, and optional debug output β replacing private subflows with a publishable npm package.
Table of contents
- Features
- Installation
- Initial setup
- Nodes overview
- Output properties
- Message precedence
- MQTT topics
- Example flow
- Development
- Requirements
- Links
β¨ Features
| Area | What you get |
|---|---|
| Config | Shared Button+ settings linked to an existing mqtt-broker config (prefix, device, QoS, retain) |
| LED | Front/wall/both LEDs β color, brightness, steady or pulse |
| Click | Short and long press on separate outputs; optional LED feedback after press |
| Update button | Top label, value label, SVG and optional LED per button |
| Update display | Label, value, unit and SVG per display item |
| Update global | Active page and display brightness |
| Output properties | Home Assistantβstyle mapping: choose what goes on msg (click events, metadata, debug) |
| Debug output | Optional buttonplus_debug with input message and all MQTT messages sent |
π¦ Installation
npm
cd ~/.node-red
npm install @nielseulink/node-red-contrib-buttonplus
Restart Node-RED after installation.
Node-RED palette manager
After publishing to npm, search for buttonplus or @nielseulink/node-red-contrib-buttonplus in Manage palette β Install and restart Node-RED.
Local / development install
From a checkout of this repository:
cd ~/.node-red
npm install /path/to/buttonplus-nodered
Or install a packed tarball:
npm pack
cd ~/.node-red
npm install /path/to/nielseulink-node-red-contrib-buttonplus-1.0.0.tgz
Docker example (sync repo to the container mount, then):
docker exec -it NodeRed npm install --prefix /data --no-save /dev/buttonplus-nodered
docker restart NodeRed
See scripts/install-in-nodered.sh and scripts/sync-to-server.ps1.
π§ Initial setup
- Add or select an existing mqtt-broker config node (Node-RED built-in MQTT nodes).
- Add a Button+ config node and link it to that broker.
- Set Topic prefix (default
buttonplus) and Device (e.g.buttonplus_1). - Drag nodes from the Button+ palette category and link each to the shared config node.
- Deploy.
Each functional node can override page, button and other fields at runtime via msg properties.
π Nodes overview
| Node | Inputs | Outputs | Purpose |
|---|---|---|---|
| Button+ config | β | β | Shared MQTT broker link, prefix, device id, QoS, retain |
| Button+ LED | 1 | 1 | Set button LED color, brightness, on/off/pulse |
| Button+ click | 1 | 2 | Listen for short press (output 1) and long press (output 2) |
| Button+ update button | 1 | 1 | Update top label, value label, SVG; optional LED |
| Button+ update display | 1 | 1 | Update display item label, value, unit, SVG |
| Button+ update global | 1 | 1 | Set active page and/or display brightness |
Button+ click β input properties
| Property | Type | Description |
|---|---|---|
page |
number | Button page (re-subscribe at runtime) |
button |
number | Button number |
led |
string | none, front, wall or both β LED after press |
led_color |
string | e.g. #a10303 |
led_delay |
string | number | none/steady or seconds (0.5, 1, β¦) |
Button+ LED / update button β shared LED fields
Same page, button, led, led_color, led_delay as above. LED node also supports led_brightness (0β100).
Button+ update button β label fields
| Property | Type | Description |
|---|---|---|
label |
string | Top label β empty string clears on device |
value |
string | Main label/value β empty clears |
svg |
string | Button SVG β empty clears |
Empty node configuration values are always published (as empty strings) to clear fields on the device.
Button+ update display β fields
| Property | Type | Description |
|---|---|---|
item |
number | Display item number |
label, value, unit, svg |
string | Published only when set in msg or node config; msg.field = "" clears |
Button+ update global β fields
| Property | Type | Description |
|---|---|---|
page |
number | Active page β page/set |
brightness |
number | 0β100 β brightness/set |
Fields empty in both node config and msg are skipped (nothing published for that field).
ποΈ Output properties
All nodes support Output properties: map a destination msg field (left) to a source (right), similar to the Home Assistant Node-RED nodes.
Default behaviour
| Node type | Empty output properties |
|---|---|
| Click | Sends an empty message {} |
| LED / update nodes | Pass-through: incoming msg unchanged |
Click node β available sources
| Source | Description |
|---|---|
payload |
Original MQTT payload from the device (usually { "event_type": "shortpress" }) |
topic |
MQTT topic the event was received on |
device |
Device id from config |
button_page |
Page of the pressed button (not the device active page) |
button |
Button number |
event_type |
shortpress or longpress |
buttonplus |
Metadata object: device, button_page, button, event_type, topic |
buttonplus_debug |
Debug: received MQTT in input, LED MQTT in mqtt |
Tip: map payload + buttonplus for a practical default. Use button_page instead of msg.page so click output does not override page settings on other Button+ nodes.
Action nodes β debug source
Add a row such as msg.buttonplus_debug = debug info (input + mqtt sent) to attach:
{
"input": { /* incoming msg snapshot */ },
"mqtt": [
{ "topic": "...", "payload": "...", "qos": 0, "retain": false }
]
}
π Message precedence
For all nodes:
msg property β node configuration β fallback default
Explicit falsy values in msg (false, 0, "") are respected and are not replaced by defaults.
Device id is always taken from the linked Button+ config node, not from individual nodes.
π‘ MQTT topics
With prefix buttonplus and device buttonplus_1:
| Action | Topic pattern |
|---|---|
| Button press (subscribe) | buttonplus/buttonplus_1/button/{button}-{page}/pushbutton |
| Button top label | .../button/{button}-{page}/toplabel/set |
| Button value label | .../button/{button}-{page}/label/set |
| Button SVG | .../button/{button}-{page}/svg/set |
| Button LED | .../button/{button}-{page}/led/{front|wall}/rgb/set, .../brightness/set, .../on/set |
| Display item | .../displayitem/{item}/label/set, .../value/set, .../unit/set, .../svg/set |
| Global page | buttonplus/buttonplus_1/page/set |
| Global brightness | buttonplus/buttonplus_1/brightness/set |
LED none on update/click nodes runs the full off sequence on front and wall.
π Example flow
An example is included at examples/basic-flow.json.
After installation it also appears in Node-RED under:
Menu β Import β Import example flow β @nielseulink/node-red-contrib-buttonplus β basic-flow
The example demonstrates MQTT broker setup, shared config, LED pulse, and button click with debug nodes.
π οΈ Development
npm install
npm test
npm pack
Tests cover MQTT payload parsing, LED actions, topic building, resolve helpers, output properties and debug output.
Project layout:
| Path | Purpose |
|---|---|
nodes/ |
Runtime and editor definitions |
nodes/lib/ |
Shared logic (topics, LED, resolve, output properties) |
resources/ |
Editor JavaScript served to Node-RED (buttonplus-editor.js) |
examples/ |
Importable example flow |
test/ |
Mocha tests |
scripts/ |
Sync and Docker install helpers |
β Requirements
| Requirement | Version |
|---|---|
| Node-RED | 3.0+ |
| Node.js | 18+ |
| MQTT broker | Existing mqtt-broker config in Node-RED |
| Button+ device | MQTT-enabled, reachable from Node-RED |
No runtime npm dependencies β the package is self-contained.
π Links
| Resource | URL |
|---|---|
| Repository | github.com/nielseulink/buttonplus-nodered |
| npm package | @nielseulink/node-red-contrib-buttonplus |
| Button+ product | buttonplus.nl |
| Node-RED | nodered.org |
| Flow Library | flows.nodered.org/add/node |
| Example flow | examples/basic-flow.json |
License
MIT β see LICENSE.