How to shut down NAS with Nut configured on HA server via Addon and integration

Running the NUT add-on as server on my HA MiniPC and have it connected via the Usb cable to my APC UPS.
The NUT integration on the same HA MiniPC is watching the device, and provides many sensors regarding its state.

My hope (havent yet tested it) is that the APC UPS will prevent the MiniPC running HA (and the add-on obviously) from halting in case of a power outage.

I will connect the Synology Nas to the backups power outlets, just like the MiniPC and a few other critical devices.

Above topology makes it impossible to connect the UPS usb to the NAS, it has only 1 outlet for that. (And I can’t run NUT on the Synology, because my Synology goes asleep during the night)

I was told I can still connect the NUT (integration or add-n?) to the NAS to make sure it powers down in case of a depleting battery, but I cant find anything official regarding that option.

Maybe I can use a HA automation like

alias: Schakel computers uit bij lege Ups
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.apc_ups_batterijduur
    below: 300
conditions: []
actions:
  - action: button.press
    metadata: {}
    data: {}
    target:
      entity_id: button.diskstation_shutdown
#  - action: synology_dsm.shutdown
#    metadata: {}
#    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - action: hassio.host_shutdown
    metadata: {}
    data: {}
mode: single

but of course I’d much rather prefer the NUT to take control here, and set some flags on the NAS to power down safely.

Please help me out if you would know how to? thanks for having a look

It won’t “prevent it halting”.

The NUT server add-on will cleanly shut down HA when the UPS battery is nearly depleted during a power outage. It can send shutdown commands to other networked devices connected to the UPS power if they can run a NUT client

I have a similar requirement I want to cleanly shut down my NVR and NAS (separate devices also powered by the UPS) by receiving the shutdown command over the network from the NUT server add-on.

I managed to get a Windows PC NUT client to connect to the add-on as a test but that is no use as it is not powered by the UPS.

I could not get my NVR to connect. I followed this guide: NUT on my Pi, so my servers don't die | Jeff Geerling

Jump to the client setup section as we already have the server set up.

I need to revisit this as apparently a few corrections have been made to the article.

2 Likes

you mean that the UPS doesnt provide a constant power to the MIniPC in case of a power outage (to the UPS feed). it’s the sole reason I bought the thing, so if that wont work, I need to send it back asap…

is this configured in the Add-on ? I had it auto configured practically, but now see this shutdown host!

I wonder how that executes, when the host is actually hosting the add-on too :wink:
The other commands you talk about are also configured here I take it then?

completely forgot about that one yes, it would also be powered via the UPS, I wouldnt know the shutdown command though. this UPS stuff is all new to me.
Dream machine Pro here.

Of course it does. That’s what a UPS do. But it won’t prevent it halting once the battery power is used up. It will actually cause it to halt (cleanly).

It is the last to shutdown after issuing the command to the other connected clients.

You don’t need to know the shutdown command. You install the NUT clinet on the device, connect it to the NUT server (add-on) and let it take care of everything.

Follow jeff’s article about installing NUT clients.

1 Like

check, Ill go look for that on the Dream machine, thanks for the pointers Tom
seems many people before did though, and no NUT client can be setup on the DreamMachine
only some external scripting and I wont go there for now,

forgetting Dreammachine for now, getting back to the Synology.

many people cant get this going, but https://www.reddit.com/r/homelab/comments/5ssb5h/ups_server_on_raspberry_pi/ seems to be a good pointer, especially the bit on mofdifying the user in the server setup.

Given the fact my server is the Add-on, I need to add

[monuser] #This is what Synology DSM expects
password = secret #Leave this here.
upsmon slave

to the config apparently. I edited it to be

users:
  - username: otheruser
    password: otherpw
    instcmds:
      - all
    actions: []
  - username: monuser
    password: secret
    upsmon: slave
    actions: []
    instcmds:
      - all

(the actions and instcmds are required) but still no successful login is made

Yeah I could not connect from my NVR either. I could from my PC’s NUT client though. Very odd.

apparently we need to set a user and https://community.synology.com/enu/forum/1/post/162184:

  - username: monuser
    password: secret
    upsmon: slave
    actions: []
    instcmds:
      - all

but that is not accepted by the add-on because of insecure password

the solution is even simpler than that…

in Discord Discord I was advised to change the name of the device to ups, as that is also hard coded in the Synology.

change to

- name: ups
  driver: usbhid-ups
  port: auto
  config: []

and no dedicated user whatsoever.

next I added it in DSM like:

which as you can see connected!

device info reveals:

so were good now, and I can disable the automation for these devices.

I did login with my user account which I setup for Homessistant especially. Not sure of this is even required though, I havent tested that yet.

thanks to @sinclairpaul (is this the same account?) and Michael piez0r .

I think that is what I was missing.

EDIT: YAY! it worked.

User [email protected] logged into UPS [comms_ups]

Now my NAS on the other hand is going to be a PITA. It’s a locked down EX4100 that I need to root to get shell access.

It looks like it has a hard coded user and NUT server too: Network UPS: connecting 3rd party devices to a EX2 running in master-mode - #3 by ThisNameNotUsed - My Cloud OS 3 - WD Community Why do NAS developers keep doing this?

It’s due for replacement with something better soon anyway. I might just let it fail if a power outage happens. It’s well backed up.