Rebuilding the Nest plugin

For heating/cooling related questions in Domoticz
dotms
Posts: 28
Joined: Monday 01 May 2017 22:52
Target OS: Linux
Domoticz version: git
Location: Netherlands
Contact:

Rebuilding the Nest plugin

Post by dotms » Monday 01 May 2017 23:15

Domoticz comes with a hardware plugin to control the Nest thermostat and the accompanying smoke/co detectors.

While this works (for now) there are some issues with this plugin:
  • It uses a non-public API. As far as I can tell an old API for mobile applications is used. Several projects (including Domoticz) use this API but there's no telling how much longer it will work.
  • Documentation for this API is non-existant. By the looks of it some (successful) reverse engineering has been done to access the API.
  • Having 2FA (2 factor authentication) enabled on the account locks Domoticz out because Domoticz cannot supply an additional PIN code.
  • (minor issue): Plain credentials to the Nest account need to be entered and be kept up to date to allow Domoticz to keep working.
Nest has a solution for this. There is a public developer REST API available which is fully supported, is documented. The 2FA issue is circumvented by having OAuth support (so you generate a token specifically for Domoticz that it can use as a 'password' to access the Nest API).

I went ahead and adapted the current Nest plugin to use the new authentication method, calls and properties (for those interested in code see here). Still needs a bit of polishing and cleanup though.

There are some points that still need to be tackled:
  • Getting an access token for Domoticz is a kind of convoluted process: you need to register with Nest as a developer, create an application and permission set, log in as that application, get one-time PIN code, use that PIN code to obtain token. While it is certainly doable, it will need to be well documented on the Wiki. Even then it is much less accessible than just entering a user+pass to make it work.
  • I intend on having it replace the old plugin, but it is not compatible since it uses a different form of authentication.
  • What are the thoughts on the old and new style plugins coexisting in Domoticz?
Happy to hear your thoughts on this.

dotms
Posts: 28
Joined: Monday 01 May 2017 22:52
Target OS: Linux
Domoticz version: git
Location: Netherlands
Contact:

Re: Rebuilding the Nest plugin

Post by dotms » Wednesday 03 May 2017 22:46

Any thoughts?

Graph54
Posts: 5
Joined: Thursday 04 May 2017 16:05
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Rebuilding the Nest plugin

Post by Graph54 » Thursday 04 May 2017 16:13

Hi Dotms !

This is a very good idea ! If you can improve this part that would be really great. I am not very good at coding but If I can help ... :)

Damnet
Posts: 14
Joined: Friday 24 February 2017 21:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Rebuilding the Nest plugin

Post by Damnet » Sunday 18 June 2017 19:58

That would really be a step up!!

Dlanor
Posts: 105
Joined: Sunday 22 March 2015 17:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Rebuilding the Nest plugin

Post by Dlanor » Saturday 15 July 2017 8:12

Your Nest Thermostat will automatically switch to Eco Temperatures after it senses that nobody’s home. You can also manually set your thermostat to Eco Temperatures anytime, even when you’re home.
Is there a fast way to add the Eco mode as a switch in domoticz?
Domoticz | Dashticz V2 | Raspberry Pi | RFXCOM RFXtrx433E USB | RFlink 433Mhz | SONOFF

Graph54
Posts: 5
Joined: Thursday 04 May 2017 16:05
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Rebuilding the Nest plugin

Post by Graph54 » Tuesday 19 September 2017 17:29

Hi ! I've seen the code you've done on Github but I don't really understand where we are now :) Do we have to compile our own Domoticz or is it planned to be part of the official branch ? I do apologize for my "beginner's" questions :)

dotms
Posts: 28
Joined: Monday 01 May 2017 22:52
Target OS: Linux
Domoticz version: git
Location: Netherlands
Contact:

Re: Rebuilding the Nest plugin

Post by dotms » Sunday 03 December 2017 23:58

It's been a while since I last posted, so let's post an update.

Since last post no noteworthy action has been done on my side. Different priorities in life shifted my attention kind of away. Besides this my pc that I use to code/build is a pile of parts now so I'll need to get that up and running again. I expect that to be finished probably within the next week or so, but the time that I can spend on domoticz itself is quite limited unfortunately.

Once I get the build/coding machine working I need to catch up with the current domoticz code base. There probably have been some changes upstream so I need to merge those changes into my downstream repository and hope nothing major breaks :) From there I'll test stuff again, write some documentation and see if I can cobble a pull request together so the code ends up in the main domoticz code tree.

