Page 1 of 6 123456 LastLast
Results 1 to 10 of 56

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

  1. #1
    Automated Home Jr Member Bill M's Avatar
    Join Date
    Nov 2015
    Posts
    10

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

    First of all, I may have a technical background, but that is many years behind me now! However, I was really interested in accessing the API and producing temperature graphs for Evohome.
    I read all the posts on here about Python and plot.ly and it took me a long time to understand it with tutorials etc and get it working. Now that I have, I thought I would share my “idiots guide” whilst at the same time acknowledging the excellent work by others who worked it all out in the first place!

    So, the steps are:

    1 Install Python
    Download and Install Python 2.7
    https://www.python.org/downloads/

    Make sure you select option to add Python.exe to PATH
    (you will need to reboot to pick this up in your settings, if you don’t know how to add this manually)


    2. Install the relevant Python modules to support what we are trying to do
    Install pip, setuptools, and wheel
    • Download get-pip.py from https://bootstrap.pypa.io/get-pip.py and save to your C:\Python27 folder.
    • At the command prompt switch to the C:\Python27 folder and run:

    python get-pip.py

    This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already. This is explained here:
    [URL="http://python-packaging-user-guide.readthedocs.org/en/latest/installing/"]


    Now that the above is installed the rest of the modules are easy to install as they will be automatically retrieved, downloaded and installed when you type the following at the Command Prompt:
    Pip install requests
    Note: The requests module is explained here: http://docs.python-requests.org/en/master/

    Pip install plotly
    Note plot.ly is the online graphing and is explained here: https://plot.ly/python/getting-started/ and here https://github.com/PieterVO/EvohomeTemperature

    Pip install evohomeclient
    Note this is put together by some excellent work by members on this forum and the details are here
    http://evohome-client.readthedocs.org/en/latest/


    More info here if you are curious:
    http://python-packaging-user-guide.r...st/installing/
    ○ The requests module is explained here: http://docs.python-requests.org/en/master/
    ○ Installing modules in general is covered here: http://programminghistorian.org/less...on-modules-pip
    http://www.wikihow.com/Install-Pytho...s-on-Windows-7


    3. Evohome Client
    Now you can play with the python scripts like I did. If you open IDLE (Python GUI) which was installed with Python you can paste the text in any of these examples here:
    http://www.automatedhome.co.uk/vbull...ntrol-remotely
    Don’t forget to replace your evohome username (email address) and password to get it working.
    Say you save it as test.py, then just run python test py from the command prompt
    This will start reporting temperatures of your zones back to your screen. Initially I captured them all to a file and imported into Excel as a CSV file and made a pivot table. This was great, until I discovered plot.ly….


    4. plot.ly
    This is an on-line graphing too. If you create a free account and follow the instructions here https://github.com/PieterVO/EvohomeTemperature with the config.ini file to enter your evohome username and password along with the stream IDs from plot.ly account, you can forget excel. This works beautifully and you can even create dashboards with all graphs on the same page.


    5. Bear in mind gathering the date is a repeating cycle, running a python script from a DOS prompt for as long as you want to gather and graph date. It means your computer is on constantly. I have read about using raspberry pi to do this, but I haven’t go that far. Just happy with the graphs and knowing I am saving energy and money!!

  2. #2
    Automated Home Sr Member
    Join Date
    Nov 2015
    Posts
    95

    Default

    Thanks for sharing - this looks really good and Im hoping to get the time to try this out.

    My holy grail is being able to control the evohome from scripts on the PC, and then link this with voice recognition software. I have the vision of walking into the house and saying "Hot water on for an hour please", or "Set the lounge heating to 21 degrees until 11pm" and the system knowing what to do.

    I am almost certain this is technically possible, but finding the right tools for the job is difficult. I do like IT and have a decent knowledge of it - but actual coding is stretching my knowledge - Id be burried in google to try and learn that part.

    Id also like the above to be able to control lighting too, which as Siri can talk to philips hue lights I know is posible, but getting the whole thing working in harmony would just be brilliant.

  3. #3
    Automated Home Jr Member zcapr17's Avatar
    Join Date
    Oct 2014
    Location
    UK
    Posts
    20

    Default

    Quote Originally Posted by Cchris View Post
    My holy grail is being able to control the evohome from scripts on the PC, and then link this with voice recognition software. I have the vision of walking into the house and saying "Hot water on for an hour please", or "Set the lounge heating to 21 degrees until 11pm" and the system knowing what to do.
    You can do this right now with Siri, Homebridge, and a Samsung SmartThings Hub. Minimal coding required.

    See here: https://community.smartthings.com/t/...ridge/16701/27
    (to get the Evohome-SmartThings integration, you need to sign up to the beta, but it should be public any day now).

    I use two HomeKit scenes in conjunction with "Rules Engine" (a SmartThings SmartApp)...
    - When going to bed I can say "Siri, I'm going to work tomorrow" and SmartThings will set my house in 'Working Away' mode, which means it will heat my bedroom and turn on my bathroom towel rail at the right time in the morning.
    - Alternatively, I can say "Siri, I'm working from home tomorrow" and SmartThings will heat my bedroom at a later time and automatically heat my home office until 5pm.

    Note, I rarely find the need to issue specific commands like "Set Lounge Thermostat to 21 degrees until 11pm". If SmartThings detects I'm in a room outside of my normal schedule (via the motion sensors in each room), it automatically extends the Evohome heating in that room until I leave. At a macro-location level, if I go more than a few miles from home, SmartThings will put Evohome in 'Away' mode, and when I leave work it will resume normal Evohome scheduling.

    HTH

    Z
    Last edited by zcapr17; 26th February 2016 at 10:58 PM. Reason: Additional info on how I use Siri to control Evohome

  4. #4
    Automated Home Guru
    Join Date
    Jan 2015
    Posts
    102

    Default

    Thank you for posting instructions - they're very clear. However I've been trying to get this working for hours now and keep getting an error.

    I've filled out the config.ini file as follows:

    #rename this file to config.ini

    [Plotly]

    Username: xxxxxxxx

    APIkey: xxxxxxxxxx

    [Evohome]

    Username: XXXXXXXXX@gmail.com

    Password: XXXXXXXX

    #same roomnames on Evohome system

    [Rooms]
    Living Room: XXXXXXXXXX

    Kitchen: XXXXXXXXXX


    However, on running the "EvohomeTemperature.py" file (by opening it in IDLE and running the module - is this the right way?) I get the following error:

    Traceback (most recent call last):
    File "C:\Python27\Myscripts\EvohomeTemperature-master\EvohomeTemperature.py", line 46, in <module>
    stream_id = Config.get('Rooms', device['name'])
    File "C:\Python27\lib\ConfigParser.py", line 618, in get
    raise NoOptionError(option, section)
    NoOptionError: No option '' in section: 'Rooms'


    I'm at a loss. Any ideas? Any advice appreciated.

  5. #5
    Automated Home Jr Member Bill M's Avatar
    Join Date
    Nov 2015
    Posts
    10

    Default

    You need to run the script from a DOS Command Prompt. Change to the folder where you have saved the script and type python evohometemperature.py

    regarding the config.ini file, some pointers from my experience:
    - plotly APIkey can be found when you log in to your new plot.ly account, click your username, then settings and then the API key is on the left of the screen.
    - For your rooms, it is important to create an API stream token for each zone that you have set up on Evohome (don't just test it with a couple as it won't work!)
    - It is also important that you spell your rooms exactly as on EvoHome (I have my son's room as Matt's room and missed off the apostrophe in the .ini file and it failed!)

  6. #6
    Automated Home Guru
    Join Date
    Jan 2015
    Posts
    102

    Default

    thanks for the quick reply...

    I've updated the config.ini file so it includes all 11 zones, all spelt perfectly and each with its own API stream token.

    I've ran the script from the command prompt, but am getting the same error:

    C:\EvohomeTemperature-master>python evohometemperature.py
    Traceback (most recent call last):
    File "evohometemperature.py", line 46, in <module>
    stream_id = Config.get('Rooms', device['name'])
    File "C:\Python27\lib\ConfigParser.py", line 618, in get
    raise NoOptionError(option, section)
    ConfigParser.NoOptionError: No option '' in section: 'Rooms'


    To me as a novice, it looks like the script isn't pulling something from the config file correctly (something to do with rooms?)

    This is the exact layout of my config.ini file - is it correct? There aren't any spaces where there's not meant to be?

    #rename this file to config.ini

    [Plotly]
    Username: xxxxxxxx
    APIkey: xxxxxxxxxx

    [Evohome]
    Username: xxxxxxxxxx@gmail.com
    Password: xxxxxxxx

    #same roomnames on Evohome system
    [Rooms]
    Living Room: xxxxxxxxxx
    Kitchen: xxxxxxxxxx
    Nursery: xxxxxxxxxx
    Study: xxxxxxxxxx
    Hallway: xxxxxxxxxx
    Master Bed: xxxxxxxxxx
    Spare Bed: xxxxxxxxxx
    Landing: xxxxxxxxxx
    Bathroom: xxxxxxxxxx
    En Suite: xxxxxxxxxx
    WC: xxxxxxxxxx

  7. #7
    Automated Home Jr Member Bill M's Avatar
    Join Date
    Nov 2015
    Posts
    10

    Default

    Just checked this against my file and looks spot on. I can only guess it is the libraries that are not all installed.

    Try saving the following into a test.py file (using IDLE) and running it from the command prompt. Change the email and password to your evohome ones. It should just list your rooms and temperatures...



    import requests
    import json

    USERNAME = 'whatever@email.com'
    PASSWORD = 'password'

    url = 'https://rs.alarmnet.com/TotalConnectComfort/WebAPI/api/Session'
    postdata = {'Username':USERNAME,'Password':PASSWORD,'Applicat ionId':'91db1612-73fd-4500-91b2-e63b069b185c'}
    headers = {'content-type':'application/json'}

    response = requests.post(url,data=json.dumps(postdata),header s=headers)

    userData = json.loads(response.content)

    userId = userData['userInfo']['userID']
    sessionId = userData['sessionId']

    url = 'https://rs.alarmnet.com/TotalConnectComfort/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]

    for device in fullData['devices']:
    print device['thermostatModelType'], device['deviceID'], device['name'], device['thermostat']['indoorTemperature']

  8. #8
    Automated Home Guru
    Join Date
    Jan 2015
    Posts
    102

    Default

    hmmm, when I run that I get:

    Traceback (most recent call last):
    File "C:\Python27\Myscripts\test.py", line 15, in <module>
    userId = userData['userInfo']['userID']
    TypeError: list indices must be integers, not str

  9. #9
    Automated Home Guru
    Join Date
    Jan 2015
    Posts
    102

    Default

    ignore that, got it to list the temperatures, not sure what I changed. But that works... does that help?

  10. #10
    Automated Home Jr Member Bill M's Avatar
    Join Date
    Nov 2015
    Posts
    10

    Default

    That's good. It shows that you have installed everything correctly (well the same as mine anyway!).
    I seem to recall having a similar error at one point but that was because I tried it with just 2 rooms initially. Maybe create the config.ini file again from scratch? After that I am struggling as I had to google just about everything I learned to get this far...

    Hopefully one of the experts will step in and help?

Posting Permissions

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