My first attempt at rule machine. I'm trying to simplify the event handling to reduce the load.
I thought of using "wait on event" to rewrite the following rule. However, I don't think that model fits what I'm trying to do.
In words, this rule is: if the UPS is on battery and less than 5% battery remains, shut down. However, if the UPS is low but back on mains (this can happen if it restarts after a power failure and the hub restarts as well), watch out for a another power failure occurring before the battery is charged over 5%, and shut down if that happens.
In my attempt to make this simpler, I changed the trigger events, which allowed me to simplify this greatly. Did I do it correctly?
Could make the trigger AND , then you can just have it shutdown as the action. This way it only triggers when the battery is <=5 AND reporting on battery mode. This can remove the If statement from your actions to run
Well, I've achieved the ultimate simplification of the rule. I deleted it!
Instead, on the raspberry pi that is running NUT server, I edited /etc/nut/upsmon.conf, changing SHUTDOWNCMD "/sbin/shutdown -h +0" to SHUTDOWNCMD /etc/nut/shutdown.sh and wrote a new executable file, /etc/nut/shutdown.sh with the following lines: