Strange NUT question. (Network UPS Tools, get your mind out of the gutter)

I have a Pi4 running Channels DVR Server that I would like to have automatically shut down when my UPS gets to a low battery state. It turns out that the Channels DVR Server runs on Home Assistant OS.

I also have a separate Pi4 running Home Assistant (both of these are plugged into the UPS). I know that there is a plugin for NUT that can be added to Home Assistant. Is there a way I can add that to HA and have it shut down both Pis?

If not, is there a step-by-step guide on how to install NUT onto Home Assistant OS that is not running HA?

I am grasping at straws here, but hopefully, someone can help me out. Every time my power fails while the Channels DVR Server is recording a program, my hard drive gets corrupted. That is why I got the UPS. But if the power goes out and stays out for 2 hours and I don’t know about it (and therefore don’t shut down the Pi manually) I run the risk of disk corruption. I would love to automate this.

Please help me Obi Won, you are my only help. :slight_smile:

You can run NUT wherever you want - if you want to run it from HA there is an add-on that will provide it. Or you can run it elsewhere. In either case, the NUT integration will then pick up all the info and bring it into HA.

You can then have an automation with a trigger - you could do it based on time on battery, or when the battery drops below a threshold - whatever works for your situation. The action of the automation could then be a command_line that will run a command to shut down the Pi4 running your NVR software via SSH.

Awesome! This is great! I will start down this path and I am sure I will have questions, and will be back to ask them when I know what to ask. Thanks again.

The issue is going to be that if you are running HA OS and also not running HA on that OS then you are very limited on what you can install on that machine.

HA OS is a very limited OS in what you can do with it directly.

The HA Supervisor is what provides the majority of the functionality of the OS - including the ability to run add-ons/Docker contaners. Without that you can’t do much.

How does your UPS communicate to the some machine? Mine plugs into my HA PC via USB cable which provides the comm link to the NUT Server running on that machine. Does yours plug in anywhere like that? And hopefully not on your HA OS bare bones machine.

The NUT addon (not integration) works fine for a UPS plugged into a machine running HA OS.

True but the OP said that he doesn’t have HA installed on that machine so that he can’t install the NUT add-on required for the integration to communicate with the UPS.

At least that’s what I got out of the above.

I’d connect the UPS to the machine running HA and shut down the machine not running home assistant with an automation and a shell command.

Yes, this is what I plan to do. I just need a few hours that I can set aside to work on this. Hopefully, this weekend. Home Assistant keeps getting better and better for me all the time. I am glad I took the plunge.

I am very glad to find out that I can install the NUT addon to my HA Pi and have it shut down my Channels Pi without having to install anything on the Channels Pi. That is a big relief.

I have a USB cable that I will be plugging into the HA Pi.

I have NUT set up and working and now I want to create the automation to send the SSH command to the other RPi instructing it to shut down when NUT detects the UPS battery falling to 10%.

Does anyone already have an automation like this that I could use as a template?

This is a partial example from my environment - I cobbled together a couple things for this example so it may not work exactly, but hopefully it’ll point you in the proper direction:

Pre-req to the automation… create a shell command in your configuration.yaml that will shut down your RPi (your command will be different - change as it fits your environment):

shell_command:
  host2_poweron: ssh [email protected] -o StrictHostKeyChecking=no -i /config/.ssh/ssh1key.priv 'racadm serveraction powerup'
  host2_poweroff: ssh [email protected] -o StrictHostKeyChecking=no -i /config/.ssh/ssh2key.priv '/vmfs/volumes/host2-raid5-sas/shutdownscript.sh &'

Then the automation:

alias: UPS on Battery
description: ""
trigger:
  - platform: state
    entity_id: sensor.cyberups_status
    not_from:
      - unavailable
    not_to:
      - unavailable
condition: []
action:
  - service: shell_command.host2_poweron
    data: {}

Again, this is just an example so don’t just copy/paste expecting this to work :wink:

Thank you, thank you, thank you. I will try this out asap, in the next few days and report back.

I will do it in stages. 1st, I will get the automation to trigger correctly. Then I will work on the shell command (due to my ignorance).

You have given me a great jumping off point. I knew that HA was powerful, but this is better than I expected. And the Comunity is so helpful.