I managed to get my config working :)
I thought that I share it here so maybe someone will find it useful.
My UPS Settings:
Services UPS Settings-final-c.png
/usr/local/etc/nut/upssched.conf
-rw-r--r-- 1 root wheel 630 Sep 11 21:29 upssched.conf
CMDSCRIPT /usr/local/bin/upssched-cmd
# Command pipe and lock-file
PIPEFN /var/db/nut/upssched.pipe
LOCKFN /var/db/nut/upssched.lock
# Send alerts immediately on change in line power
AT ONBATT * EXECUTE onbatt
AT ONLINE * EXECUTE onpower
# Send alerts immediately if low battery limit is reached
AT LOWBATT * EXECUTE onlowbatt
# (Optional) Silence the beeper after 2 minutes
AT ONBATT * START-TIMER mute_beeper 120
AT ONLINE * CANCEL-TIMER mute_beeper
# Shutdown after 5 minutes on battery (5 * 60 = 300)
AT ONBATT * START-TIMER onbatt_shutdown 300
# Cancel timer if power's restored
AT ONLINE * CANCEL-TIMER onbatt_shutdown
/usr/local/bin/upssched-cmd
-r-xr-xr-x 1 root wheel 1411 Sep 11 21:29 upssched-cmd
#!/bin/sh
# START: User-specific settings
#
UPS_USERNAME="local-admin"
UPS_PASSWORD="some-pass"
UPS_LINK="CP1300_UPS@localhost"
# END
# START: Battery info
#
STATUS=$( upsc $UPS_LINK ups.status )
CHARGE=$( upsc $UPS_LINK battery.charge )
CHMSG="[$STATUS]:$CHARGE%"
# END
logger -i -t upssched-cmd Calling upssched-cmd $1
case $1 in
onbatt)
# make sure beeper is enabled
upscmd -u ${UPS_USERNAME} -p ${UPS_PASSWORD} ${UPS_LINK} beeper.enable
# alert
message="$UPS_LINK, $CHMSG - Power outage, on battery"
;;
onlowbatt)
message="$UPS_LINK, $CHMSG - Power battery low - shutdown now!"
;;
onpower)
message="$UPS_LINK, $CHMSG - Power restored"
;;
mute_beeper)
message="(2) minute limit exceeded, muting beeper"
upscmd -u ${UPS_USERNAME} -p ${UPS_PASSWORD} ${UPS_LINK} beeper.mute
;;
onbatt_shutdown)
message="$UPS_LINK, $CHMSG - Triggering shutdown after (5) minutes on battery"
/usr/local/sbin/upsmon -c fsd
;;
replace_batt)
message="Quick self-test indicates battery requires replacement"
;;
*)
message="Unrecognized command: $1"
/usr/bin/logger -i -t upssched-cmd $message
exit 1
;;
esac
/usr/bin/logger -i -t upssched-cmd $message
/usr/local/pkg/nut/nut_email.php $message
exit 0
The reason why my original config didn't work (upssched not starting) was caused by wrong AT declarations.
I had to change them from
AT notifytype UPS-name EXECUTE command
to
AT notifytype * EXECUTE command
I'm not sure why I can't use specific UPS name (CP1300_UPS@localhost in my case) as it is recommended approach but otherwise upssched doesn't work.
Regarding the offdelay and ondelay parameters in Extra Arguments to driver field.
Initially I set them to offdelay=120 and ondelay=180 but it wasn't working as expected.
After 120 seconds UPS was turning off but 60 seconds later (180 - 120) it was turning back on again while still being on battery power.
I had to set ondelay=0 to prevent UPS from turning on until line power was restored.