Multi-plug toggle wiring with single button, avoid Node-RED mqtt-broker duplicate-delivery bug #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Track the wiring that maps a single ThirdReality button (Door Button) to toggling three ThirdReality smart plugs (Squiggle, Sideboard Lamp, Bamboo Lights) via zigbee2mqtt.
Findings
#subscriber on the same base topic. Source:/usr/src/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.jsline ~1091:node._clientOn('message', subscription.handler)is unconditional and re-adds the handler as an EventEmitter listener on every subscribe call.zigbee2mqtt/<device>) instead of wildcards (zigbee2mqtt/#).TOGGLE— onlyON/OFF. Use individualmqtt outnodes per plug.Implemented
mqtt outnodes, each publishes TOGGLE to its plug on button pressmqtt innodes, one per plug, drive the correspondingui-textwidgetbtn-filterfunction node drops non-action:singlebutton events (battery reports, double press, etc.)Reboot survival
All configs are bind-mounted to host paths:
/root/nodered/flows.json→ nodered container/data/flows.json(volume)/root/zigbee2mqtt/configuration.yaml→ zigbee2mqtt container/app/data/configuration.yaml(volume)/root/nodered/node_modules/@flowfuse/node-red-dashboard/dist/index.html(modified with<base href="/dashboard/">to fix Vue Router 4replace()error)The
<base href>patch is fragile: anynpm installin the nodered container would overwrite it. Needs a proper upstream PR to FlowFuse/node-red-dashboard.Next steps
<base href>issue (or document as manual fix)Update: the duplicate-delivery theory in this ticket was a red herring. The real bug in nodered 5.0 + mqtt-broker is that tabs containing an internal
nodes: [...]array silently break the MQTT broker connection — no error, no log, just noConnected to brokerline. Switching to a flat structure (all nodes at top level withzfield referencing the tab id) restores the broker. Verified by bisection from a minimal flow (broker connects) to a wrapped-tab flow (broker never connects).The wildcard-alongside-specific topic pattern also works fine once the structure is flat, so the subscribe-handler stacking theory from
10-mqtt.js:1091is not the blocker. We still use specific topics for cleanliness.Added
deny_wrapped_tabto the Rego policy to catch this on validation. Implementing in the next commit (closes this issue).