Remote shutdown

I use a script to shutdown my hub incase of mains power loss. For some reason the hub is no longer shutting down.

This is my script

#!/bin/bash
#/var/www/control/scripts/poweroffhe.sh
HOST="myHuburl"*
CHECKOFF="/etc/ups/scripts/hubitat/checkheoff.sh"
POWERLOG="/etc/ups/log/power_log"
USER=myUser
PASS=myPass
FILECOOKIE=/bin/mktemp

echo $(date) " - Running poweroffhe.sh as user $(whoami)" >> $POWERLOG
echo $(date) " - Hubitat Elevation shutdown..." >> $POWERLOG*
curl -k -c $FILECOOKIE -d username=$USER -d password=$PASS https://$HOST/login
if [ $? = 1 ]; then
echo $(date) " - Hubitat curl login failed" >> $POWERLOG
exit 1
fi
curl -k -sb -X POST https://$HOST/hub/shutdown
sudo -u control $CHECKOFF &
rm $FILECOOKIE
exit 0

I've checked the login curl which is working, or I'm not seeing any errors. The script appears to complete without errors. Any ideas as to why the hub is not shutting down?

Can't claim to to ffer a solution to your issue with the script... but would recommend looking at the Hub Info driver we which allows shutdown and reboot. Just something else that may help....

Ahhh, as soon as I posted that I realised I'm not using the cookie file:

curl -k -sb $FILECOOKIE -X POST https://$HOST/hub/shutdown

working now.....

1 Like

Hi pswogan

What's the content of /etc/ups/scripts/hubitat/checkheoff.sh ? Could you provide it?

#!/bin/bash
#/etc/ups/scripts/hubitat/checkheoff.sh

POWERLOG="/etc/ups/log/power_log"
HOST="myHuburl"
FLAGOFF="/etc/ups/flag/slave/heoff"
TIME=5
DELAY=20

ping -c 1 $HOST
while [ $? = 0 ] ; do
sleep $TIME
ping -c 1 $HOST
done
sleep $DELAY
touch $FLAGOFF
echo $(date) " - Hubitat Elevation shutdown complete" >> $POWERLOG
exit 0

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.