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:
@@ -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>`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -2,6 +2,15 @@
|
||||
|
||||
This guide covers how to create the light/switch entities that Node-RED and the PLC use, and how to assign them to **rooms** (HA **Areas**) so you can manage and display them by room.
|
||||
|
||||
Canonical naming in this project is now:
|
||||
|
||||
- `input_boolean.<area>_<room>_<light_type>_<index>`
|
||||
- Example: `input_boolean.open_plan_living_room_main_1`
|
||||
|
||||
Pre-generated helper YAML for the current electrical plan:
|
||||
|
||||
- [`lights_by_area_room_type_index.yaml`](lights_by_area_room_type_index.yaml)
|
||||
|
||||
---
|
||||
|
||||
## 1. Concepts
|
||||
@@ -41,18 +50,13 @@ Create one file per room (or one file with sections) so entities are grouped by
|
||||
|
||||
```yaml
|
||||
# PLC/Node-RED lights – entity_id must match room-config.js (entityToRoom, lightEntityMap)
|
||||
# Naming: <room>_<light_num> e.g. living_room_1, kitchen_2
|
||||
# Naming: <area>_<room>_<light_type>_<index> e.g. open_plan_living_room_main_1
|
||||
|
||||
input_boolean:
|
||||
# Living room
|
||||
living_room_1: { name: Living Room 1 }
|
||||
living_room_2: { name: Living Room 2 }
|
||||
# Kitchen
|
||||
kitchen_1: { name: Kitchen 1 }
|
||||
kitchen_2: { name: Kitchen 2 }
|
||||
# Hallway
|
||||
hallway_1: { name: Hallway 1 }
|
||||
# Add more: master_bedroom_1, bathroom_1, entrance_1, etc.
|
||||
open_plan_living_room_main_1: { name: Open Plan Living Room Main 1 }
|
||||
open_plan_living_room_spots_1: { name: Open Plan Living Room Spots 1 }
|
||||
kitchen_kitchen_main_1: { name: Kitchen Main 1 }
|
||||
bedrooms_hallway_main_1: { name: Bedrooms Hallway Main 1 }
|
||||
```
|
||||
|
||||
Ensure `configuration.yaml` has:
|
||||
@@ -62,7 +66,7 @@ homeassistant:
|
||||
packages: !include_dir_named packages
|
||||
```
|
||||
|
||||
Restart Home Assistant. All entities are created. Entity IDs will be `input_boolean.living_room_1`, etc.
|
||||
Restart Home Assistant. All entities are created. Entity IDs will be `input_boolean.open_plan_living_room_main_1`, etc.
|
||||
|
||||
### Option B: UI (one by one)
|
||||
|
||||
@@ -99,9 +103,9 @@ Use the **same entity_id and room logic** in both places.
|
||||
|
||||
**Naming convention that works well:**
|
||||
|
||||
- Entity ID: `input_boolean.<room>_<number>`
|
||||
Examples: `living_room_1`, `kitchen_2`, `hallway_1`.
|
||||
- In **entityToRoom** use the part without the number: `living_room`, `kitchen`, `hallway` (and any alias like `living_room_new` → `cmd_livingroom`).
|
||||
- Entity ID: `input_boolean.<area>_<room>_<light_type>_<index>`
|
||||
Examples: `open_plan_living_room_main_1`, `kitchen_kitchen_island_1`, `exterior_yard_driveway_1`.
|
||||
- In **entityToRoom** use the part without trailing `_<index>`, e.g. `open_plan_living_room_main` or `exterior_yard_driveway`.
|
||||
|
||||
When you add a new light in HA (new entity_id), add or update:
|
||||
|
||||
|
||||
47
docs/integration/lights_by_area_room_type_index.yaml
Normal file
47
docs/integration/lights_by_area_room_type_index.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
# Home Assistant helpers for the canonical lighting naming model.
|
||||
# Naming: input_boolean.<area>_<room>_<light_type>_<index>
|
||||
|
||||
input_boolean:
|
||||
open_plan_living_room_main_1: { name: Open Plan Living Room Main 1 }
|
||||
open_plan_living_room_spots_1: { name: Open Plan Living Room Spots 1 }
|
||||
open_plan_dining_room_main_1: { name: Open Plan Dining Room Main 1 }
|
||||
open_plan_dining_room_spots_1: { name: Open Plan Dining Room Spots 1 }
|
||||
open_plan_entrance_mirror_1: { name: Open Plan Entrance Mirror 1 }
|
||||
open_plan_entrance_main_1: { name: Open Plan Entrance Main 1 }
|
||||
open_plan_guest_wc_main_1: { name: Open Plan Guest WC Main 1 }
|
||||
open_plan_guest_wc_strip_1: { name: Open Plan Guest WC Strip 1 }
|
||||
open_plan_guest_wc_fan_1: { name: Open Plan Guest WC Fan 1 }
|
||||
open_plan_living_room_strip_1: { name: Open Plan Living Room Strip 1 }
|
||||
open_plan_living_room_strip_2: { name: Open Plan Living Room Strip 2 }
|
||||
|
||||
kitchen_kitchen_main_1: { name: Kitchen Main 1 }
|
||||
kitchen_kitchen_island_1: { name: Kitchen Island 1 }
|
||||
kitchen_kitchen_cabinets_1: { name: Kitchen Cabinets 1 }
|
||||
kitchen_kitchen_fridge_1: { name: Kitchen Fridge 1 }
|
||||
kitchen_pantry_main_1: { name: Kitchen Pantry Main 1 }
|
||||
|
||||
bedrooms_office_main_1: { name: Bedrooms Office Main 1 }
|
||||
bedrooms_office_strip_1: { name: Bedrooms Office Strip 1 }
|
||||
bedrooms_hallway_main_1: { name: Bedrooms Hallway Main 1 }
|
||||
bedrooms_laundry_main_1: { name: Bedrooms Laundry Main 1 }
|
||||
bedrooms_shower_spots_1: { name: Bedrooms Shower Spots 1 }
|
||||
bedrooms_shower_fan_1: { name: Bedrooms Shower Fan 1 }
|
||||
bedrooms_bedroom_main_1: { name: Bedrooms Bedroom Main 1 }
|
||||
bedrooms_bedroom_spots_1: { name: Bedrooms Bedroom Spots 1 }
|
||||
|
||||
master_bedroom_suite_main_1: { name: Master Bedroom Suite Main 1 }
|
||||
master_bedroom_suite_spots_1: { name: Master Bedroom Suite Spots 1 }
|
||||
master_bedroom_suite_strip_1: { name: Master Bedroom Suite Strip 1 }
|
||||
master_bedroom_suite_door_1: { name: Master Bedroom Suite Door 1 }
|
||||
master_bedroom_suite_dresser_1: { name: Master Bedroom Suite Dresser 1 }
|
||||
master_bedroom_bathroom_spots_1: { name: Master Bedroom Bathroom Spots 1 }
|
||||
master_bedroom_bathroom_fan_1: { name: Master Bedroom Bathroom Fan 1 }
|
||||
|
||||
exterior_veranda_main_1: { name: Exterior Veranda Main 1 }
|
||||
exterior_entrance_door_1: { name: Exterior Entrance Door 1 }
|
||||
exterior_yard_bbq_1: { name: Exterior Yard BBQ 1 }
|
||||
exterior_yard_front_lights_1: { name: Exterior Yard Front Lights 1 }
|
||||
exterior_yard_backyard_flood_light_1: { name: Exterior Yard Backyard Flood Light 1 }
|
||||
exterior_yard_backyard_flood_light_2: { name: Exterior Yard Backyard Flood Light 2 }
|
||||
exterior_yard_master_bedroom_flood_light_1: { name: Exterior Yard Master Bedroom Flood Light 1 }
|
||||
exterior_yard_driveway_1: { name: Exterior Yard Driveway 1 }
|
||||
Reference in New Issue
Block a user