Implement global room configuration for Node-RED integration

- Introduced a single global room configuration file to streamline the management of rooms and lights, reducing redundancy in configuration.
- Updated various integration scripts to utilize the global configuration, enhancing maintainability and clarity.
- Improved documentation to reflect the new configuration approach, including instructions for loading and modifying the room configuration.

This update simplifies the integration process and improves the overall user experience for managing lights and rooms in Node-RED.
This commit is contained in:
2026-02-08 17:49:07 +02:00
parent 714aa84504
commit c049a28c97
7 changed files with 118 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
// Build the payload for nvl-send from flow.nvlInState.
// Redesign: all rooms use struct_room_cmds. Add more names to roomNames when you add rooms.
// Room list comes from global roomConfig (single source of truth). See /root/.node-red/room-config.js.
// Wire: HA to NVL / Zigbee to NVL → this function → nvl-send → udp out
const struct_room_cmds_default = {
@@ -11,8 +11,8 @@ const struct_room_cmds_default = {
ha_all_on: false, ha_all_off: false
};
// NVL variable names per room (struct_room_cmds). Add more when you add rooms.
const roomNames = ['cmd_livingroom'];
const config = global.get('roomConfig');
const roomNames = (config && config.roomNames && config.roomNames.length) ? config.roomNames : ['cmd_livingroom'];
const state = flow.get('nvlInState') || { rooms: {}, boiler: {} };
const rooms = state.rooms || {};