more G-Labs products

Author Topic: Nest Thermostat  (Read 3113 times)

February 23, 2016, 12:21:56 PM
Read 3113 times

ajays

  • *
  • Information
  • Newbie
  • Posts: 3
This is an interface to the Nest Thermostat via a php script.
It uses Guillaume Boudreau's Unofficial Nest Learning Thermostat API (https://github.com/gboudreau/nest-api) to get/set information on the Nest Thermostat as required.

The Nest Widget
The widget design is based on the Weather Underground and Security Alarm System widgets.
The widget:
1) Displays Nest Thermostat Heating information
   (Current Temperature, Target Temperature, Humidity, Battery level, Nest Status, Heating ON/OFF, Nest IP address, Nest Serial number)
2) Allows you to set the Target Temperature
3) Allows you to Set/End Away

Notes
1) You will need a working PHP environment to use this interface.
2) The unofficial Nest API requires your Nest userid and password. Supply these via the Nest Thermostat program options (step 8a/8b below); these are stored in a configuration file (nestInterface.cfg). Your nest password is encrypted. If you need to re-create this file, just repeat step 8b below; this forces the Nest Thermostat program to re-create this file.
3) This Nest Thermostat program only covers Nest heating (not cooling). I do not have cooling on my Nest thermostat so could not test that :(
4) If you have more than one Nest Thermostat you will have to add the Nest serial number when you setup the widget. If it is left empty the Unofficial Nest Learning Thermostat API selects your default Nest device. Find the Nest serial number by logging in to the Nest website, selecting a Thermostat and then choosing Settings > Technical Info.

Installation
1) Create a <nest-interface> directory (program defaults to /usr/local/bin/nest) and extract the Nest interface scripts [1] in to it
2) Download Guillaume Boudreau's Unofficial Nest Learning Thermostat API (https://github.com/gboudreau/nest-api/archive/master.zip)
3) Extract this in to your <nest-interface> directory. It will extract in to a subdirectory called <nest-interface>/nest-api-master
4) Import the Nest Thermostat widget [2]
5) Extract the Nest Thermostat widget images [3] in to <your-homegenie-directory>/html/pages/control/widgets/nest/thermostat/images
6) Import the Nest Thermostat program [4]
7) Enable the Nest Thermostat program
8 ) Select the Nest Thermostat program and set the program options
8a) Enter your Nest userid
8b) Enter your Nest password
8c) Set the number of Nest thermostats you require
8d) Check the widget refresh interval
8e) Set the min/max temperature values appropriately (defaults are set for Nests that use the Centigrade temperature scale)
8f) Set DEBUG to TRUE just while you initially setup the widget
8g) Check the paths to the PHP binary and your <nest-interface> directory are set correctly
9) Restart the Nest thermostat program - you should get notified that "The nestInterface.cfg file has been (re)created".
10) Add a Nest Thermostat widget to a homegenie dashboard, give it a name and leave the nest serial number box blank
If all is OK, the widget should display correctly, so...
11) If you need to, add another Nest Thermostat widget to a homegenie dashboard, give it a name, but this time enter the nest serial number in the box provided.
When you are happy all is working...
12) Set the DEBUG option to FALSE

Problem diagnosis
If the widget does not display properly:
1) Try using the widget refresh button a couple of times.
2) Check the DEBUG option is set to TRUE on the Nest Thermostat program and then search the Homegenie log file for 'Nest Thermostat DEBUG' to find further information.

Any feedback and bug reports welcome.

February 27, 2016, 10:13:30 PM
Reply #1

cmptrblder

  • *
  • Information
  • Newbie
  • Posts: 12
Damn, thank you, I'm going to install this tonight or tomorrow, nie work, KUDO'S

March 01, 2016, 12:53:52 PM
Reply #2

ajays

  • *
  • Information
  • Newbie
  • Posts: 3
Thanks for the feedback - hope you find it useful.

I have attached updates to the widget and the program which I suggest you install instead of the ones on my original post.
These fix a fault when trying to change the target temperature on the Nest thermostat.






April 16, 2016, 03:56:56 AM
Reply #3

cmptrblder

  • *
  • Information
  • Newbie
  • Posts: 12
I have installed everything as you have instructed, and in the debug log it sais successfully connected to nest, but it never display the temp or controls in home genie.  Any pointers on what may be wrong or what I can provide to help debug this?  Also is there any special php modules required?

Thnx

Log Snipet:

2016-04-16 08:37:24.3445 Debug Nest Thermostat DEBUG (callNestInterface) - Script Output: Script Arguments: /usr/local/bin/nest/nestInterface.php getDeviceInfo
2016-04-16 08:37:24.3445 Info HomeAutomation.Nest   1   -   Program.UiRefresh   Nest data Updated

April 16, 2016, 08:01:47 PM
Reply #4

ajays

  • *
  • Information
  • Newbie
  • Posts: 3
From just those two log entries it looks like Homegenie is not getting any data passed back from the nestInterface.php script, so there is no information to be displayed for you. When it is working properly you will see multiple lines of debug output, one for each parameter the script has picked up from Nest.
 
I have not installed any special php modules.

Please can you run the attached nestTest.php script. Copy it to the same directory you installed the nestInterface.php script into. You need to edit it first to add in your Nest logon details. Run it with the command "php nestTest.php". It will try to connect to Nest and display some information about the Nest devices you have.

April 21, 2016, 10:40:32 PM
Reply #5

cmptrblder

  • *
  • Information
  • Newbie
  • Posts: 12
Thanx for the test script it really helped, I was actually missing the php5-curl module.  I installed it and its working like a champ!  My Nest is a Version 3 and everything in your program is working fine with it.  THANK you for your great work !

December 10, 2016, 06:12:57 PM
Reply #6

jeffkjolley

  • *
  • Information
  • Newbie
  • Posts: 1
Has anyone made any efforts to add Cool & Heat/Cool modes to this? I live in a warm climate and use cooling as much as I use heating... I really need to learn how to code.

February 28, 2017, 02:32:02 AM
Reply #7

odinn

  • *
  • Information
  • Newbie
  • Posts: 4
    • CDS
I made a minor code change in controller.js

I have 4 Nest thermostats (4 zones in my house) and have custom labeling, so instead of seeing these custom labels, I see a formatted ID in the Location.  In the modules, you can name each one of the 4 nest thermostats, so I used this and changed line 129 in controller.js

The fist line starting with var location grabs the nest name (which, in my case, is a formatted ID and not a name) so adding the next 2 lines allows my custom module.Name to be shown instead.

Code: [Select]
      var location        = HG.WebApp.Utility.GetModulePropertyByName(module,'Location').Value;
      if (module.Name)
        location          = module.Name;

As soon as I get more time, I'm going to dig into this more and see what else I can do with it.
--
Risk All - Regret Nothing