As this might also be useful for others who have the Evohome system of Honeywell; below a Python script I use to send temperature values of my house to Emoncms.
#!/usr/bin/python
# Script to monitor and read temperatures from Honeywell EvoHome Web API
# Load required libraries
import requests
import json
import time
# Set your Evohome login details in the 2 fields below
USERNAME = 'LOGONNAME'
PASSWORD = 'PASSWORD'
# 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'}
data = json.dumps(postdata)
response = requests.post(url, data=data, headers=header)
str_response = response.content.decode("utf-8")
# print(str_response)
userinfo = json.loads(str_response)
# Extract the sessionId and your userid from the response
userid = userinfo['userInfo']['userID']
sessionId = userinfo["sessionId"]
while True:
params = ""
# Next, using your userid, get all the data back about your site
url = 'https://tccna.honeywell.com/WebAPI/api/locations?userId=%s&allData=True' % userid
header['sessionId'] = sessionId
response = requests.get(url, data=json.dumps(postdata), headers=header)
str_response = response.content.decode("utf-8")
# print(str_response)
fullData = json.loads(str_response)[0]
for device in fullData['devices']:
if params != "":
params += ","
# Add every device with values to url json string
params += device['name'] + "_temp:"
params += str(device['thermostat']['indoorTemperature'])
params += "," + device['name'] + "_thermostat:"
params += str(device['thermostat']['changeableValues']['heatSetpoint']['value'])
print(params)
# Below I will generate the url I am using two URLS: 1 for legacy emoncms and 1 for Emoncms9
url = "http://URLTOEMONCMS/input/post.json?node=2&apikey=APIKEY&json={"
url += params + "}"
print(url)
url2 = "http://URLTOSECONDEMONSMSINSTALLATION/input/post.json?node=2&apikey=APIKEY&json={"
url2 += params + "}"
print(url2)
# now open the url and send the values
response = requests.get(url, headers=header)
response2 = requests.get(url2, headers=header)
# read the response and print it
str_response = response.content.decode("utf-8")
print(str_response)
str_response2 = response2.content.decode("utf-8")
print(str_response2)
#clear the parameters for the next round
del params
# sleep 60secs
time.sleep(90)