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.
aaiyar
August 25, 2019, 3:10am
3
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?
Just kidding. I am not a web programmer...any samples/suggestions? How do you get the cookie set from the hub?
aaiyar
August 25, 2019, 6:45pm
5
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!
aaiyar
August 26, 2019, 11:28pm
7
@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?
aaiyar
August 27, 2019, 12:54pm
9
BearBrewery:
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
dJOS
July 22, 2020, 4:49am
10
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
dJOS
July 22, 2020, 5:14am
12
Cheers, Iβll try that when my C7 arrives.
2 Likes