node-red-contrib-dmx-for-ha 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,341 @@
1
+ # DMX Node — Environmental Variable Reference
2
+ **Version: 0.5.0**
3
+ Samba: `\\HOMEASSISTANT\`
4
+
5
+ ---
6
+
7
+ ## Notation
8
+
9
+ | Bracket style | Scope | Where to set |
10
+ |---|---|---|
11
+ | `<variable>` | **Node-level** subflow environmental | Double-click subflow node → Edit subflow template → double-click the tab → subflow env menu |
12
+ | `<<<variable>>>` | **Flow-level** environmental (global to all nodes on the tab) | Double-click the tab → gear icon → flow envs |
13
+ | `<<variable>>` | **RAM memory** — fast, lost on NR restart/reboot | Managed internally by the node. Do not set manually |
14
+ | `<<D_variable>>` | **Disk memory** — persistent, survives restarts | Managed internally by the node. Written after the disk-save debounce delay |
15
+
16
+ > **Rule of thumb:**
17
+ > - Single brackets `<>` → one fixture
18
+ > - Triple brackets `<<<>>>` → every DMX node on the flow simultaneously
19
+ > - Double brackets `<<>>` → runtime RAM state (fast, temporary)
20
+ > - Double brackets with `D_` prefix `<<D_>>` → persisted disk state (survives reboot/death)
21
+
22
+ ---
23
+
24
+ ## Flow-Level Globals `<<<...>>>`
25
+
26
+ These are set once per deployment and apply to **every** DMX subflow node on the tab.
27
+
28
+ | Variable | Type | Default | Description |
29
+ |---|---|---|---|
30
+ | `<<<DMX_NODE_FLOW_Transition_Rate_Limit>>>` | `float` | `1` | Global transition speed multiplier. `0.1` = potato/limp mode, `0.5` = half speed, `1` = normal, `2` = double speed (overclocked). Acts as a divisor on each node's tick rate — raise it to reduce total network/controller load across all fixtures. |
31
+ | `<<<DMX_NODE_FLOW_Transition_HA_UI_Time_(seconds)>>>` | `float` | `1` | Fallback transition duration (seconds) used when HA does not include a `transition` value in the command payload. |
32
+
33
+ ---
34
+
35
+ ## Node-Level Subflow Envs `<...>`
36
+
37
+ Set individually per fixture node in the subflow env menu.
38
+
39
+ ---
40
+
41
+ ### HA Identity
42
+
43
+ | Variable | Type | Example | Description |
44
+ |---|---|---|---|
45
+ | `<HA_discovery_prefix>` | `string` | `homeassistant` | MQTT discovery prefix — must match HA's configured discovery prefix. |
46
+ | `<HA_site_unique_id>` | `string` | `site01` | Unique site identifier. Prefixes the DMX MQTT topic. |
47
+ | `<HA_component>` | `string` | `light` | HA component type. Almost always `light`. |
48
+ | `<HA_unique_id_prefix>` | `string` | `dmx` | Prefix for the fixture's unique ID. |
49
+ | `<HA_unique_id>` | `string` | `lounge_spot_01` | The fixture's unique ID. Must be unique across the entire HA instance. |
50
+ | `<HA_unique_id_postfix>` | `string` | _(empty)_ | Optional postfix appended to the unique ID. |
51
+
52
+ ---
53
+
54
+ ### MQTT
55
+
56
+ | Variable | Type | Example | Description |
57
+ |---|---|---|---|
58
+ | `<HA_MQTT_retain_flag>` | `bool` | `true` | Whether MQTT messages are published with the retain flag. |
59
+ | `<HA_MQTT_QOS>` | `int` | `1` | MQTT Quality of Service level. `0`, `1`, or `2`. |
60
+ | `<HA_config_topic>` | `string` | `config` | Topic segment for HA MQTT discovery config messages. |
61
+ | `<HA_command_topic>` | `string` | `set` | Topic segment HA publishes commands to. |
62
+ | `<HA_state_topic>` | `string` | `state` | Topic segment this node publishes state back to HA on. |
63
+
64
+ ---
65
+
66
+ ### HA Feature Flags
67
+
68
+ | Variable | Type | Example | Description |
69
+ |---|---|---|---|
70
+ | `<HA_schema>` | `string` | `json` | MQTT light schema. Use `json`. |
71
+ | `<HA_optimistic>` | `bool` | `false` | Whether HA assumes commands succeed without waiting for a state report. Keep `false` — node reports state explicitly. |
72
+ | `<HA_enabled_by_default>` | `bool` | `true` | Whether the entity is enabled by default in the HA UI. |
73
+ | `<HA_icon>` | `string` | `mdi:lightbulb` | MDI icon shown in the HA dashboard. |
74
+ | `<HA_supported_color_modes>` | `string` | `rgbw` | Comma-separated list of supported color modes. Drives the entire ON/OFF/transition dispatch table. See supported values below. |
75
+ | `<HA_brightness>` | `bool` | `true` | Advertise brightness support to HA. |
76
+ | `<HA_brightness_scale_and_dmx_limiter>` | `int` | `190` | **Required.** HA brightness scale AND DMX output limiter in one value. Sets the maximum DMX output (0–255). Use to protect fixtures on undersized transformers (e.g. `190` for 9V fixtures on 12V supply). Also baked into the gamma lookup table at startup. |
77
+ | `<DMX_min_output>` | `int` | `1` | Minimum DMX output value when the fixture is ON. Prevents the gamma curve collapsing low brightness levels to DMX zero, which would cause the fixture to appear off while the HA slider is visibly above 0%. Default `1` guarantees something perceptible at any brightness above zero. Set to `0` to disable for pure gamma behaviour — recommended for lighting designers who want mathematically correct perceptual response and understand that sub-threshold values are genuinely imperceptible. OFF commands always send true 0 regardless of this setting. |
78
+ | `<HA_Transitions_Enabled>` | `bool` | `true` | Whether this fixture supports transitions. Advertised in the HA discovery payload. Set to `false` for binary `onoff` fixtures — all transition commands will fall back to the instant handler regardless of what HA sends. |
79
+ | `<HA_effects>` | `bool` | `true` | Advertise effects support to HA. |
80
+ | `<HA_effects_list>` | `string` | `flash_short,flash_long,strobe,rainbow,fire,flicker,twinkle,color_chase,scan,random,police,christmas,halloween,calaveras,party,relaxing,temperature_transition,sleep_transition,fireworks` | Comma-separated list of effect names advertised to HA. Must match keys in `EFFECT_MAP`. |
81
+ | `<DMX_Effects_Group_Controlled>` | `bool` | `true` | **ADVANCED.** Controls who triggers effects. `true` = fixture only accepts effects via AUX from a parent Group Node (siblings stay in sync). `false` = fixture accepts effects directly from HA payload (independent). Set to `false` for standalone fixtures with no Group Node parent. |
82
+ | `<HA_effects_flash_time_Short_(seconds)>` | `float` | `0.5` | Duration of the `flash_short` effect in seconds. |
83
+ | `<HA_effects_flash_time_Long_(seconds)>` | `float` | `2` | Duration of the `flash_long` effect in seconds. |
84
+
85
+ #### Supported Color Modes
86
+ | Value | Channels used |
87
+ |---|---|
88
+ | `onoff` | White only, no dimming |
89
+ | `brightness` | White with brightness |
90
+ | `rgb` | Red, Green, Blue |
91
+ | `rgbw` | Red, Green, Blue, Cold White |
92
+ | `rgbww` | Red, Green, Blue, Cold White, Warm White |
93
+ | `color_temp` | Cold White + Warm White (mireds mapping) |
94
+ | `white` | White with brightness only |
95
+ | `rgb,color_temp` | RGB or CT, HA selects active sub-mode |
96
+ | `rgbw,color_temp` | RGBW or CT |
97
+ | `rgbww,color_temp` | RGBWW or CT |
98
+
99
+ ---
100
+
101
+ ### DMX Controller
102
+
103
+ | Variable | Type | Example | Description |
104
+ |---|---|---|---|
105
+ | `<DMX_controller_zone>` | `string` | `rack_a` | The zone/location label of the DMX controller. Used in MQTT topic and device description. |
106
+ | `<DMX_universe>` | `int` | `1` | DMX universe number. Used in MQTT topic. |
107
+ | `<CONTROLLER_fw_v>` | `string` | `2.1.4` | DMX controller firmware version. Informational only — shown in HA device info. |
108
+
109
+ ---
110
+
111
+ ### DMX Channels
112
+
113
+ | Variable | Type | Example | Description |
114
+ |---|---|---|---|
115
+ | `<DMX_ch_red>` | `int` | `1` | DMX channel for Red. |
116
+ | `<DMX_ch_green>` | `int` | `2` | DMX channel for Green. |
117
+ | `<DMX_ch_blue>` | `int` | `3` | DMX channel for Blue. |
118
+ | `<DMX_ch_white>` | `int` | `4` | DMX channel for Cold White (also used as the single white channel for `brightness`, `onoff`, `white` modes). |
119
+ | `<DMX_ch_warm_white>` | `int` | `5` | DMX channel for Warm White. Used by `rgbww` and `color_temp` modes. |
120
+ | `<DMX_ch_color_temp>` | `int` | `6` | Dedicated CT channel if the fixture has one (uncommon). |
121
+
122
+ ---
123
+
124
+ ### Default ON Values
125
+
126
+ Values sent when the fixture turns ON with no prior known state in memory.
127
+ All values are raw 0–255 — gamma correction is applied automatically when sent to DMX.
128
+
129
+ | Variable | Type | Example | Description |
130
+ |---|---|---|---|
131
+ | `<DMX_default_on_v_brightness>` | `int` | `255` | Default brightness on first ON. |
132
+ | `<DMX_default_on_v_red>` | `int` | `255` | Default Red channel value. |
133
+ | `<DMX_default_on_v_green>` | `int` | `255` | Default Green channel value. |
134
+ | `<DMX_default_on_v_blue>` | `int` | `255` | Default Blue channel value. |
135
+ | `<DMX_default_on_v_white>` | `int` | `255` | Default Cold White channel value. |
136
+ | `<DMX_default_on_v_warm_white>` | `int` | `0` | Default Warm White channel value. Defaults to `0` if not set. |
137
+ | `<DMX_default_on_v_color_temp>` | `int` | `128` | Default color temperature in mireds. Defaults to `128` (midpoint between min/max) if not set. |
138
+ | `<DMX_Brightness_Initial_on_value>` | `int` | `40` | **Head-start bump value (0–255).** Sent instantly to DMX at the very start of a transition when the fixture is coming from OFF, giving the room immediate usable light before the slow fade completes. Set to `0` to disable. Only fires when state was `OFF` — ignored mid-transition between two ON states. |
139
+
140
+ ---
141
+
142
+ ### Default OFF Values
143
+
144
+ Values sent to DMX when the fixture turns OFF.
145
+
146
+ | Variable | Type | Example | Description |
147
+ |---|---|---|---|
148
+ | `<DMX_default_off_v_red>` | `int` | `0` | Red channel value when OFF. Defaults to `0`. |
149
+ | `<DMX_default_off_v_green>` | `int` | `0` | Green channel value when OFF. Defaults to `0`. |
150
+ | `<DMX_default_off_v_blue>` | `int` | `0` | Blue channel value when OFF. Defaults to `0`. |
151
+ | `<DMX_off_v_white>` | `int` | `0` | White channel value when OFF. |
152
+
153
+ ---
154
+
155
+ ### Color Temperature
156
+
157
+ Only relevant for `color_temp`, `rgbww`, `rgb,color_temp`, `rgbw,color_temp`, `rgbww,color_temp` modes.
158
+
159
+ | Variable | Type | Default | Description |
160
+ |---|---|---|---|
161
+ | `<DMX_ct_min_mireds>` | `int` | `153` | Minimum mireds value the fixture supports (~6500K cool white). HA maps this to Cold White = 255, Warm White = 0. |
162
+ | `<DMX_ct_max_mireds>` | `int` | `500` | Maximum mireds value the fixture supports (~2000K warm white). HA maps this to Cold White = 0, Warm White = 255. |
163
+
164
+ > **Tip:** Check your fixture's spec sheet for the actual min/max. Common values: cool-only = 153–200, warm-only = 370–500, full range = 153–500.
165
+
166
+ ---
167
+
168
+ ### Transitions
169
+
170
+ | Variable | Type | Default | Description |
171
+ |---|---|---|---|
172
+ | `<DMX_transition_ticks_ps>` | `int` | `31` | Transition interpolation steps per second for **this node only**. Higher = smoother fade but more DMX payloads per second from this fixture. 31 is a safe baseline. Tune up for premium fixtures, down for busy deployments. Multiplied by `<<<DMX_NODE_FLOW_Transition_Rate_Limit>>>` to get the effective tick rate. |
173
+
174
+ ---
175
+
176
+ ### Persistence
177
+
178
+ | Variable | Type | Example | Description |
179
+ |---|---|---|---|
180
+ | `<CONTEXT_STORE_values_to_disk_delay_in_seconds>` | `int` | `10` | How many seconds after the last command before RAM state is written to disk. Prevents excessive disk writes during rapid commands (e.g. dragging the colour wheel). Disk state survives NR restarts and HA reboots. |
181
+ | `<FIXTURE_Default_State>` | `string` | `OFF` | State reported to HA on first boot before any command has been received and before disk memory is available. `ON` or `OFF`. |
182
+
183
+ ---
184
+
185
+ ### Device Metadata
186
+
187
+ Informational only — populates the HA device info panel and MQTT discovery payload.
188
+
189
+ | Variable | Type | Example | Description |
190
+ |---|---|---|---|
191
+ | `<DEVICE_Type>` | `string` | `Spot` | Type of fixture (e.g. `Spot`, `Strip`, `Flood`, `Par`). |
192
+ | `<DEVICE_situation>` | `string` | `above` | Positional description (e.g. `above`, `behind`, `under`). |
193
+ | `<DEVICE_area>` | `string` | `Lounge` | Room or area the fixture is in. |
194
+ | `<DEVICE_Sub_Location>` | `string` | `Couch` | More specific location within the area (e.g. `Couch`, `TV`, `Entry`). |
195
+
196
+ ---
197
+
198
+ ### Node Metadata
199
+
200
+ | Variable | Type | Example | Description |
201
+ |---|---|---|---|
202
+ | `<NODE_code>` | `string` | `DMX-NODE` | Short identifier for this node type. Shown in HA device `sw_version` field. |
203
+ | `<NODE_sw_v>` | `string` | `0.5.0` | Software version of this node. Shown in HA device `sw_version` field. |
204
+
205
+ ---
206
+
207
+ ## RAM & Disk Memory Keys
208
+
209
+ These are not env vars — they are flow context store keys managed internally by the node.
210
+ Listed here for debugging reference (visible in NR context store panel).
211
+
212
+ | Key | Store | Description |
213
+ |---|---|---|
214
+ | `<<FIXTURE_RAM_Memory_State>>` | `memory` | Current state (`ON`/`OFF`) — fast access during operation. |
215
+ | `<<FIXTURE_Disk_Memory_State>>` | `disk_values` | Persisted state — survives reboot. |
216
+ | `<<bright>>` | `memory` | Current brightness (0–255). |
217
+ | `<<D_bright>>` | `disk_values` | Persisted brightness. |
218
+ | `<<red>>` | `memory` | Current Red value (0–255). |
219
+ | `<<D_red>>` | `disk_values` | Persisted Red value. |
220
+ | `<<green>>` | `memory` | Current Green value (0–255). |
221
+ | `<<D_green>>` | `disk_values` | Persisted Green value. |
222
+ | `<<blue>>` | `memory` | Current Blue value (0–255). |
223
+ | `<<D_blue>>` | `disk_values` | Persisted Blue value. |
224
+ | `<<white>>` | `memory` | Current Cold White value (0–255). |
225
+ | `<<D_white>>` | `disk_values` | Persisted Cold White value. |
226
+ | `<<warmWhite>>` | `memory` | Current Warm White value (0–255). |
227
+ | `<<D_warmWhite>>` | `disk_values` | Persisted Warm White value. |
228
+ | `<<colorTemp>>` | `memory` | Current color temperature (mireds). |
229
+ | `<<D_colorTemp>>` | `disk_values` | Persisted color temperature. |
230
+ | `timer_diskSave` | `node` | Handle for the debounced disk-write timer. |
231
+ | `timer_transition` | `node` | Handle for the active transition `setInterval`. |
232
+ | `timer_effect` | `node` | Handle for the active effect `setInterval`. |
233
+
234
+ ---
235
+
236
+ ## Quick Checklist — New Node Setup
237
+
238
+ - [ ] Set `<HA_unique_id>` — must be unique across all HA entities
239
+ - [ ] Set `<HA_supported_color_modes>` — drives everything else
240
+ - [ ] Set `<HA_brightness_scale_and_dmx_limiter>` — **required**, node errors without it
241
+ - [ ] Set `<DMX_min_output>` — default `1` (set to `0` for pure gamma, see note above)
242
+ - [ ] Set `<HA_Transitions_Enabled>` — `false` for `onoff` fixtures, `true` (or leave unset) for everything else
243
+ - [ ] Set DMX channels (`<DMX_ch_red>` etc.) for the fixture's mode
244
+ - [ ] Set `<DMX_default_on_v_*>` values to match fixture's expected default colours
245
+ - [ ] Set `<DMX_ct_min_mireds>` / `<DMX_ct_max_mireds>` if using any CT mode
246
+ - [ ] Set `<DMX_Brightness_Initial_on_value>` — `0` to disable head-start bump, or a low value like `30`–`60` for rooms where instant light matters
247
+ - [ ] Set `<FIXTURE_Default_State>` — usually `OFF`
248
+ - [ ] Set `<CONTEXT_STORE_values_to_disk_delay_in_seconds>` — `10` is a safe starting point
249
+ - [ ] Verify `<<<DMX_NODE_FLOW_Transition_Rate_Limit>>>` is set at flow level — `1` for normal
250
+ - [ ] Verify `<<<DMX_NODE_FLOW_Transition_HA_UI_Time_(seconds)>>>` is set at flow level — fallback transition duration
251
+
252
+ ---
253
+
254
+ ## Group Node Env Variables `<...>`
255
+
256
+ The Group Node uses mostly the same env keys as the DMX Node. Only the differences and additions are listed here.
257
+
258
+ ### Group Node — Differences from DMX Node
259
+
260
+ | Variable | Notes |
261
+ |---|---|
262
+ | `<HA_brightness_scale_and_dmx_limiter>` | **Not used** — Group Node has no DMX output. Brightness scale is always 255 (full range) for HA reporting. Children apply their own limiter. |
263
+ | `<DMX_ch_*>` | **Not used** — no DMX channels on a Group Node. |
264
+ | `<DMX_default_on_v_*>` / `<DMX_default_off_v_*>` | **Not used** — replaced by `<GRP_default_on_v_*>` (see below). |
265
+ | `<DMX_Brightness_Initial_on_value>` | **Not used** — initial bump lives at fixture level only. |
266
+ | `<DMX_transition_ticks_ps>` | **Not used** — Group Node does not run a transition engine. It forwards transition time to children who handle their own stepping. |
267
+ | `<HA_effects_list>` | Replaced by `<HA_group_effects_list>` — limited to group-safe effects only. |
268
+
269
+ ---
270
+
271
+ ### Group Node — Additions
272
+
273
+ | Variable | Type | Default | Description |
274
+ |---|---|---|---|
275
+ | `<HA_group_effects_list>` | `string` | `flash_short,flash_long,strobe,rainbow,fire,flicker,twinkle,color_chase,scan,random,police,christmas,halloween,calaveras,party,fireworks` | Comma-separated list of effects the Group Node advertises to HA and forwards to children. Excludes `sleep_transition` and `temperature_transition` which are fixture-level only. |
276
+ | `<DMX_Group_Max_Depth>` | `int` | `10` | Maximum AUX hop depth before a payload is dropped and `node.warn` is raised. Prevents infinite loops from accidental circular wiring. `0` = disabled (not recommended for production). Use the spinner in the Advanced env menu. |
277
+ | `<GRP_default_on_v_brightness>` | `int` | `255` | Default brightness for the Group Node's own HA state recovery after reboot. |
278
+ | `<GRP_default_on_v_red>` | `int` | `255` | Default Red for HA state recovery. |
279
+ | `<GRP_default_on_v_green>` | `int` | `255` | Default Green for HA state recovery. |
280
+ | `<GRP_default_on_v_blue>` | `int` | `255` | Default Blue for HA state recovery. |
281
+ | `<GRP_default_on_v_white>` | `int` | `255` | Default Cold White for HA state recovery. |
282
+ | `<GRP_default_on_v_warm_white>` | `int` | `0` | Default Warm White for HA state recovery. |
283
+ | `<GRP_default_on_v_color_temp>` | `int` | `128` | Default color temperature (mireds) for HA state recovery. |
284
+
285
+ ---
286
+
287
+ ### Group Node — RAM & Disk Memory Keys
288
+
289
+ | Key | Store | Description |
290
+ |---|---|---|
291
+ | `<<GRP_State>>` | `memory` | Current group state (`ON`/`OFF`). |
292
+ | `<<D_GRP_State>>` | `disk_values` | Persisted group state. |
293
+ | `<<bright>>` / `<<D_bright>>` | `memory` / `disk_values` | Same keys as DMX Node — shared naming convention. |
294
+ | `<<red>>` / `<<D_red>>` etc. | `memory` / `disk_values` | Same keys as DMX Node. |
295
+ | `timer_diskSave` | `node` | Debounced disk-write timer handle. |
296
+
297
+ ---
298
+
299
+ ### dmx_trace — AUX Payload Contract
300
+
301
+ Every payload forwarded from a Group Node to its children includes a `dmx_trace` object:
302
+
303
+ ```javascript
304
+ {
305
+ dmx_trace: {
306
+ source: "L-991-grp", // ID of the immediate parent Group Node
307
+ path: ["L-001-grp", "L-991-grp"], // full ancestry from root to immediate parent
308
+ depth: 2 // number of Group Node hops
309
+ },
310
+ payload: { // original HA command — unmodified
311
+ state: "ON",
312
+ brightness: 145,
313
+ transition: 3,
314
+ color: { r: 255, g: 58, b: 75 }
315
+ },
316
+ retain: false,
317
+ qos: 0
318
+ }
319
+ ```
320
+
321
+ - `source` — the immediate parent that sent this payload (useful for targeted fault-finding)
322
+ - `path` — full chain from root group to immediate parent (visible in NR debug panel)
323
+ - `depth` — compared against `<DMX_Group_Max_Depth>` on each hop; payload dropped if exceeded
324
+
325
+ The DMX Node detects `msg.dmx_trace` at its entry point and routes via the AUX handler, which strips the trace and processes `msg.payload` identically to a direct HA command.
326
+
327
+ ---
328
+
329
+ ### Group Node Output Wiring
330
+
331
+ | Output | Index | Use |
332
+ |---|---|---|
333
+ | 1 | `0` | MQTT — HA state topic + discovery config |
334
+ | 2 | `1` | MQTT — subscribe / unsubscribe actions |
335
+ | 3 | `2` | Node status + debug |
336
+ | 4 | `3` | Original `msg` passthrough (untouched) |
337
+ | **5** | **`4`** | **Fan-out to children — wire to DMX Node or child Group Node inputs** |
338
+ | 6 | `5` | Spare |
339
+ | 7 | `6` | Spare |
340
+
341
+ > Output 5 is the key wire. Connect it to the input of every DMX Node or child Group Node that belongs to this group.