Add Dual Outlet - Couch to single-press button automation #2

Open
opened 2026-08-15 09:48:33 +00:00 by david · 1 comment
Owner

Context

Door Button single-press toggles Squiggle, Sideboard Lamp, Bamboo Lights (all_plugs). Wanted to add the new Dual Outlet - Couch (0x4ce175523f710000, ThirdReality BL702 dual plug) to the same single-press action.

Finding (bug)

The dual plug ignores {state:"TOGGLE"} on its /set topic — nothing happens. It only responds to per-channel commands:

  • {"state_1":"TOGGLE"} / {"state_2":"TOGGLE"} (verified on live device)

So a multi-channel device needs a dedicated mapper, not the shared {state:"TOGGLE"} payload the current single-filter emits.

Change

In flows/zigbee-monitor.yaml:

  • Added Dual Outlet - Couch to single_plugs
  • Added zigbee-state-couch (state in), couch-mapper (function → {state_1:"TOGGLE",state_2:"TOGGLE"}), plug-out-couch (/set), text-couch dashboard widget (shows state_1/state_2)
  • Wired single-filter → couch-mapper → plug-out-couch
  • Dashboard widget displays {{msg.payload.state_1}} / {{msg.payload.state_2}} (dual plug publishes per-channel, not a single state)

Verification

  • 567 Rego policy checks pass
  • E2E: simulated single press → /set emitted {"state_1":"TOGGLE","state_2":"TOGGLE"} → both outlets flipped ON→OFF
  • Deployed to RPi Node-RED (HTTP 204), verified, and outlets restored to ON/ON

Follow-up risk

The generator's shared {state:"TOGGLE"} from single-filter silently fails on any multi-channel device. Other plugs in configuration.yaml worth auditing for the same issue.

## Context Door Button single-press toggles `Squiggle`, `Sideboard Lamp`, `Bamboo Lights` (all_plugs). Wanted to add the new `Dual Outlet - Couch` (`0x4ce175523f710000`, ThirdReality BL702 dual plug) to the same single-press action. ## Finding (bug) The dual plug ignores `{state:"TOGGLE"}` on its `/set` topic — nothing happens. It only responds to per-channel commands: - `{"state_1":"TOGGLE"}` / `{"state_2":"TOGGLE"}` (verified on live device) So a multi-channel device needs a dedicated mapper, not the shared `{state:"TOGGLE"}` payload the current `single-filter` emits. ## Change In `flows/zigbee-monitor.yaml`: - Added `Dual Outlet - Couch` to `single_plugs` - Added `zigbee-state-couch` (state in), `couch-mapper` (function → `{state_1:"TOGGLE",state_2:"TOGGLE"}`), `plug-out-couch` (`/set`), `text-couch` dashboard widget (shows `state_1/state_2`) - Wired `single-filter → couch-mapper → plug-out-couch` - Dashboard widget displays `{{msg.payload.state_1}} / {{msg.payload.state_2}}` (dual plug publishes per-channel, not a single `state`) ## Verification - 567 Rego policy checks pass - E2E: simulated single press → `/set` emitted `{"state_1":"TOGGLE","state_2":"TOGGLE"}` → both outlets flipped ON→OFF - Deployed to RPi Node-RED (HTTP 204), verified, and outlets restored to ON/ON ## Follow-up risk The generator's shared `{state:"TOGGLE"}` from `single-filter` silently fails on any multi-channel device. Other plugs in `configuration.yaml` worth auditing for the same issue.
Author
Owner

Follow-up on the generator risk: resolved.

flow2json.py now has build_plugs(). A flow declares a plugs: table ({id, name, channels?}) plus single_plugs/hold_plugs lists and single_filter/hold_filter ids; the generator auto-emits all per-plug plumbing: state-in node, /set out node, dashboard widget, and for multi-channel devices (channels: [1,2]) a mapper function that toggles each channel (state_1/state_2) instead of the ignored shared {state:TOGGLE} payload.

zigbee-monitor.yaml rewritten to declarative form — Dual Outlet - Couch is declared as multi-channel. Adding a plug is now a one-line change with no manual node/wire duplication.

Verified: 567 Rego checks pass, single-press toggles 5 devices (couch flips both channels E2E), hold-release still DJ Booth only. Committed as b9c53c1.

Follow-up on the generator risk: **resolved**. `flow2json.py` now has `build_plugs()`. A flow declares a `plugs:` table (`{id, name, channels?}`) plus `single_plugs`/`hold_plugs` lists and `single_filter`/`hold_filter` ids; the generator auto-emits all per-plug plumbing: state-in node, `/set` out node, dashboard widget, and for multi-channel devices (`channels: [1,2]`) a mapper function that toggles each channel (`state_1`/`state_2`) instead of the ignored shared `{state:TOGGLE}` payload. `zigbee-monitor.yaml` rewritten to declarative form — `Dual Outlet - Couch` is declared as multi-channel. Adding a plug is now a one-line change with no manual node/wire duplication. Verified: 567 Rego checks pass, single-press toggles 5 devices (couch flips both channels E2E), hold-release still DJ Booth only. Committed as `b9c53c1`.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/nr-flow-validator#2