UNRAID Integration

Yes, my UPS is plugged into Unraid for communication and is set to shut down after 3 minutes on battery power. I am looking for a solution to bring the Unraid server back online when normal power is restored. I can’t figure out how another machine can determine if power is restored, as it won’t be able to check the UPS status if Unraid is offline.

Is the Pi5 in the same building on the same electrical supply?

If yes, then assuming it is powered up is good enough to assume the power is back for the UPS on the RAID.

OR if that Pi has it’s own UPS, then check if it’s own UPS is charging.

With my own setup, currently the UNRAID box has the USB UPS cable. So it can shut down gracefully controlled by NUTS on UNRAID.

The HA PI is in the same UPS, but will just crash once the UPS is out of power. After the experience this week I want to find a way to make the HA PI always boot if it has power. Then it could let me use it to talk to the UNRAID box via WOL and this integration.

Ideally HP PI is last one to power down, first to power back up…

Pi and Unraid are in the same building and on the same UPS.

UPS is plugged into Unraid and does a graceful shutdown after 3 minutes of running on the battery.

I might create an automation on the Pi in HA to send a magic packet to the Unraid server when HA starts.

I have not tested how long the Pi will last on the UPS battery before it loses power. I might test this and see if it will turn on when power is restored to the UPS.

I would assume the PI would run a long time on UPS. How vital is the UNRAID box?

Note if you send a magic packet to UNRAID too early, then it would boot up and check the UPS. Then shut down again due to running out of time. As long as it has not spun up the disks at this point the worst thing that would happen is to chomp some of the last of the battery.

Anything else in the house you could ping to see if power had returned? What about pinging a smart plug?

if (ping’d smart plug says connected) and (unraid says offline) then (send magic packet to unraid)

That is a brilliant idea! I’m not too sure how to implement the “if smart plug says connected” bit, though. Do you have any ideas?

Many Smart Plugs have their own state you could test for. So any device that can confirm if it exists by checking its state could work.

Personally, I am a simple IT guy, so think Network. So I’d use the PING integration to test for it.

Install the Ping (ICMP) HACS integration and add a device that you know only functions when you have power in the house. Then you can test the “binary_sensor” if it is connected.

if (binary_sensor.unraidserver = off) and (binary_sensor.smartswitch = on) then (switch.unraidserver = on)

I am fairly new to the HA language so may have that a little wrong? If above icdea is not clear enough I could attempt to hack an example Automation together.

The above question does make me wonder a couple of things about the UNRAID integration.

a\ What is the correct test to say “Is this UNRAID server on?”
b\ Is the Array online? (Or I guess that is one of @Gurulee’s requests)

I think your setup is similar to mine i just dont have a Pi5, i run HA on an old laptop. That has the added benefit to detecting whether its running on battery power or not. My laptop then outlives the UPS but i have the same issue in that the UPS could still be alive with no power connected. The pinging a smart plug is a great idea i agree as those would be dead or alive relatively quick with power. So my smart plugs are ESPHome and that has a connected binary sensor i can use.

What i am planning to do after seeing this idea is use that binary sensor to detect when it goes from unavailable or disconnected to connected. That will trigger a parrallel section to run two wait fors. One to watch the connected state to change to unavailable or disconnected, which can just send me a notification with how long long the power popped back on and off for. The second one will wait for the connected state to stay for as long as required, probably 5-10 minutes for me, and will then instruct the sonoff to turn the server back on. Does that help with your implementation? I gather you have access to or can create the needed binary sensor.

Probably trigger on the UPS and add some other conditions in to make sure it is a power loss but i think that should work.

1 Like

I’ll come back to this. Sorry for the late reply. I’ve been tinkering with a Raspberry Pi Zero W. I’ve got it plugged in independent of the UPS. When it loses power and comes back online it runs a custom Python script to check if my Unraid server and Pi 5 are online. If not, it sends them wake-on packets and then continues to ping them up to 12 times with 10 seconds between each ping. Once the devices are online it confirms they are in a log. I’m creating an email notification for this and a web interface in case I’m not home. Also advancing it with more power statistics. Happy to share my code.

An example of the log output:

