I'm running into the following issue: I'm using NodeRED with the newest version of node-red-contrib-sonoff-server. The different in this version is that the node loads only the sonoff Dispatch/WS module (sonoff.server.module.js) but not the API part (sonoff.server.js). So if I need the API part I have to stop NodeRED (to avoid network port conflict) and manually run sonoff.server.js. This is a bit inconvenient since NodeRED is driving my real home automation flows.
That made me thinking if it is possible to implement the API part as a separate module (for example sonoff.api.server.module.js). It would accept "devices" object in its constructor. The file sonoff.server.js will stay the classic standalone nodejs app. It will take care only for building config, env vars and creating instances. Something like:
// call sonoff server for device handling
var devices = sonoffServer.createServer(config);
var apiServer = sonoffApiServer.createServer({sonoffServer: devices});
This way node-red-contrib-sonoff-server may load both modules that share the same device repository.
I'm running into the following issue: I'm using NodeRED with the newest version of node-red-contrib-sonoff-server. The different in this version is that the node loads only the sonoff Dispatch/WS module (sonoff.server.module.js) but not the API part (sonoff.server.js). So if I need the API part I have to stop NodeRED (to avoid network port conflict) and manually run sonoff.server.js. This is a bit inconvenient since NodeRED is driving my real home automation flows.
That made me thinking if it is possible to implement the API part as a separate module (for example sonoff.api.server.module.js). It would accept "devices" object in its constructor. The file sonoff.server.js will stay the classic standalone nodejs app. It will take care only for building config, env vars and creating instances. Something like:
This way node-red-contrib-sonoff-server may load both modules that share the same device repository.