Remote Shutdown Command

I have been reading up how to remotely shutdown the hub. I am doing this via a Linux shell script from another machine once a power failure is detected. I found several tidbits, but nothing seems to be working.

The final syntax that I am using (from linux shell) is:
curl -X POST http://hubIP:8080/hub/shutdown

The command runs fine, no errors or anything, but the hub does not shutdown. I have checked through logs and events and do not see that the hub has received any notice at all.

What am I missing?

Hub firmware is version 2.1.4.125 if that helps.

Try removing the β€œ:8080” from your URL. That’s only necessary when calling the reboot command from within RM.

If your hub has authentication enabled, then you will need to use a cookie.

Ahhhhhhh YES! A Cookie! Of Course!

Peanut Butter or Chocolate Chip? :slight_smile:

Just kidding. I am not a web programmer...any samples/suggestions? How do you get the cookie set from the hub?

Here's a bash script that I use on my Odroid (something like a Raspberry Pi) to shutdown my Hubitat.

#!/bin/bash
#
he_login=your_login
he_passwd=your_password
he_ipaddr=hubitat_ip_address
cookiefile=`/bin/mktemp`
#
curl -k -c $cookiefile -d username=$he_login -d password=$he_passwd https://$he_ipaddr/login
curl -k -sb $cookiefile -X POST https://$he_ipaddr/hub/shutdown
rm $cookiefile

The first curl command retrieves a login cookie using your username/password. The second one sends a shutdown command.

5 Likes

This worked PERFECTLY! Thank you so much!

@BearBrewery

Glad that worked. There's a slew of HE commands that can be sent via curl.

Yes, I was looking for some sort of reference but cant find anything other than the /hub/shutdown and /hub/reboot. Where did you find them?

I just looked up the elements in each webpage that I wanted to use from the page source.

1 Like

Sorry to necro this topic, currently my Windows 2012 R2 Server (which monitors my Eaton 1500VA UPS) sends a remote shutdown command to my Vera Plus (and other systems) when power has been off for 7 minutes using Putty and SSH:

Call "C:\Program files (x86)\puTTY\plink.exe" -ssh -batch root@<vera_IP> -pw <password> poweroff

Is there a way to do this with HE from a Windows Server??

Download the latest build of curl and do the same thing would be the easiest imo.

2 Likes

Cheers, I’ll try that when my C7 arrives.

2 Likes