Been thinking of doing something similar myself. I would lean toward installing apcupsd on the rpi and publishing the power status to mosqutto as per https://iotbytes.wordpress.com/monitor-ups-power-events-on-mqtt-client/.
About shutting down your PC - I don't see how you could run both apcupsd and APC PowerChute simulatiously, perhaps you could do this via MQTT.
Don't think I've seen that before. Or if I had, I forgot about it. Would be useful for my Windows 10 based picture frame
Nope, don't mind at all.
You can see from my flow that I haven't used the node - not sure it existed when I set up my connection. I have it set up on my "new" PC server now rather than the Pi but that is still Debian based so it is the same.
Urm, massive overkill? You can install apcupsd via APT quite happily. It is very stable and doesn't take up much resource.
Not sure how much that really gives you? An exec call to the command line works fine and doesn't need another custom node. It would be different if that node didn't need to poll the service but it does.
Again, you really don't need a custom node for this. Just issue the shutdown command using an exec node. You may need to tweak your sudo settings to allow the user running Node-RED to issue the command without a password prompt.
One of my 2 APC units died completely even though I tried replacing the battery. The other one is still fine though after a battery replacement. Contrary to popular belief, it isn't that hard to replace the battery and you can easily get replacements for a very low cost. Certainly beats spending ÂŁ150 on a new one every 2 years!.
I have everything up and running now, I had to use some more steps due to having a Dockerised Node Red install, I even wrote a guide to remind myself for future.
From a previous post I believe you use influxDB as well?
Well my issue is that the outputs from your flow are strings,whereas 'real' values are needed to display in Grafana. I'm wondering if you have a way around this?
Example:
I have this function working for one payload at a time, but handling the whole lot is evading me for now:
I can't quite remember the full format of the original data but assuming the payload is an object, something like this will output a new object with numeric values:
const out = {}
Object.keys(msg.payload).forEach( key => {
let pSplit = msg.payload[key].split(' ')
out[key] = parseFloat(pay[0])
if ( Number.isNaN(out[key]) ) out[key] = pay[0]
})
msg.payload = out
return msg
Not meant to be complete code, only to give you the steer you need. There are all sorts of ways to handle the things that are text - convert "ONLINE"/"OFFLINE" to 1/0 for example which is more useful in InfluxDB. You don't need "date" and starttime you may want to convert to an elapsed number of hours maybe.
You will need to work through all of the entries, get rid of the ones you don't want and reformat others as you need to.