- 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.
14 lines
707 B
JavaScript
14 lines
707 B
JavaScript
// Paste this into a Function node named "Load room config".
|
|
// Connect an Inject node (once after 0.5 s) to it so it runs at startup.
|
|
//
|
|
// Since functionExternalModules is true in settings.js, you can require files.
|
|
// room-config.js must be on the Node-RED server at /root/.node-red/room-config.js
|
|
|
|
// Delete cached version so changes to the file are picked up on redeploy
|
|
delete require.cache[require.resolve('/root/.node-red/room-config.js')];
|
|
const ROOM_CONFIG = require('/root/.node-red/room-config.js');
|
|
|
|
global.set('roomConfig', ROOM_CONFIG);
|
|
node.warn('[Load room config] loaded: ' + ROOM_CONFIG.roomNames.length + ' rooms, ' + ROOM_CONFIG.lightEntityMap.length + ' light mappings');
|
|
return null;
|