- Updated documentation to clarify the mapping of Zigbee buttons to specific (room, light) pairs using `switchBindings`. - Improved the Zigbee to NVL function to support both single-device and multi-device payloads, enhancing flexibility in handling actions. - Revised the room configuration to include detailed switch bindings and fallback mechanisms for device identification, streamlining the integration process. This update improves the usability and functionality of the Zigbee integration within Node-RED, facilitating better control of lighting systems.
23 lines
885 B
JavaScript
23 lines
885 B
JavaScript
// Paste into a Function node named "Reload room config from payload".
|
|
// Input: msg.payload = JSON string (from Exec node that runs the script below).
|
|
// Sets global roomConfig so all flows see the new config without restarting Node-RED.
|
|
|
|
const raw = msg.payload;
|
|
if (typeof raw !== 'string') {
|
|
node.warn('[Reload config] expected string payload, got ' + typeof raw);
|
|
return null;
|
|
}
|
|
try {
|
|
const config = JSON.parse(raw.trim());
|
|
if (!config.roomNames || !Array.isArray(config.roomNames)) {
|
|
node.error('[Reload config] invalid config: missing roomNames');
|
|
return null;
|
|
}
|
|
global.set('roomConfig', config);
|
|
node.warn('[Reload config] OK: ' + config.roomNames.length + ' rooms, ' + (config.lightEntityMap ? config.lightEntityMap.length : 0) + ' light mappings');
|
|
return msg;
|
|
} catch (e) {
|
|
node.error('[Reload config] parse error: ' + e.message);
|
|
return null;
|
|
}
|