Page 11 of 14

Re: Nest Thermostat plug-in

Posted: Wed Apr 23, 2014 2:57 pm
by abuttino
I think I found something that could be very useful..

http://trevp.net/tlslite/

Re: Nest Thermostat plug-in

Posted: Wed Apr 23, 2014 6:28 pm
by krambriw
I created an account @ NEST and did some testing with the script below but I get 'TLSRemoteAlert: handshake_failure' with both methods I tried. The socket connects ok but the authorization handshake is where it stops.

Best regards, Walter

Here the script;

Code: Select all

import socket
HOST = "home.nest.com"
PORT = 443
user = 'your email'
pword = 'your password'

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.connect( (HOST, PORT) )

from tlslite import TLSConnection
connection = TLSConnection(sock)
print connection
connection.handshakeClientSRP(user, pword)
connection.close()

#from tlslite import HTTPTLSConnection
#connection = HTTPTLSConnection(HOST, PORT, username=user, password=pword)
#connection.connect()
#connection.close()

Re: Nest Thermostat plug-in

Posted: Wed Apr 23, 2014 6:42 pm
by abuttino
That could be because there are different user names and tokens to log in.

My username/ID consists of a 5 digit numerical phrase.

Thank you very much for your help Walter.

Re: Nest Thermostat plug-in

Posted: Wed Apr 23, 2014 9:01 pm
by abuttino
tlslite seems to be a bit outdated from what I've read, M2Crypto also has some great options for strong ciphers.

Re: Nest Thermostat plug-in

Posted: Wed Apr 23, 2014 10:13 pm
by abuttino
I got it solved with M2Crypto.

Before I release anything I need to talk to Dragon470 about releasing a compiled version ONLY. I may be a little paranoid or pompous, but I think that Nest is closely watching the progress of these threads. If we release a compiled version, it'll be a lot harder for them to crack down on this fix.

Re: Nest Thermostat plug-in

Posted: Sun Apr 27, 2014 2:32 pm
by Dragon470
M2Crypto is now the new connection method. Thanks to abuttino for the research and initial implementation. As a bonus m2Crypto is a bit faster.

Re: Nest Thermostat plug-in

Posted: Mon Apr 28, 2014 2:15 pm
by Dragon470
Small fix on get_object weather related

Added Duty-cycle in fan mode

added fan timer action (0 will turn off the fan if it was on a timer)



If anyone knows how to get the energy_latest from nest would be a huge benefit. The url seems to be transport_url /v1/subscribe?energy_latest.serial I have looked into it a few times but never seem to get anything working.

I also have looked into being able to do schedule setting to no avail.

Any other additions anyone wants, just list them here.

Re: Nest Thermostat plug-in

Posted: Wed Apr 30, 2014 4:21 am
by funat120mph
Is it possible to know when the nest is running stage 2 or not?

Re: Nest Thermostat plug-in

Posted: Wed Apr 30, 2014 12:24 pm
by abuttino
Dragon470 wrote:Small fix on get_object weather related

Added Duty-cycle in fan mode

added fan timer action (0 will turn off the fan if it was on a timer)



If anyone knows how to get the energy_latest from nest would be a huge benefit. The url seems to be transport_url /v1/subscribe?energy_latest.serial I have looked into it a few times but never seem to get anything working.

I also have looked into being able to do schedule setting to no avail.

Any other additions anyone wants, just list them here.
I will check the php library.

Re: Nest Thermostat plug-in

Posted: Wed Apr 30, 2014 12:38 pm
by Dragon470
I am a bit unclear on what is meant by stage. This is just because I have a simple HVAC system. Nest says they support multi stage systems. As long as it is being reported from nest, then the data should be there. In In the list of variables there are: hvac_heat_x2_state, hvac_heat_x3_state , hvac_cool_x2_state, etc So I would assume that is a yes on the reporting as well.

Re: Nest Thermostat plug-in