Besides that: I noticed that for me the current Nest device in Domoticz stopped working (at least for me it did: "Error: Nest: Error login!"). Running latest domoticz git version. Anyone else running into this as well resulting in Nest support currently being broken? If so I can try and give the above a little more priority since that hits more people than just me.

edit: managed to resolve the login issue. Was an issue on the side of probably Debian 9. Reverted to Ubuntu 16.04 and all is fine.

dotms
Posts: 28
Joined: Monday 01 May 2017 22:52
Target OS: Linux
Domoticz version: git
Location: Netherlands
Contact:

Re: Rebuilding the Nest plugin

Post by dotms » Thursday 28 December 2017 20:47

Small update on my part.
  • My build machine is up and running again.
  • Merged upstream changes from domoticz/master repo into my version.
  • It still builds. Did some layout fixes and everything works first time.
I did have to change a lot of stuff around to get it to work in Visual Studio 2017 so I did not commit any msbuild related stuff. I'll try and see if I can get it in such a state that it's still compatible with VS2015. If I'm lucky I might be able to squish out a pull request.

dotms
Posts: 28
Joined: Monday 01 May 2017 22:52
Target OS: Linux
Domoticz version: git
Location: Netherlands
Contact:

Re: Rebuilding the Nest plugin

Post by dotms » Friday 29 December 2017 0:35

Another update: I submitted a pull request: https://github.com/domoticz/domoticz/pull/2026.

If anyone wants to test this new functionality the basic steps come down to:

- Compile a new version of Domoticz from my git repo (while the pull request is not yet accepted).
- Register for an account at Nest Developers
- Create an application so you get a product id and a secret.
- Follow the link displayed so you get a pin code.
- Enter those 3 pieces in domoticz so it will fetch an API key and can communicate with Nest in a secure manner.

Image

Mdieli
Posts: 14
Joined: Saturday 14 February 2015 12:18
Target OS: Linux
Domoticz version: BETA
Location: The Netherlands
Contact:

Re: Rebuilding the Nest plugin

Post by Mdieli » Sunday 07 January 2018 10:26

Thanks dotms!
Just tested it here in my test environment and all is looking good and working like expected thus far!
I hope integration in domoticz will be done quickly. :)

Madgeni
Posts: 1300
Joined: Friday 25 March 2016 18:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Rebuilding the Nest plugin

Post by Madgeni » Saturday 20 January 2018 14:12

Hi - does this still split out NEST functionality into multiple devices? Is there still a separate setpoint and sensor?
Native Alexa skill and Google app - register at https://www.controlicz.com

MarceldeJongNL
Posts: 46
Joined: Tuesday 03 May 2016 10:07
Target OS: Raspberry Pi
Domoticz version: 3.5108
Location: Barendrecht
Contact:

Re: Rebuilding the Nest plugin

Post by MarceldeJongNL » Tuesday 23 January 2018 14:10

gizmocuz denied the pull request, with the following comment:

Is it possible you could submit the pull request against the development branch ? Patches against the master branch are not allowed (Sorry)
Hardware: Raspberry Pi 2B | RFXCOM RFXtrx433E v1 | Synology DS213+ | KaKu Clones | Conrad RSL switches | KAKu Doorbell Clone | USB Webcam | ICY Thermostat | Resol DL2 | Imatic Relay Board | Eminent 6230 | Eminent 6220 | iMatic 16 ports Relay Board

dotms
Posts: 28
Joined: Monday 01 May 2017 22:52
Target OS: Linux
Domoticz version: git
Location: Netherlands
Contact:

Re: Rebuilding the Nest plugin

Post by dotms » Monday 29 January 2018 23:28

I'll put some effort in a new pull request this weekend or sooner :)

poudenes
Posts: 565
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Rebuilding the Nest plugin

Post by poudenes » Tuesday 06 March 2018 11:40

Version: 3.8975
Build Hash: 63d0d07e
Compile Date: 2018-02-28 08:26:48
dzVents Version: 2.4.1
Platform: Raspbian Jessie (updated today 05-03-2018)
Hardware: Nest Thermostat/Protect OAuth

Nest Thermostat/Protect normal way with username password work without problems.
But i have now 3 Protect devices. And with normal username/pasword way connect i only see smoke sensors.

When i use the OAuth method i see smoke and CO Sensors. But then i get sometimes this error:

