After having used Node-RED for only a couple of weeks, I have already implemented my first custom nodes.
The node-red-contrib-map plugin allows for defining re-usable mappings through configuration nodes; these mappings can then be used by the map, set and switch nodes provided by the plugin under the mappings category.
Its main use is to define mappings between device id's and device names:
- The map node allows you to map an incoming device id to a device name, and vice versa.
- The set node allows for selecting a device from the configured mappings, and then add the device id or name to an incoming message.
- The switch node allows for defining node outputs by matching incoming messages against the configured mappings. Note that this is somewhat similar to the switch node provided by Node-RED, but dedicated for working with configured mappings.
I am successfully using this plugin in my own Node-RED flows, and it has allowed me to greatly simplify some of my flows.
If you have any feedback or experience any issues with this plugin, please let me know either here or through an issue on the GitHub page.
Note that the documentation at https://flows.nodered.org/node/node-red-contrib-map has some formatting issues; you can view the correctly formatted documentation at either https://www.npmjs.com/package/node-red-contrib-map or https://github.com/rsenden/node-red-contrib-map