Refactor room and light configurations for Node-RED integration

- Updated global variable lists in GVL_IO.gvl and GVL_NVL_placeholders.gvl to reflect new room naming conventions and structures.
- Revised PLC_App.st to map new room configurations for lighting control.
- Enhanced documentation in all-lights-and-rooms.md and ha-lights-and-rooms.md to align with updated room and light entity naming.
- Adjusted room-config.js and related Node-RED flows to support the new configuration structure.

This update improves the organization and clarity of room and light management within the Node-RED integration, ensuring consistency across the system.
This commit is contained in:
2026-04-01 19:09:59 +03:00
parent d755d3c1ed
commit 0af21f4dc3
16 changed files with 579 additions and 220 deletions

View File

@@ -10,6 +10,11 @@ To avoid adding a new room or light in several places, use **one config file** t
**Config file:** [`node-red/config_files/room-config.js`](../../node-red/config_files/room-config.js) — exports `ROOM_CONFIG` with: **roomNames** (NVL SEND), **lightEntityMap** (NVL to HA Sync), **entityToRoom** (HA to NVL), **deviceToRoom** (Zigbee to NVL).
Canonical source-of-truth for this migration:
- Electrical mapping: [`../Electrical/lights_zones_canonical.csv`](../Electrical/lights_zones_canonical.csv)
- Naming rules: [`../Electrical/naming_rules.md`](../Electrical/naming_rules.md)
**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', ...)`.
@@ -39,14 +44,14 @@ Use a single list of room keys everywhere. Example (match your CODESYS NVL order
| Room key (Node-RED / NVL) | PLC NVL_Out (receive) | Lights per room |
|---------------------------|------------------------|-----------------|
| `livingRoom` | `l_livingRoom` | 1..6 |
| `masterBedroom` | `l_masterBedroom` | 1..6 |
| `kitchen` | `l_kitchen` | 1..6 |
| `bathroom` | `l_bathroom` | 1..6 |
| `open_plan_living_room` | `l_open_plan_living_room` | 1..6 |
| `open_plan_guest_wc` | `l_open_plan_guest_wc` | 1..6 |
| `kitchen_kitchen` | `l_kitchen_kitchen` | 1..6 |
| `master_bedroom_suite` | `l_master_bedroom_suite` | 1..6 |
| … | … | 1..6 |
- **NVL send (to PLC):** same keys as NVL_In in CODESYS (e.g. `livingRoom`, `masterBedroom`, … or `cmd_livingroom` for the test slot). Order and names must match the PLC.
- **NVL receive (from PLC):** keys in the nvl-receive output (e.g. `l_livingRoom`, `light_livingRoom`) — use the same key in **LIGHT_ENTITY_MAP** in the sync function.
- **NVL send (to PLC):** same keys as NVL_In in CODESYS (e.g. `open_plan_living_room`, `master_bedroom_suite`). Order and names must match the PLC.
- **NVL receive (from PLC):** keys in the nvl-receive output (e.g. `l_open_plan_living_room`) — use the same key in **LIGHT_ENTITY_MAP** in the sync function.
Keep one list (e.g. in a comment or config file) and use it in:
- **state-to-nvl-send-payload.js** → `roomNames`
@@ -254,9 +259,9 @@ Add or remove lines to match your rooms and light counts. Entity IDs become `inp
Use a **consistent pattern** so you can derive room + light in Node-RED and in YAML:
- **Entity ID:** `input_boolean.<room>_<light>`
Examples: `living_room_1`, `kitchen_2`, `master_bedroom_1`.
- Then in HA to NVL you can parse: room from the first part, light from the trailing number.
- **Entity ID:** `input_boolean.<area>_<room>_<light_type>_<index>`
Examples: `input_boolean.open_plan_living_room_main_1`, `input_boolean.kitchen_kitchen_island_1`, `input_boolean.exterior_yard_driveway_1`.
- In HA to NVL, parse room mapping from `entityToRoom` using the base without the trailing `_<index>`.
---