// 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;