I'm trying to create Node-RED flows to switch on/off my sonoff switches using https://github.com/saryn/node-red-contrib-sonoff-server.
The node to switch on is definied here: https://github.com/saryn/node-red-contrib-sonoff-server/blob/master/node-on/node-on.js. In this code it says
RED.nodes.createNode(node, config);
and
sonoffServer.turnOnDevice(config.device_id);
I am really new to node red (< 1 day), but as far as I can see it, this code requires the config to be set when the node is created in the dashboard, so the deviceID must be hardcoded to the node. I want to supply the deviceID dynamically to the node. Is this possible with this node as it is?
The flow I want to achive. The template node has the deviceID as output.
No, it is not possible to dynamically supply the device id with that node as it is currently written.
Looking at the code it would probably be pretty trivial to modify it to take id from the input message. If you choose to do this please raise a pull request against the original node rather than just fork so the feature can be shared by all users and not end up diluting the collection of nodes with very similar release.