-
-
Save NeoCat/5279143 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Usage: ./honeywell_settmp.sh [-c|-h|-o] [<temp(F)>|schedule] | |
# Example: ./honeywell_settmp.sh -h 72 # set HEAT: temp=72F | |
# ./honeywell_settmp.sh -c schedule # set COOL: follow shceduled temp | |
# ./honeywell_settmp.sh -o # turn system OFF | |
######## Settings ######## | |
LOGIN="YOUR_MAIL_ADDRESS" | |
PASSWORD="YOUR_PASSWORD" | |
DEVICE_ID=12345 # number at the end of URL of the honeywell control page | |
########################## | |
SW=null | |
STATUS=1 | |
MODE=Heat | |
FAN=null | |
NO_SEND=0 | |
function usage { | |
echo "usage: $0 [-achofF] [<temp>|schedule]" | |
echo " <temp>: hold temp until next schedule" | |
echo " shcedule: follow scheduled temp settings" | |
echo "options:" | |
echo " -a : set system to AUTO" | |
echo " -c : set system to COOL" | |
echo " -h : set system to HEAT" | |
echo " -o : set system to OFF" | |
echo " -f : set fan to ON" | |
echo " -F : set fan to AUTO" | |
echo " -n : no settings; just read status" | |
} | |
while getopts "achofFn" flag; do | |
case $flag in | |
\?) usage; exit;; | |
a) SW=4; TEMP="";; | |
c) SW=3; MODE=Cool;; | |
h) SW=1;; | |
o) SW=2;; | |
f) FAN=1;; | |
F) FAN=0;; | |
n) NO_SEND=1;; | |
esac | |
done | |
shift $(( $OPTIND - 1 )) | |
TEMP="$1" | |
[ "$TEMP" = "" ] && STATUS=null | |
[ "$TEMP" = "" ] && TEMP=null | |
[ "$TEMP" = "schedule" ] && STATUS=0 | |
[ "$TEMP" = "schedule" ] && TEMP=null | |
# Login | |
curl -s -c /tmp/honeywell_cookie.dat https://mytotalconnectcomfort.com/portal/ -d UserName="$LOGIN" -d Password="$PASSWORD" -d timeOffset=0 > /dev/null | |
# Set Temp | |
if [ "$NO_SEND" = 0 ]; then | |
CMD='{"DeviceID":'$DEVICE_ID',"'$MODE'Setpoint":'$TEMP',"SystemSwitch":'$SW',"StatusHeat":'$STATUS',"StatusCool":'$STATUS',"FanMode":'$FAN'}' | |
echo "$CMD" | |
curl -s -b /tmp/honeywell_cookie.dat https://mytotalconnectcomfort.com/portal/Device/SubmitControlScreenChanges -H 'Content-Type:application/json; charset=UTF-8' -d "$CMD" | |
echo | |
fi | |
# Get Status | |
curl -s -b /tmp/honeywell_cookie.dat https://mytotalconnectcomfort.com/portal/Device/CheckDataSession/"$DEVICE_ID" -H X-Requested-With:XMLHttpRequest | |
echo | |
rm -f /tmp/honeywell_cookie.dat |
FYI - I found that I get a "401 - Unauthorized" error if I attempt too many accesses with this script. It appears that I can ping the temperature about once every 2 minutes.
Another FYI - it appears the 401 error comes from logging in too often. For more frequent refreshes, you can comment out the rm on the last line, and just execute the final curl statement. I'm assuming it uses the credentials cached in the cookie file. I'm also assuming those credentials expire at some point, and will need to be refreshed.
I had to update my curl. I also had to add --insecure to the end of the command to get around the certificate handshaking. I thing there is a better way, but I think I can trust the Honeywell site...?
This Command Line script is working perfectly for me. However in the Winter Time I'll be set in Emergecy Heat mode. How would the code be set for that function. For the buttons on the left hand side of my web site screen I have Heat, Cool, Off, EmHeat . I've played with a few switches but no luck. I would rather ask than keep jerking my equipment from Cooling mode to Heating Mode. ;-)
Found it. For Emergency Heat Mode leave the program as is but add a SW=0;; to the program. This switches it to Emergency Heat mode.
Is this code still working? It is exactly what I need, however it does not seem to work. I was getting a authentication error with the second curl command so I disabled that. Now it seems to run without error However it does not change the thermostat setting.
Thanks, Rich.
For me, this has been working forever! Did honeywell change something within the last day or two? Now I get:
<html><head><title>Object moved</title></head><body><h2>Object moved to <a href="/portal/">here</a>.</h2></body></html>
This seems to be relevant though I'm getting an invalid username or password error...
https://dirkgroenen.nl/projects/2016-01-15/honeywell-API-endpoints-documentation/
It looks like the URL is supposed to be https://mytotalconnectcomfort.com/WebAPI/api/Session.
The documentation on the Honeywell page uses Username and Password rather than username and password but neither seems to help. I've confirmed the username and password are correct.
FYI - I found that I get a "401 - Unauthorized" error if I attempt too many accesses with this script. It appears that I can ping the temperature about once every 2 minutes.