infra: runtime config fixes + declarative flow updates

Refs #3
This commit is contained in:
2026-08-27 03:15:07 +00:00
parent 14581d05dd
commit 229e311f68
7 changed files with 542 additions and 170 deletions
+90 -37
View File
@@ -5,6 +5,16 @@ brokers:
host: mosquitto
port: 1883
# Plugs toggled on brief single press
single_plugs:
- Squiggle
- Sideboard Lamp
- Bamboo Lights
# Plugs toggled on press-hold-release (action: "release" after a "hold")
hold_plugs:
- DJ Booth
dashboards:
- base: Dashboard
pages:
@@ -17,35 +27,32 @@ dashboards:
flows:
- tab: Zigbee Monitor
description: Button dispatches single vs hold-release to different plug sets.
Plug plumbing (state-in, /set out, dashboard widget, per-channel mapper)
is generated by flow2json.py from the plugs lists below.
# Declarative plug set. channels:[] marks a multi-channel device, which gets
# a mapper that toggles each channel and a widget showing each state_N.
plugs:
- id: squiggle
name: Squiggle
- id: sideboard
name: Sideboard Lamp
- id: bamboo
name: Bamboo Lights
- id: djbooth
name: DJ Booth
- id: couch
name: Dual Outlet - Couch
channels: [1, 2]
# Device ids toggled on brief single press (driven by single_filter)
single_plugs: [squiggle, sideboard, bamboo, couch]
# Device ids toggled on press-hold-release (driven by hold_filter)
hold_plugs: [djbooth]
single_filter: single-filter
hold_filter: hold-filter
description: Button dispatches single vs hold-release to different plug sets
nodes:
- id: zigbee-state-squiggle
type: mqtt in
broker: mosquitto
topic: zigbee2mqtt/Squiggle
qos: 0
- id: zigbee-state-sideboard
type: mqtt in
broker: mosquitto
topic: zigbee2mqtt/Sideboard Lamp
qos: 0
- id: zigbee-state-bamboo
type: mqtt in
broker: mosquitto
topic: zigbee2mqtt/Bamboo Lights
qos: 0
- id: zigbee-state-djbooth
type: mqtt in
broker: mosquitto
topic: zigbee2mqtt/DJ Booth
qos: 0
- id: button-in
type: mqtt in
broker: mosquitto
@@ -56,10 +63,6 @@ flows:
type: function
name: Single click
code: |
const now = Date.now();
const last = context.get('lastTime') || 0;
if (now - last < 50) return null;
context.set('lastTime', now);
try {
const p = JSON.parse(msg.payload);
if (p.action === 'single') {
@@ -73,10 +76,6 @@ flows:
type: function
name: Hold release
code: |
const now = Date.now();
const last = context.get('lastTime') || 0;
if (now - last < 50) return null;
context.set('lastTime', now);
try {
const p = JSON.parse(msg.payload);
if (p.action === 'release') {
@@ -86,6 +85,54 @@ flows:
} catch (e) {}
return null;
- id: plug-out-squiggle
type: mqtt out
broker: mosquitto
topic: zigbee2mqtt/Squiggle/set
- id: plug-out-sideboard
type: mqtt out
broker: mosquitto
topic: zigbee2mqtt/Sideboard Lamp/set
- id: plug-out-bamboo
type: mqtt out
broker: mosquitto
topic: zigbee2mqtt/Bamboo Lights/set
- id: plug-out-djbooth
type: mqtt out
broker: mosquitto
topic: zigbee2mqtt/DJ Booth/set
- id: text-squiggle
type: ui-text
group: Plugs
label: Squiggle
format: "{{msg.payload.state}}"
order: 1
- id: text-sideboard
type: ui-text
group: Plugs
label: Sideboard Lamp
format: "{{msg.payload.state}}"
order: 2
- id: text-bamboo
type: ui-text
group: Plugs
label: Bamboo Lights
format: "{{msg.payload.state}}"
order: 3
- id: text-djbooth
type: ui-text
group: Plugs
label: DJ Booth
format: "{{msg.payload.state}}"
order: 4
- id: permit-btn
type: ui-button
group: Plugs
@@ -94,12 +141,18 @@ flows:
payload:
value: true
time: 60
order: 9
order: 5
- id: mqtt-out
type: mqtt out
broker: mosquitto
wires:
zigbee-state-squiggle: [text-squiggle]
zigbee-state-sideboard: [text-sideboard]
zigbee-state-bamboo: [text-bamboo]
zigbee-state-djbooth: [text-djbooth]
button-in: [single-filter, hold-filter]
single-filter: [plug-out-squiggle, plug-out-sideboard, plug-out-bamboo]
hold-filter: [plug-out-djbooth]
permit-btn: [mqtt-out]