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:
@@ -1,13 +1,10 @@
|
||||
// Run this AFTER nvl-receive. Syncs all mapped lights from PLC state to HA entities.
|
||||
// Map comes from global roomConfig (single source of truth). See /root/.node-red/room-config.js.
|
||||
// Connect output 1 → Action node (turn_on), output 2 → Action node (turn_off).
|
||||
// Format matches node-red-contrib-home-assistant-websocket "Action" node: payload.action + payload.target.entity_id (array).
|
||||
// Only outputs when state changed (per entity). Add more entries to LIGHT_ENTITY_MAP as you add rooms/lights.
|
||||
|
||||
// Map: NVL room key (in payload) + light index 1..6 → HA entity_id
|
||||
const LIGHT_ENTITY_MAP = [
|
||||
const config = global.get('roomConfig');
|
||||
const LIGHT_ENTITY_MAP = (config && config.lightEntityMap && config.lightEntityMap.length) ? config.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: 'light.kitchen_ceiling' },
|
||||
];
|
||||
|
||||
const payload = msg.payload || {};
|
||||
|
||||
Reference in New Issue
Block a user