Here is an example flow that reads data from an APC UPS (Uninterruptible Power Supply). These are commonly used to keep PC's and servers powered up during short power outages and to allow them to gracefully shut down.
In this case, I have a low-cost APC UPS connected via a USB cable to the Raspberry Pi that is running Node-RED and a Mosquitto MQTT broker.
To get the latest data from the UPS, we are using a command-line Linux tool called apcaccess
. This is part of apcupsd which you should be able to install directly from your distribution's software library.
There are 2 function nodes included in the flow. One that isn't wired in, that converts the text output from the tool into an object on the payload containing properties for everything returned by the query. The second one, that is in use, is very similar but throws out a new message for each property using topics that correspond roughly to the homie MQTT topic structure. Homie is simi