Skip to content

Instantly share code, notes, and snippets.

@NeoCat
Last active August 17, 2024 15:14
Show Gist options
  • Save NeoCat/5279143 to your computer and use it in GitHub Desktop.
Save NeoCat/5279143 to your computer and use it in GitHub Desktop.
Set temperature of honeywell Wi-Fi thermostat by shell script
#!/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
@ricch-dhsr
Copy link

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.

@PatrickNY
Copy link

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>

@RichyT
Copy link

RichyT commented Feb 18, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment