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

@@ -4,6 +4,20 @@ This doc explains how to scale the working “test light” setup to **all your
---
## 0. Single global room config (recommended)
To avoid adding a new room or light in several places, use **one config file** that lives on the Node-RED server and is loaded into **global context** at startup. All function nodes read from `global.get('roomConfig')`.
**Config file:** [`node-red/room-config.js`](../../node-red/room-config.js) — exports `ROOM_CONFIG` with: **roomNames** (NVL SEND), **lightEntityMap** (NVL to HA Sync), **entityToRoom** (HA to NVL), **deviceToRoom** (Zigbee to NVL).
**Server location:** `/root/.node-red/room-config.js` (uploaded via `scp`).
**Loader:** [`node-red/room-config-loader.js`](../../node-red/room-config-loader.js) — paste this code into a **Function node** named "Load room config". Connect an **Inject node** (once after 0.5 s) to it and deploy. It `require()`s the config file, clears the cache (so edits are picked up on redeploy), and sets `global.set('roomConfig', ...)`.
**Adding a room or light:** Edit `room-config.js` locally, `scp` it to the server, and redeploy (or restart Node-RED). No function nodes need editing.
---
## 1. How it works (recap)
- **HA / Zigbee** → Node-RED updates **`flow.nvlInState.rooms.<roomKey>`** (e.g. `ha_l1_on`, `zigbee_sw2`).