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:
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
ccc/**
|
||||
/**
|
||||
* Single source of truth for rooms and lights.
|
||||
* Lives on the Node-RED server at /root/.node-red/room-config.js
|
||||
* All function nodes use: global.get('roomConfig')
|
||||
@@ -9,56 +9,111 @@ ccc/**
|
||||
const ROOM_CONFIG = {
|
||||
// Order must match CODESYS NVL_In. Used by NVL SEND (state-to-nvl-send-payload).
|
||||
roomNames: [
|
||||
'cmd_livingroom',
|
||||
'cmd_out', // add other NVL room keys as needed
|
||||
// 'masterBedroom',
|
||||
// 'masterBathroom',
|
||||
// 'bedroom_1',
|
||||
// 'bedroom_2',
|
||||
// 'bathroom',
|
||||
// 'guestWc',
|
||||
// 'kitchen',
|
||||
// 'pantry',
|
||||
// 'livingRoom',
|
||||
// 'dinningRoom',
|
||||
// 'entrance',
|
||||
// 'hallway',
|
||||
// 'outVeranda',
|
||||
// 'outFront',
|
||||
// 'outBack',
|
||||
// 'outSide',
|
||||
'open_plan_living_room',
|
||||
'open_plan_dining_room',
|
||||
'open_plan_entrance',
|
||||
'open_plan_guest_wc',
|
||||
'kitchen_kitchen',
|
||||
'kitchen_pantry',
|
||||
'bedrooms_office',
|
||||
'bedrooms_hallway',
|
||||
'bedrooms_laundry',
|
||||
'bedrooms_shower',
|
||||
'bedrooms_bedroom',
|
||||
'master_bedroom_suite',
|
||||
'master_bedroom_bathroom',
|
||||
'exterior_veranda',
|
||||
'exterior_entrance',
|
||||
'exterior_yard',
|
||||
],
|
||||
|
||||
// PLC → HA sync. room = key in nvl-receive payload, light = 1..6, entityId = HA entity.
|
||||
lightEntityMap: [
|
||||
{ room: 'light_livingRoom', light: 1, entityId: 'input_boolean.living_room_new' },
|
||||
// { room: 'light_livingRoom', light: 2, entityId: 'input_boolean.living_room_2' },
|
||||
// { room: 'l_kitchen', light: 1, entityId: 'input_boolean.kitchen_1' },
|
||||
{ room: 'l_open_plan_living_room', light: 1, entityId: 'input_boolean.open_plan_living_room_main_1' },
|
||||
{ room: 'l_open_plan_living_room', light: 2, entityId: 'input_boolean.open_plan_living_room_spots_1' },
|
||||
{ room: 'l_open_plan_dining_room', light: 1, entityId: 'input_boolean.open_plan_dining_room_main_1' },
|
||||
{ room: 'l_open_plan_dining_room', light: 2, entityId: 'input_boolean.open_plan_dining_room_spots_1' },
|
||||
{ room: 'l_open_plan_entrance', light: 1, entityId: 'input_boolean.open_plan_entrance_mirror_1' },
|
||||
{ room: 'l_open_plan_entrance', light: 2, entityId: 'input_boolean.open_plan_entrance_main_1' },
|
||||
{ room: 'l_open_plan_guest_wc', light: 1, entityId: 'input_boolean.open_plan_guest_wc_main_1' },
|
||||
{ room: 'l_open_plan_guest_wc', light: 2, entityId: 'input_boolean.open_plan_guest_wc_strip_1' },
|
||||
{ room: 'l_open_plan_guest_wc', light: 3, entityId: 'input_boolean.open_plan_guest_wc_fan_1' },
|
||||
{ room: 'l_open_plan_living_room', light: 3, entityId: 'input_boolean.open_plan_living_room_strip_1' },
|
||||
{ room: 'l_open_plan_living_room', light: 4, entityId: 'input_boolean.open_plan_living_room_strip_2' },
|
||||
{ room: 'l_kitchen_kitchen', light: 1, entityId: 'input_boolean.kitchen_kitchen_main_1' },
|
||||
{ room: 'l_kitchen_kitchen', light: 2, entityId: 'input_boolean.kitchen_kitchen_island_1' },
|
||||
{ room: 'l_kitchen_kitchen', light: 3, entityId: 'input_boolean.kitchen_kitchen_cabinets_1' },
|
||||
{ room: 'l_kitchen_kitchen', light: 4, entityId: 'input_boolean.kitchen_kitchen_fridge_1' },
|
||||
{ room: 'l_kitchen_pantry', light: 1, entityId: 'input_boolean.kitchen_pantry_main_1' },
|
||||
{ room: 'l_bedrooms_office', light: 1, entityId: 'input_boolean.bedrooms_office_main_1' },
|
||||
{ room: 'l_bedrooms_office', light: 2, entityId: 'input_boolean.bedrooms_office_strip_1' },
|
||||
{ room: 'l_bedrooms_hallway', light: 1, entityId: 'input_boolean.bedrooms_hallway_main_1' },
|
||||
{ room: 'l_bedrooms_laundry', light: 1, entityId: 'input_boolean.bedrooms_laundry_main_1' },
|
||||
{ room: 'l_bedrooms_shower', light: 1, entityId: 'input_boolean.bedrooms_shower_spots_1' },
|
||||
{ room: 'l_bedrooms_shower', light: 2, entityId: 'input_boolean.bedrooms_shower_fan_1' },
|
||||
{ room: 'l_bedrooms_bedroom', light: 1, entityId: 'input_boolean.bedrooms_bedroom_main_1' },
|
||||
{ room: 'l_bedrooms_bedroom', light: 2, entityId: 'input_boolean.bedrooms_bedroom_spots_1' },
|
||||
{ room: 'l_master_bedroom_suite', light: 1, entityId: 'input_boolean.master_bedroom_suite_main_1' },
|
||||
{ room: 'l_master_bedroom_suite', light: 2, entityId: 'input_boolean.master_bedroom_suite_spots_1' },
|
||||
{ room: 'l_master_bedroom_suite', light: 3, entityId: 'input_boolean.master_bedroom_suite_strip_1' },
|
||||
{ room: 'l_master_bedroom_suite', light: 4, entityId: 'input_boolean.master_bedroom_suite_door_1' },
|
||||
{ room: 'l_master_bedroom_suite', light: 5, entityId: 'input_boolean.master_bedroom_suite_dresser_1' },
|
||||
{ room: 'l_master_bedroom_bathroom', light: 1, entityId: 'input_boolean.master_bedroom_bathroom_spots_1' },
|
||||
{ room: 'l_master_bedroom_bathroom', light: 2, entityId: 'input_boolean.master_bedroom_bathroom_fan_1' },
|
||||
{ room: 'l_exterior_veranda', light: 1, entityId: 'input_boolean.exterior_veranda_main_1' },
|
||||
{ room: 'l_exterior_yard', light: 1, entityId: 'input_boolean.exterior_yard_bbq_1' },
|
||||
{ room: 'l_exterior_entrance', light: 1, entityId: 'input_boolean.exterior_entrance_door_1' },
|
||||
{ room: 'l_exterior_yard', light: 2, entityId: 'input_boolean.exterior_yard_front_lights_1' },
|
||||
{ room: 'l_exterior_yard', light: 3, entityId: 'input_boolean.exterior_yard_backyard_flood_light_1' },
|
||||
{ room: 'l_exterior_yard', light: 4, entityId: 'input_boolean.exterior_yard_backyard_flood_light_2' },
|
||||
{ room: 'l_exterior_yard', light: 5, entityId: 'input_boolean.exterior_yard_master_bedroom_flood_light_1' },
|
||||
{ room: 'l_exterior_yard', light: 6, entityId: 'input_boolean.exterior_yard_driveway_1' },
|
||||
],
|
||||
|
||||
// HA entity_id substring (after domain.) without trailing _N → NVL room key. For HA to NVL.
|
||||
entityToRoom: {
|
||||
// living_room: 'livingRoom',
|
||||
living_room_new: 'cmd_livingroom',
|
||||
// kitchen: 'kitchen',
|
||||
// master_bedroom: 'masterBedroom',
|
||||
// bathroom: 'bathroom',
|
||||
// bedroom_1: 'bedroom_1',
|
||||
// bedroom_2: 'bedroom_2',
|
||||
// dinning_room: 'dinningRoom',
|
||||
// entrance: 'entrance',
|
||||
// hallway: 'hallway',
|
||||
// pantry: 'pantry',
|
||||
// guest_wc: 'guestWc',
|
||||
// out_veranda: 'outVeranda',
|
||||
// out_front: 'outFront',
|
||||
// out_back: 'outBack',
|
||||
// out_side: 'outSide',
|
||||
open_plan_living_room_main: 'open_plan_living_room',
|
||||
open_plan_living_room_spots: 'open_plan_living_room',
|
||||
open_plan_living_room_strip: 'open_plan_living_room',
|
||||
open_plan_dining_room_main: 'open_plan_dining_room',
|
||||
open_plan_dining_room_spots: 'open_plan_dining_room',
|
||||
open_plan_entrance_mirror: 'open_plan_entrance',
|
||||
open_plan_entrance_main: 'open_plan_entrance',
|
||||
open_plan_guest_wc_main: 'open_plan_guest_wc',
|
||||
open_plan_guest_wc_strip: 'open_plan_guest_wc',
|
||||
open_plan_guest_wc_fan: 'open_plan_guest_wc',
|
||||
kitchen_kitchen_main: 'kitchen_kitchen',
|
||||
kitchen_kitchen_island: 'kitchen_kitchen',
|
||||
kitchen_kitchen_cabinets: 'kitchen_kitchen',
|
||||
kitchen_kitchen_fridge: 'kitchen_kitchen',
|
||||
kitchen_pantry_main: 'kitchen_pantry',
|
||||
bedrooms_office_main: 'bedrooms_office',
|
||||
bedrooms_office_strip: 'bedrooms_office',
|
||||
bedrooms_hallway_main: 'bedrooms_hallway',
|
||||
bedrooms_laundry_main: 'bedrooms_laundry',
|
||||
bedrooms_shower_spots: 'bedrooms_shower',
|
||||
bedrooms_shower_fan: 'bedrooms_shower',
|
||||
bedrooms_bedroom_main: 'bedrooms_bedroom',
|
||||
bedrooms_bedroom_spots: 'bedrooms_bedroom',
|
||||
master_bedroom_suite_main: 'master_bedroom_suite',
|
||||
master_bedroom_suite_spots: 'master_bedroom_suite',
|
||||
master_bedroom_suite_strip: 'master_bedroom_suite',
|
||||
master_bedroom_suite_door: 'master_bedroom_suite',
|
||||
master_bedroom_suite_dresser: 'master_bedroom_suite',
|
||||
master_bedroom_bathroom_spots: 'master_bedroom_bathroom',
|
||||
master_bedroom_bathroom_fan: 'master_bedroom_bathroom',
|
||||
exterior_veranda_main: 'exterior_veranda',
|
||||
exterior_yard_bbq: 'exterior_yard',
|
||||
exterior_entrance_door: 'exterior_entrance',
|
||||
exterior_yard_front_lights: 'exterior_yard',
|
||||
exterior_yard_backyard_flood_light: 'exterior_yard',
|
||||
exterior_yard_master_bedroom_flood_light: 'exterior_yard',
|
||||
exterior_yard_driveway: 'exterior_yard',
|
||||
},
|
||||
|
||||
// // Zigbee: friendly_name → single room (fallback when switchBindings missing).
|
||||
// deviceToRoom: {
|
||||
// 'Office Switch': 'cmd_livingroom',
|
||||
// 'Office Switch': 'open_plan_living_room',
|
||||
// },
|
||||
|
||||
// When using a multi-device Zigbee node, payload is keyed by IEEE (e.g. 0xa4c138a5b9771b05). Map IEEE → friendly name so switchBindings by name still works.
|
||||
@@ -68,7 +123,7 @@ const ROOM_CONFIG = {
|
||||
|
||||
// Optional: bind by IEEE instead of friendly name (same shape as switchBindings). Use if the node never sends friendly_name.
|
||||
// switchBindingsByDeviceId: {
|
||||
// '0xa4c138a5b9771b05': { 1: { room: 'cmd_livingroom', light: 1 }, 2: { room: 'cmd_out', light: 2 } },
|
||||
// '0xa4c138a5b9771b05': { 1: { room: 'open_plan_living_room', light: 1 }, 2: { room: 'open_plan_dining_room', light: 1 } },
|
||||
// },
|
||||
|
||||
/**
|
||||
@@ -78,8 +133,8 @@ const ROOM_CONFIG = {
|
||||
*/
|
||||
switchBindings: {
|
||||
'Office Switch': {
|
||||
1: { room: 'cmd_livingroom', light: 1 }, // button 1 → light 1
|
||||
2: { room: 'cmd_livingroom', light: 2 }, // button 2 → light 1 (same light; other switches could do button 2 → light 2)
|
||||
1: { room: 'open_plan_living_room', light: 1 },
|
||||
2: { room: 'open_plan_dining_room', light: 1 },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user