Posted: Wed Apr 30, 2014 12:46 pm
by abuttino
Here is the nest.class from the PHP library

Code: Select all

    public function getEnergyLatest($serial_number=null) {
        $serial_number = $this->getDefaultSerial($serial_number);

        $payload = array(
            'objects' => array(
                array('object_key' => "energy_latest.$serial_number")
            )
        );

        $url = '/v5/subscribe';
    
        return $this->doPOST($url, json_encode($payload));
I notice he uses v5 instead of v1 like you posted.. You may want to try that first..

Re: Nest Thermostat plug-in

Posted: Wed Apr 30, 2014 5:45 pm
by abuttino
Here you go...

Code: Select all

auth = str('Basic ' + access_token)
getreq = str('/v5/subscribe')
dat = str('{"objects":[{"object_key":"energy_latest.' +DevSerial +'"}]}')
content = str(len(dat))
print dat


auth = str('Basic ' + access_token)
uid = str(userid)
transport = transport_url

ctx = SSL.Context('tlsv1')
h = httpslib.HTTPSConnection(transport, 443, ssl_context=ctx)
h.set_debuglevel(1)
h.putrequest('POST', getreq)
h.putheader('user-agent', 'Nest/2.1.3 CFNetwork/548.0.4')
h.putheader('Authorization', auth)
h.putheader('X-nl-user-id', uid)
h.putheader('X-nl-protocol-version', '1')
h.putheader('Content-Length', content)
h.putheader('Accept-Language', 'en-us')
h.putheader('Connection', 'keep-alive')
h.putheader('Accept', '*/*')
h.endheaders()
h.send(dat)
resp = h.getresponse()
resps = resp.read()
print resps
In trade... Can I get your logging graph script? I would love to track some of this stuff

EDIT: Nevermind. I built my own...

Image

It would be nice if every hour there was a full update on the log.. I'll see if I can do it, but if I can't I'll re-edit this post.

I post way too much in this thread and will edit my posts more often.

EDIT:
Added a "Seconds to force log update" to the configuration, and password cloaking.

Re: Nest Thermostat plug-in

Posted: Mon May 05, 2014 4:15 am
by funat120mph
Dragon470 wrote:I am a bit unclear on what is meant by stage. This is just because I have a simple HVAC system. Nest says they support multi stage systems. As long as it is being reported from nest, then the data should be there. In In the list of variables there are: hvac_heat_x2_state, hvac_heat_x3_state , hvac_cool_x2_state, etc So I would assume that is a yes on the reporting as well.
Sorry for my absence here, been busy at home.

I have a two stage air conditioner, it looks like hvac_cool_x2_state would be the correct variable.

Abuttino, is it possible to add run stage to the ISY plugin? How did you graph all that data?

Re: Nest Thermostat plug-in

Posted: Mon May 05, 2014 5:16 am
by abuttino
I have been waiting for your reply to my email. Can't do much about writing scripts for the ISY and Nest plugins without the information I need.

If you need me to resend the email, let me know.

The charts were written with python scripting and a library called "ChartDirector" It offers some powerful charting information and I had to learn the language to do it.. It's pretty simple to port, I am just busy as all hell getting the ISY plugin rebuilt, then I have to update my Nest/ISY scripts for it.

Charting for your multiple thermostat setup would be challenging. One chart/script per thermostat, unless you want the data to look really messy.. The chart you see above is still a little messy, for me and, I'll probably do something with it when I figure out what would make it look better.

Tony

Re: Nest Thermostat plug-in

Posted: Wed May 07, 2014 2:08 am
by Dragon470
Added 10 day energy in to plugin. It will cache all days it ever gets for future retrieval. It will only get the energy history once per day / or at the startup of the plugin.

All items right now will output the raw data. So some of it will display a lot of JSON output as that is the format it is in. Making the nice day graphs that you can see from Nest will require significant more data manipulation of the objects "events" and "cycles".

At least now we can keep our energy history on our computer for more than 10 days.