Code: Select all

2018-03-05 10:17:34.832 Error: NestOAuthAPI: Error getting structures!
2018-03-05 10:18:06.090 Error: NestOAuthAPI: Error login!
2018-03-05 10:18:37.232 Error: NestOAuthAPI: Error login!
2018-03-05 10:19:08.390 Error: NestOAuthAPI: Error login!
2018-03-05 10:19:39.903 Error: NestOAuthAPI: Error login!
2018-03-05 10:20:11.783 Error: NestOAuthAPI: Error login!
2018-03-05 10:20:43.115 Error: NestOAuthAPI: Error login!
2018-03-05 10:21:47.672 Error: NestOAuthAPI: Error getting structures!
2018-03-05 10:22:18.915 Error: NestOAuthAPI: Error login!
2018-03-05 10:22:49.899 Error: NestOAuthAPI: Error login!
2018-03-05 10:23:24.597 Error: NestOAuthAPI: Error login!
2018-03-05 10:23:55.840 Error: NestOAuthAPI: Error login!
2018-03-05 10:24:27.029 Error: NestOAuthAPI: Error login!
2018-03-05 10:24:58.184 Error: NestOAuthAPI: Error login!
2018-03-05 10:25:29.463 Error: NestOAuthAPI: Error login!
2018-03-05 10:26:00.626 Error: NestOAuthAPI: Error login!
2018-03-05 10:26:31.214 Error: NestOAuthAPI: Error login!
2018-03-05 10:27:01.849 Error: NestOAuthAPI: Error login!
2018-03-05 10:27:33.006 Error: NestOAuthAPI: Error login!
2018-03-05 10:28:04.514 Error: NestOAuthAPI: Error login!
2018-03-05 10:28:35.651 Error: NestOAuthAPI: Error login!
2018-03-05 10:29:06.840 Error: NestOAuthAPI: Error login!
2018-03-05 10:32:23.035 Error: NestOAuthAPI: Error getting devices!
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

User avatar
tcviper
Posts: 172
Joined: Monday 30 June 2014 13:34
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands
Contact:

Re: Rebuilding the Nest plugin

Post by tcviper » Monday 19 March 2018 15:42

Either Im blind or stupid but i cannot seem to find the OAUTH PIN anywhere when im editting a Nest application on the Nest dev pages.
I do find my id and secret, but there is nowhere i can find the oauth pin.

dotms
Posts: 28
Joined: Monday 01 May 2017 22:52
Target OS: Linux
Domoticz version: git
Location: Netherlands
Contact:

Re: Rebuilding the Nest plugin

Post by dotms » Monday 19 March 2018 15:48

In your Nest developer portal there should be an authentication link on the product page (below the product id and secret). Follow that one, log in with your Nest credentials and you'll get a PIN.

Robbie
Posts: 35
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: Rebuilding the Nest plugin

Post by Robbie » Wednesday 21 March 2018 2:02

Are you planning to also add a switch for the "Manual Eco Mode" like the other nest-plugin?

poudenes
Posts: 565
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Rebuilding the Nest plugin

Post by poudenes » Wednesday 21 March 2018 12:41

dotms wrote:
Monday 19 March 2018 15:48
In your Nest developer portal there should be an authentication link on the product page (below the product id and secret). Follow that one, log in with your Nest credentials and you'll get a PIN.

Any idea why i get lots of errors?
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

leecollings
Posts: 170
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi
Domoticz version:
Location: United Kingdom
Contact:

Re: Rebuilding the Nest plugin

Post by leecollings » Thursday 22 March 2018 18:15

Robbie wrote:
Wednesday 21 March 2018 2:02
Are you planning to also add a switch for the "Manual Eco Mode" like the other nest-plugin?
Isn't that what the current 'ECO' switch is?

Robbie
Posts: 35
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: Rebuilding the Nest plugin

Post by Robbie » Friday 23 March 2018 14:54

leecollings wrote:
Thursday 22 March 2018 18:15
Robbie wrote:
Wednesday 21 March 2018 2:02
Are you planning to also add a switch for the "Manual Eco Mode" like the other nest-plugin?
Isn't that what the current 'ECO' switch is?
The original Nest Thermostat/Protect adds this 'ECO' switch.
But this new Nest Thermostat/Protect OAuth (the rebuilded plugin which is discussed in this topic) does not have this ECO switch.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests