Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

apcupsd notification - no restore notification

Featured Replies

I have apcupsd configured as a slave over LAN, connected to my pfSense, which runs apcupsd as the master.

Everything works fine — reporting, battery mode notifications, and clean shutdowns — but there’s no notification when power is restored and the system switches back to mains.

Any clue from anyone where I should start looking to fix this?

  • Community Expert

? so you want unraid to report back or pfsense to report back?

  • Author

unraid, running apcupsd as a slave, correctly and immediately sends a notification when the UPS switches to battery (main power loss). However, it never sends a “power restored” notification when the UPS goes back online, even though unraid clearly receives this status update from pfsense, which is running apcupsd as the master. I want unraid to send the power-restored notification in the same way it handles the on-battery event.

  • Community Expert

I'm not in the know on ups the acupsd sytem... however, from googling around this is what I have found:

this is a “nothing fires on restore” issue, not a comms problem. On a slave, apcupsd does receive the “power back” state from the master, but the default event handling doesn’t notify on it. By design, the offbattery (and sometimes mainsback / online) events are generated on return to line power, but the stock action is do nothing unless you override it with an event script.

https://subnets.ru/blog/wp-content/uploads/2008/07/apcupsd.pdf

so I would assume edit the event scripts that unrad slave system is using...

Confirm the event is actually generated (it is, but verify once)
On the Unraid box (slave):
tail -f /var/log/apcupsd.events


Trigger a short power pull. You should see lines like:

Power failure.
... (ONBATT)
Power is back. UPS running on mains.
... (OFFBATT or MAINSBACK/ONLINE)


If you see the “back on mains” line in the events file but got no Unraid notification, it’s exactly the default-action gap described above.

see manpages as well for this system:
https://www.mankier.com/5/apcupsd.conf

so lets add an event hook so unraid reprots back...

?untested but should work...
apcupsd will execute a script named after the event if present in /etc/apcupsd/. We’ll hook offbattery (fires only if onbattery had fired) and optionally mainsback / online for belt-and-suspenders. https://blog.horner.tj/apcupsd-scripts/

Create persistent copies on the flash and install them at boot:

*(to survive reboots and carry with unraid flash backups...)

mkdir -p /boot/config/custom/apcupsd

nano /boot/config/custom/apcupsd/offbattery


/boot/config/custom/apcupsd/offbattery

#!/bin/bash
# Unraid apcupsd slave: notify when power is restored
HOSTNAME=$(hostname)
SUBJECT="UPS power restored on ${HOSTNAME}"
DESC="UPS back on line power (offbattery event)."
# Unraid's notify utility:
# -e event, -s subject, -d description, -i severity (normal|warning|alert)
/usr/local/emhttp/webGui/scripts/notify \
  -e "UPS" -s "$SUBJECT" -d "$DESC" -i "normal"

(Optional) also create mainsback and online with the same contents to catch alternate restore sequences:cp /boot/config/custom/apcupsd/offbattery /boot/config/custom/apcupsd/mainsback:

cp /boot/config/custom/apcupsd/offbattery /boot/config/custom/apcupsd/mainsback

cp /boot/config/custom/apcupsd/offbattery /boot/config/custom/apcupsd/online

Make them executable:
chmod +x /boot/config/custom/apcupsd/offbattery \

/boot/config/custom/apcupsd/mainsback \

/boot/config/custom/apcupsd/online

Install them into the RAM filesystem on boot by editing /boot/config/go and adding (before the emhttp line is fine):
(Or user pluigin script at first arry start...)

# Install apcupsd event hooks at boot
mkdir -p /etc/apcupsd
install -m 755 /boot/config/custom/apcupsd/offbattery /etc/apcupsd/offbattery
install -m 755 /boot/config/custom/apcupsd/mainsback  /etc/apcupsd/mainsback
install -m 755 /boot/config/custom/apcupsd/online     /etc/apcupsd/online

Test as the above is move for unriad reboot to keep at a unraid reboot...
*For this session (without reboot), install and test now:
install -m 755 /boot/config/custom/apcupsd/offbattery /etc/apcupsd/offbattery

install -m 755 /boot/config/custom/apcupsd/mainsback /etc/apcupsd/mainsback

install -m 755 /boot/config/custom/apcupsd/online /etc/apcupsd/online


Pull power briefly → you should get your normal “on battery” notification and the new “power restored” one when mains returns.

Why this works: apcupsd’s default for offbattery is to do nothing; Unraid’s plugin notifies aggressively on “bad” events, but not always on “back to normal.” Adding a per-event script is the supported method to extend behavior.

as I'm not sure if this is a plugin or other emhttp notfication system...
? Unraid’s APC plugin ships a helper that reads a line from stdin and turns it into a GUI notification. If you prefer that style, you can do this inside your event scripts:
*Per other fourm posts... I don't have a ups to test theses things..

This could be as easey as adding this line at boot...
echo "Power is back. UPS running on mains." \

| /usr/local/emhttp/plugins/dynamix.apcupsd/apcupsd.notify


If you still don’t see events (Per ubuntu/deb man pages:https://manpages.ubuntu.com/manpages/jammy/man8/apcupsd.8.html)

  • Make sure the slave is truly ONBATT → OFFBATT (short blips might produce mainsback/online only). That’s why we hook all three.

  • Keep an eye on /var/log/apcupsd.events to confirm which event name your restore path generates, then ensure you have a matching script.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.