2024-12-16 19:33:34,589 - INFO - ------------------ New Session Started ------------------
2024-12-16 19:33:34,610 - INFO - Power Monitor starting up…
2024-12-16 19:33:34,611 - INFO - Logging to /home/admin/logs/power-monitor.log
2024-12-16 19:33:34,622 - INFO - Configuration loaded successfully
2024-12-16 19:33:34,640 - INFO - Power Monitor started at 2024-12-16 19:33:34.624241 on power-pi
2024-12-16 19:33:34,709 - WARNING - Network check attempt 1 failed
2024-12-16 19:33:39,721 - INFO - Network connection established after 2 attempts
2024-12-16 19:33:39,722 - INFO - Waiting 30 seconds for network services
2024-12-16 19:34:25,281 - INFO - Checking initial status of all devices…
2024-12-16 19:34:26,291 - INFO - Initial status of JUPITER: OFFLINE
2024-12-16 19:34:26,310 - INFO - Initial status of PLUTO: ONLINE
2024-12-16 19:34:26,311 - INFO - Sent WoL packet to JUPITER (00:00:00:00:00:00)
2024-12-16 19:34:31,312 - INFO - Waiting for JUPITER to respond…
2024-12-16 19:34:42,322 - INFO - Waiting for JUPITER - attempt 1/12
2024-12-16 19:34:53,332 - INFO - Waiting for JUPITER - attempt 2/12
2024-12-16 19:35:04,343 - INFO - Waiting for JUPITER - attempt 3/12
2024-12-16 19:35:15,354 - INFO - Waiting for JUPITER - attempt 4/12
2024-12-16 19:35:26,360 - INFO - Waiting for JUPITER - attempt 5/12
2024-12-16 19:35:37,370 - INFO - Waiting for JUPITER - attempt 6/12
2024-12-16 19:35:48,380 - INFO - Waiting for JUPITER - attempt 7/12
2024-12-16 19:35:59,390 - INFO - Waiting for JUPITER - attempt 8/12
2024-12-16 19:36:10,400 - INFO - Waiting for JUPITER - attempt 9/12
2024-12-16 19:36:10,415 - INFO - JUPITER is now online! (Attempt 10/12)
2024-12-16 19:36:10,426 - INFO - Wake-on-LAN sequence completed:
2024-12-16 19:36:10,427 - INFO - Wake-on-LAN summary: Total devices configured: 2
2024-12-16 19:36:10,428 - INFO - Wake-on-LAN summary: Devices requiring wake packets: 1
2024-12-16 19:36:10,428 - INFO - Wake-on-LAN summary: Devices online at start: 1/2
2024-12-16 19:36:10,429 - INFO - Wake-on-LAN summary: Devices online at end: 2/2
2024-12-16 19:36:10,429 - INFO - Device Status - JUPITER: Initial: OFFLINE, Wake attempted, Final: ONLINE
2024-12-16 19:36:10,429 - INFO - Device Status - PLUTO: Initial: ONLINE, No wake needed, Final: ONLINE
2024-12-16 19:36:10,430 - INFO - ------------------ Session Completed Successfully ------------------

Check out the project I’m working on. It may be of use to your setup.

I will thanks! Ive got a few zero W2’s lying around so perfect use case for them.

If you’re interested in following along I’m probably going to have to take this conversation elsewhere as it probably doesn’t belong here? Anyway, I’ve been working on the web interface today and have got it reporting if a device is online or offline and able to wake device.

Please move this discussion somewhere else. This is for the unraid integration. Thank you

I’d absolutely love to see this; I’ve just purchased a UPS and have direct-connected my server to it, meaning I no longer have a Smart Plug connected to the server. I’d love to continue passing the power consumption data into HA’s energy dashboard, if this is something we can do from the UPS data in Unraid.

Edit: This is awesome - I can see the power data now after fixing the VM network issue (see below). Great work, man! Now for me to spend some time building out a nice dashboard :wink:



For anyone else having issues connecting to Unraid from their HA instance, if you are running HA as an Unraid VM, you may need to change the following settings:

  1. Unraid Settings > Docker > Turn off > Apply
  2. Unraid Settings > VM Manager > Turn off > Apply
  3. Unraid Settings > Network Settings > Enable bridging to Yes > Apply
  4. Turn Docker back on
  5. Turn VMs back on
  6. Go to the Edit page of your HA VM > Change “Network Source” to br0 > Update
  7. Start your HA VM

You should now be able to connect HA to Unraid through the integration, and you can check SSH is working through HA terminal by typing “ssh [unraid-username]@[unraid-ip]”

Im waiting for this update before jumping in with your integration.
Curious if this update will be coming soon. No rush…just don’t want to install it right before an update that may change entity names etc.

1 Like

Hello, I’m still working on addressing a few issues before releasing the next version.

4 Likes

Hello, this is an awesome integration, when will it have the stop, reboot and shutdown option?

Latest version have shutdown and reboot button. Stop array button not available yet.

1 Like

Did anyone else’s docker switches disappear with the latest version?