Honeywell Evohome Monitoring

You might want to check out this thread: Script for feeding Honeywell Evohome data into Emoncms

I’m successfully using the Python script that was provided to get the Evohome data.

I made a few modifications, I think mainly to stop the script exiting when the connection timed out:

#!/usr/bin/python
import requests
import json
import time
import math
from sys import exit

USERNAME = 'username'
PASSWORD = 'password'

while True:
    # Initial JSON POST to the website to return your userdata
    url = 'https://tccna.honeywell.com/WebAPI/api/Session'
    postdata = {'Username': USERNAME, 'Password': PASSWORD, 'ApplicationId': '91db1612-73fd-4500-91b2-e63b069b185c'}
    header = {'content-type': 'application/json'}
    # get sessionID
    data = json.dumps(postdata)
    
    error = 0
    
    try:
        response = requests.post(url, data=data, headers=header)
    except:
        print("Couldn't get data")
        error = 1
        time.sleep(60)
        
    if error == 0:
        str_response = response.content.decode("utf-8")

       # print(str_response)
        
        try:
            userinfo = json.loads(str_response)
        except:
            print("Couldn't decode data")
            error = 1
            time.sleep(60)

        if error == 0:
            if 'userInfo' not in userinfo: 
                #print "not allowed - header"
                # sleep for 5 minutes
                time.sleep(300)
                continue

            # here havea  connection so can get data
            userid = userinfo['userInfo']['userID']
            sessionId = userinfo["sessionId"]

            # setup and receive data then loop and extract temperature for each device
            params = ""
            paramsSet = ""
            url = 'https://tccna.honeywell.com/WebAPI/api/locations?userId=%s&allData=True' % userid
            header['sessionId'] = sessionId
            try:
                response = requests.get(url, data=json.dumps(postdata), headers=header)
            except:
                print("Timed out")
                error = 1
                time.sleep(60)
                
            if error == 0:
                str_response = response.content.decode("utf-8")
               # print(str_response)
                
                try:
                    fullData = json.loads(str_response)[0]
                except: 
                    print("couldn't decode data")
                    error = 1
                    time.sleep(60)

                if error == 0:
                    if 'devices' not in fullData: 
                        print("not allowed - data")
                        time.sleep(300)
                        continue


                    for device in fullData['devices']:
                        stemp = ""
                        if params != "": params += ","
                        # Add device current temperature
                        if device['thermostatModelType'] == "DOMESTIC_HOT_WATER": params += "hot_water_temp:"
                        else:  params += device['name'] + "_temp:"
                        stemp = str(round(device['thermostat']['indoorTemperature'],1))
                        #stemp = str(math.ceil((device['thermostat']['indoorTemperature'])*10)/10)
                        params += stemp

                    for deviceSetTemp in fullData['devices']:
                        if params != "": params += ","
                        params += deviceSetTemp['name'] + "_set_temp:"
                        stemp = str(round(deviceSetTemp['thermostat']['changeableValues']['heatSetpoint']['value'],1))
                        params += stemp


                    #now generate the insert into emoncms
                    url = "http://localhost/emoncms/input/post.json?node=evohome&apikey=PUT_API_KEY_HERE&json={"
                    url += params + "}"
                    print(url)
                    response = requests.get(url, headers=header)

                    # debug - read the response and print it
                    str_response = response.content.decode("utf-8")
                    # print(str_response)

                    del params

                    time.sleep(300)