Page 3 of 6 FirstFirst 123456 LastLast
Results 21 to 30 of 56

Thread: Beginners guide to graphing Evohome temperatures using python and plot.ly

  1. #21
    Automated Home Lurker
    Join Date
    May 2016
    Posts
    4

    Default

    Quote Originally Posted by WiteWulf View Post
    Thanks for this guide, Bill, it helped me get up and running sending data to an ELK stack pretty quickly. One thing to note, however: as of around midday today the old rs.alarmnet.com URLs stopped working. I changes the URLs in the scripts I based off your material to the tccna.honeywell.com URLs and everything worked as normal.
    Hi,

    I'm new here and trying to get a py script to work with evohome. I have tried several urls but none work. Could someone please post a simple script to compare Temperature Setpoint versus Actual Temperature? Would be much appreciated. Thanks Keith

  2. #22
    Automated Home Jr Member WiteWulf's Avatar
    Join Date
    Mar 2016
    Location
    Leicestershire
    Posts
    40

    Default

    Okay, this is heavily cribbed off Bill's earlier work in this thread. So long as you have the correct python modules installed and available (listed in the import lines at the top), and you enter in your username and password, it will poll your system's data on the Honeywell servers and output a timestamped list of location_id, location, measured temperature and set point. It will poll new data every 60 seconds.

    Code:
    import requests
    import json
    import time
    
    USERNAME = 'YOUR USERNAME HERE'
    PASSWORD = 'YOUR PASSWORD HERE'
    APPLICATIONID = '91db1612-73fd-4500-91b2-e63b069b185c'
    
    url = 'https://tccna.honeywell.com/WebAPI/api/Session'
    postdata = {'Username':USERNAME,'Password':PASSWORD,'ApplicationId':APPLICATIONID}
    headers = {'content-type':'application/json'}
    
    try:
            response = requests.post(url,data=json.dumps(postdata),headers=headers)
    except:
            print "Failed to connect/authenticate to Honeywell servers"
    
    userData = json.loads(response.content)
    
    userId = userData['userInfo']['userID']
    sessionId = userData['sessionId']
    
    url = 'https://tccna.honeywell.com/WebAPI/api/locations?userId=%s&allData=True' % userId
    
    headers['sessionId'] = sessionId
    
    response = requests.get(url,data=json.dumps(postdata),headers=headers)
    
    fullData = json.loads(response.content)[0]
    
    while True:
            now = time.strftime('%d-%m-%Y %H:%M:%S')
            try:
                    response = requests.get(url,data=json.dumps(postdata),headers=headers)
            except:
                    print now + " Failed to connect to Honeywell servers"
                    print "Waiting to retry..."
                    time.sleep(5)
            fullData = json.loads(response.content)[0]
            for device in fullData['devices']:
                    print now,device['deviceID'],device['name'],device['thermostat']['indoorTemperature'],device['thermostat']['changeableValues']['heatSetpoint']['value']
            print "Sleeping for 60s..."
            time.sleep(60)

  3. #23
    Automated Home Legend
    Join Date
    Sep 2014
    Location
    Scotland
    Posts
    1,928

    Default

    Quote Originally Posted by WiteWulf View Post
    Okay, this is heavily cribbed off Bill's earlier work in this thread. So long as you have the correct python modules installed and available (listed in the import lines at the top), and you enter in your username and password, it will poll your system's data on the Honeywell servers and output a timestamped list of location_id, location, measured temperature and set point. It will poll new data every 60 seconds.
    Polling the Honeywell servers every 60 seconds is too often. This may lead to the server throttling or blocking your requests. The generally accepted (unofficial) minimum time between requests for those using the API for graphing is 5 minutes. Temperatures don't change that fast that polling more often is useful, especially when the API rounds temperatures to 0.5 degrees. (A 0.5 degree change every 60 seconds is a lot faster than you'll ever see)

    If the system you are using for graphing polls more often or polls separately for each zone you should probably implement local caching of data like the evohome-munin plugin does:

    https://github.com/Infern1/evohome-m...home_#L86-L111

    Since each response contains the data for every zone once you query the server for one zone you can pull the data for the other zones from local disk from the 4 minute cache (in the above example) without re-querying the server.
    Last edited by DBMandrake; 3rd May 2016 at 09:15 PM.

  4. #24
    Automated Home Lurker
    Join Date
    May 2016
    Posts
    4

    Default

    Quote Originally Posted by WiteWulf View Post
    Okay, this is heavily cribbed off Bill's earlier work in this thread. So long as you have the correct python modules installed and available (listed in the import lines at the top), and you enter in your username and password, it will poll your system's data on the Honeywell servers and output a timestamped list of location_id, location, measured temperature and set point. It will poll new data every 60 seconds.

    Code:
    import requests
    import json
    import time
    
    USERNAME = 'YOUR USERNAME HERE'
    PASSWORD = 'YOUR PASSWORD HERE'
    APPLICATIONID = '91db1612-73fd-4500-91b2-e63b069b185c'
    
    url = 'https://tccna.honeywell.com/WebAPI/api/Session'
    postdata = {'Username':USERNAME,'Password':PASSWORD,'ApplicationId':APPLICATIONID}
    headers = {'content-type':'application/json'}
    
    try:
            response = requests.post(url,data=json.dumps(postdata),headers=headers)
    except:
            print "Failed to connect/authenticate to Honeywell servers"
    
    userData = json.loads(response.content)
    
    userId = userData['userInfo']['userID']
    sessionId = userData['sessionId']
    
    url = 'https://tccna.honeywell.com/WebAPI/api/locations?userId=%s&allData=True' % userId
    
    headers['sessionId'] = sessionId
    
    response = requests.get(url,data=json.dumps(postdata),headers=headers)
    
    fullData = json.loads(response.content)[0]
    
    while True:
            now = time.strftime('%d-%m-%Y %H:%M:%S')
            try:
                    response = requests.get(url,data=json.dumps(postdata),headers=headers)
            except:
                    print now + " Failed to connect to Honeywell servers"
                    print "Waiting to retry..."
                    time.sleep(5)
            fullData = json.loads(response.content)[0]
            for device in fullData['devices']:
                    print now,device['deviceID'],device['name'],device['thermostat']['indoorTemperature'],device['thermostat']['changeableValues']['heatSetpoint']['value']
            print "Sleeping for 60s..."
            time.sleep(60)
    ------------------
    Im getting this error now

    /data/data/com.hipipal.qpyplus/files/bin/qpython-android5.sh "/storage/emulated/0/com.hipipal.qpyplus/scripts3/.last_tmp.py" && exit
    storage/emulated/0/com.hipipal.qpyplus/scripts3/.last_tmp.py" && exit <
    /data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.10.0-py2.7.egg/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/l...missingwarning.
    SNIMissingWarning
    /data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.10.0-py2.7.egg/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/l...latformwarning.
    InsecurePlatformWarning
    /data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.10.0-py2.7.egg/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/l...latformwarning.
    InsecurePlatformWarning
    /data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.10.0-py2.7.egg/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/l...latformwarning.
    InsecurePlatformWarning
    03-05-2016 23:53:32 1648402 20.0 19.5
    03-05-2016 23:53:32 1648405 Traceback (most recent call last):
    File "/storage/emulated/0/com.hipipal.qpyplus/scripts3/.last_tmp.py", line 41, in <module>
    print now,device['deviceID'],device['name'],device['thermostat']['indoorTemperature'],device['thermostat']['changeableValues']['heatSetpoint']['value']
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal not in range(128)
    1|u0_a249@gts28lte:/ $

  5. #25
    Automated Home Legend
    Join Date
    Sep 2014
    Location
    Scotland
    Posts
    1,928

    Default

    You'll need to update your version of Python on your system - what OS are you running this on ?

    A lot of TLS changes have happened in the last year that break compatibility with old TLS/SSL implementations, this includes out of date versions of Python.

  6. #26
    Automated Home Jr Member WiteWulf's Avatar
    Join Date
    Mar 2016
    Location
    Leicestershire
    Posts
    40

    Default

    Quote Originally Posted by DBMandrake View Post
    Polling the Honeywell servers every 60 seconds is too often. This may lead to the server throttling or blocking your requests. The generally accepted (unofficial) minimum time between requests for those using the API for graphing is 5 minutes. Temperatures don't change that fast that polling more often is useful, especially when the API rounds temperatures to 0.5 degrees. (A 0.5 degree change every 60 seconds is a lot faster than you'll ever see)

    If the system you are using for graphing polls more often or polls separately for each zone you should probably implement local caching of data like the evohome-munin plugin does:

    https://github.com/Infern1/evohome-m...home_#L86-L111

    Since each response contains the data for every zone once you query the server for one zone you can pull the data for the other zones from local disk from the 4 minute cache (in the above example) without re-querying the server.
    Yeah, my bad, should have pointed out that isn't my production code, just a demo to ensure you're getting good data back and to provide prompt feedback if you change a setpoint. My production system polls every 300s.

  7. #27
    Automated Home Jr Member WiteWulf's Avatar
    Join Date
    Mar 2016
    Location
    Leicestershire
    Posts
    40

    Default

    Quote Originally Posted by DBMandrake View Post
    You'll need to update your version of Python on your system - what OS are you running this on ?

    A lot of TLS changes have happened in the last year that break compatibility with old TLS/SSL implementations, this includes out of date versions of Python.
    QPython is a version of Python that runs on Android devices. I'm running python 2.7.11 on my dev machine and this QPython install seems to be running 2.7.x

    Keithflynn > See if there's a more up to date version of QPython available, or else run it in "proper" Python on a RasPi or something...

  8. #28
    Automated Home Guru
    Join Date
    Jan 2013
    Location
    Glasgow
    Posts
    186

    Default

    Here's a thought, would it be possible to put together a website that ran this.

    You would create a read-only account on your EvoHome, give those credentials to the website, give it your plot.ly details and the it would just sit and poll every 5 minutes and push to plot.ly ?

    Would just need a username/password for an account and then enter your details.

    This would save us all trying to spin all these up ourselves.

    Roy.

  9. #29
    Automated Home Jr Member WiteWulf's Avatar
    Join Date
    Mar 2016
    Location
    Leicestershire
    Posts
    40

    Default

    Quote Originally Posted by roydonaldson View Post
    Here's a thought, would it be possible to put together a website that ran this.

    You would create a read-only account on your EvoHome, give those credentials to the website, give it your plot.ly details and the it would just sit and poll every 5 minutes and push to plot.ly ?

    Would just need a username/password for an account and then enter your details.

    This would save us all trying to spin all these up ourselves.

    Roy.
    I'd imagine Honeywell throttle polling of details on a per IP basis. As soon as one server starts polling for data from many different households it'd get stomped on. At least that's what I'd do if I were running their service...but, yeah, nice idea.

  10. #30
    Automated Home Lurker
    Join Date
    May 2016
    Posts
    4

    Default

    Witewulf,

    I tried a newer version of Qpython last night but still didnt work. Im beginning to think my lack of experience with Python isnt helping things. Ill try it on a windows machine tonight. Thanks for the help though

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •