Configure the NUT to manage a UPS through the Home Assistant as a Docker container on a Raspberry Pi

The primary goal of the Network UPS Tools (NUT) project is to provide support for Power Devices, such as Uninterruptible Power Supplies, Power Distribution Units, Automatic Transfer Switches, Power Supply Units and Solar Controllers. NUT provides a common protocol and set of tools to monitor and manage such devices, and to consistently name equivalent features and data points, across a vast range of vendor-specific protocols and connection media types.

Video describes the NUT configuration and how to install Docker, Docker Compose and run the Home Assistant as a Docker container. Additionally I present how to turn off the Mikrotik router from the Raspberry Pi if the battery level state is low.

I decided to “promote” this video that is just an excellent example that explains step by step how to install and configure NUT on a Raspberry Pi.

NUT documentation: https://networkupstools.org/docs/man/

I am using this UPS: UPS Green Cell AiO 600VA 360W

More information you can find on a vendor website: https://greencell.global/en/for-rtv-and-household-appliances/1090-ups-green-cell-aio-600va-360w.html

I created a nut user on a Mikrotik and additionally tested it with RSA keys without a passphrase what in LAN is let’s say secure enough. All you have to do is to save private and public key in openSSH format, but not the newest one, but instead the standard format – hope I explained it well, just because Puttygen allows you to save the RSA key in new openSSH format. Anyway you have to upload the private key into the Files in Mikrotik, and then in system – users section im port the key for a user. But you can also just use ordinary password with sshpass as I did in the password. If you want use RSA, you have to remove this from bash script: sshpass -f /root/creds

Video that describes how to generate RSA key, import it to the Mikrotik and then connect through the ssh from Raspberry Pi to a Mikrotik router.

All the necessary scripts are on my github account: https://github.com/sysadmin-info/NUT