node-red-contrib-dmx-for-ha 0.3.9 → 0.4.1
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.
- package/nodes/ha-mqtt-dmx-group.js +17 -5
- package/package.json +1 -1
|
@@ -236,6 +236,15 @@ module.exports = function (RED) {
|
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
|
|
240
|
+
function groupStatus(state, label) {
|
|
241
|
+
if (state === 'ON') {
|
|
242
|
+
setStatus('green', 'dot', label || `${groupId} ON`);
|
|
243
|
+
} else {
|
|
244
|
+
setStatus('grey', 'ring', label || `${groupId} OFF`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
239
248
|
// ── Device add ────────────────────────────────────────────
|
|
240
249
|
function handleDeviceAdd(incomingTrace) {
|
|
241
250
|
if (!ctxGet('state') && !ctxGet('state', 'disk_values')) {
|
|
@@ -284,7 +293,7 @@ module.exports = function (RED) {
|
|
|
284
293
|
pubState({ state: payload.state, color_mode: S.colorMode, brightness: payload.brightness });
|
|
285
294
|
forwardToChildren(payload, null);
|
|
286
295
|
const _lbl = payload.effect ? `effect:${payload.effect}` : `${payload.state}`;
|
|
287
|
-
|
|
296
|
+
groupStatus(payload.state, `${groupId} → ${_lbl}`);
|
|
288
297
|
}, node.id);
|
|
289
298
|
|
|
290
299
|
setStatus('green', 'ring', `${groupId} discovery sent`);
|
|
@@ -297,8 +306,10 @@ module.exports = function (RED) {
|
|
|
297
306
|
const brightness = recall('brightness', 'brightness_disk', 255);
|
|
298
307
|
const color = recall('color', 'color_disk', null);
|
|
299
308
|
pubState({ state, color_mode: S.colorMode, brightness, color });
|
|
300
|
-
|
|
301
|
-
|
|
309
|
+
// NOTE: do NOT forward to children on recovery — each child node
|
|
310
|
+
// recovers its own state independently from its own disk store.
|
|
311
|
+
// Forwarding here would overwrite children with the group's state.
|
|
312
|
+
groupStatus(state, `${groupId} → ${state}`);
|
|
302
313
|
node.log(`${groupId} recovery — state:${state}`);
|
|
303
314
|
}, 2000);
|
|
304
315
|
}
|
|
@@ -306,6 +317,7 @@ module.exports = function (RED) {
|
|
|
306
317
|
// ── Device remove ─────────────────────────────────────────
|
|
307
318
|
function handleDeviceRemove(incomingTrace) {
|
|
308
319
|
if (diskTimer) { clearTimeout(diskTimer); diskTimer = null; }
|
|
320
|
+
// No flush needed on remove — state is cleared below
|
|
309
321
|
ctxSet('state', null); ctxSet('state', null, 'disk_values');
|
|
310
322
|
pub(cfgTopic, '', true);
|
|
311
323
|
broker.unsubscribe(cmdTopic, node.id);
|
|
@@ -327,7 +339,7 @@ module.exports = function (RED) {
|
|
|
327
339
|
saveGroupState(msg.payload);
|
|
328
340
|
pubState({ state: msg.payload.state, color_mode: S.colorMode, brightness: msg.payload.brightness });
|
|
329
341
|
forwardToChildren(msg.payload, msg.dmx_trace);
|
|
330
|
-
|
|
342
|
+
groupStatus(msg.payload.state, `${groupId} → cascade:${msg.payload.state}`);
|
|
331
343
|
}
|
|
332
344
|
} else {
|
|
333
345
|
const devReq = typeof msg.device === 'string'
|
|
@@ -344,7 +356,7 @@ module.exports = function (RED) {
|
|
|
344
356
|
saveGroupState(msg.payload);
|
|
345
357
|
pubState({ state: msg.payload.state, color_mode: S.colorMode, brightness: msg.payload.brightness });
|
|
346
358
|
forwardToChildren(msg.payload, null);
|
|
347
|
-
|
|
359
|
+
groupStatus(msg.payload.state, `${groupId} → ${msg.payload.state}`);
|
|
348
360
|
} else {
|
|
349
361
|
node.warn(`${groupId} — unrecognised message received and dropped. See node documentation.`);
|
|
350
362
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-dmx-for-ha",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "DMX lighting control for Home Assistant via Node-RED and MQTT. Place a node, fill in the settings, deploy. Full HA device registry integration with RGBW/RGBWW/CCT/brightness colour modes, transitions, effects, and group control.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|