Page 1 of 13

Nest Thermostat plug-in

Posted: Sun Apr 14, 2013 4:56 pm
by Dragon470
Here is a plugin for the Nest thermostat.

Help always accepted:
* Humidistat functions are implemented but not tested as I don't have anyone to test for me.
* Secondary or Alternate heat sources are not implemented as I don't have anyone to test for me.
* If anyone has a multi nest configuration I would like to test this setup (Is now supported, but would like confirmation that everything is fully functional.).


Updates:
Look at __init.py for change log.

Last updated 11-27-2016


Install instructions:

1. Place

[attachment=0]__init__.py[/attachment]

file in the normal plugin directory with its own subdirectory.

2. place all contents of (unzip):

[attachment=1]M2Crypto.7z[/attachment]

folder in the main eventghost folder.

Re: Nest Thermostat plug-in

Posted: Thu May 30, 2013 6:29 pm
by smwein
Is there a way to pass a variable to the set temp command?

thanks
Steven

Re: Nest Thermostat plug-in

Posted: Sat Jun 01, 2013 2:39 am
by Dragon470
I added variable input in the set temperature. I should add for the other set commands.


In a script it could have been called by:
eg.plugins.Nest.set_temp(var)

Re: Nest Thermostat plug-in

Posted: Wed Jun 12, 2013 2:41 am
by abuttino
Is this plug-in compatible with the 1st gen nest as well?

I only have two things i want to do because i work from home. turn the temperature up when I leave and turn it back down when i get home (Live in Florida, no need for heat)

If you can recommend a cheaper thermostat that has eventghost plug-ins, I'm game.

Re: Nest Thermostat plug-in

Posted: Thu Jun 13, 2013 3:19 am
by abuttino
The plugin will not load. First, it says "unknown" in the plugins list, then when i load it, it gives an error and hangs eg.

Is that all for the plugin? 1 file? I put it in a subfolder in the plugins directory and it was a no-go.

Re: Nest Thermostat plug-in

Posted: Thu Jun 13, 2013 5:28 am
by krambriw
Next time you find a problem, please also paste the actual error message into your post.

I looked at this and there is a small correction needed in the plugin code (use a normal text editor). Starting from line 36 it should look like this:

Code: Select all

#	version 2013.0415.1852
#		changed the current temp on event to reflect temperature scale.
#	* 2013-05-31 and 2013-06-01 changed so that set temp can be a variable
There was one line that was not commented out correctly. After correction, the plugin loads ok (I do not have the thermostat though..)

Best, Walter

Re: Nest Thermostat plug-in

Posted: Thu Jun 13, 2013 11:33 am
by abuttino
I can't post the log if eg hangs..

In Notepad++ the line was found a little bit further down than what you stated. But, the plugin works fine now.. I am going to order my nest soon, especially now that I know what the plug-in looks like. :)

Dragon, I'll help you test this in any ways, if you would like to develop it further.

Re: Nest Thermostat plug-in

Posted: Tue Jun 18, 2013 11:50 am
by abuttino
Can someone tell me how to script this with another plugin?

I'd like to get the temp by saying it on my cell phone "Get the temperature of the house" (Tasker/AutoVoice)
Then AutoRemote will send a message to eventghost to get the temp.
So, what I am looking at is Get_Temp and sending those parameters in an outgoing AutoRemote Message

eg.plugins.AutoRemote.SendMessage(u'Razr-MAXX', u'http://goo.gl/mygoo.glurlhere', u'myapikeyhere''', u'currenttemp', u'', u'', u'', u'')

and to accept a set temp from the phone:

I say "Set the temperature to 80degs" I can have AutoRemote send the temperature variable to eventghost, but need to know how to use that.

The event from AutoRemote is pretty standard Auto.RemoteMessage.SetTemp or whatever I specify e.g. "AutoRemote.Message.SetAway"

I have already done so much With Eventghost, can't wait to do the video to show you all how well it works :)

Re: Nest Thermostat plug-in

Posted: Tue Jun 18, 2013 6:08 pm
by krambriw
I do not know exactly how you would pick your temperature and how to set it but the basic steps would be

1) Create a macro that includes a python script that
a) picks up your current house temperature from a variable that is part of the plugin (the variable has to be defined with the leading word 'self.', then you can easily get it from outside of the plugin
b) sends the value using the way you described
c) add the event to the macro (the event that is generated in EG when you say "Get the temperature of the house" to your phone)

2) Create a second macro that includes
a) the event that is happening when you say "Set the temperature to 80degs"
b) a python script that is able to parse the temperature value from the event and then is able to set the temperature

Best, Walter

Re: Nest Thermostat plug-in

Posted: Tue Jun 18, 2013 7:01 pm
by abuttino
Can you show me an example of that?
I am a quick learner, I'll get it after you show me.a basic command structure.

mind you, I've never done any python scripting in my life, so this will definitely help.

What I really need the most help with is getting the value from an plugin event.. Setting that to a variable and calling the variable in another plugin.

If you could show me that, I think I'd be good to go.

Re: Nest Thermostat plug-in

Posted: Tue Jun 18, 2013 11:46 pm
by abuttino
This is just an example, I used set-temp-%word5 on my phone to transmit 85 degrees as the 5th word in "Set the temperature to 85 degrees" in that message.

AutoRemote.Message.set-temp-85 params: [u'set-temp-85']; command(s): ;

How would I take that (payload?) and put it into a "DesiredTemp" Variable? Then use that variable to set the temp should be easy from what I read this plugin has the ability to set a temp from a variable, but, how do I address it? %desiredtemp ?

The other way around, I would need to get the temp and send it, but that is where I am really stumped. How to take the output of this plug-in to a variable and use that variable to send a message like "got-temp-was-"

Re: Nest Thermostat plug-in

Posted: Wed Jun 19, 2013 6:06 am
by krambriw
Here some samples to start (maybe they do not work perfectly right away...)

This script should capture your current temperature and send it to your phone:

Code: Select all

currenttemp = str(eg.plugins.Nest.get_object(38))
eg.plugins.AutoRemote.SendMessage(u'Razr-MAXX', u'http://goo.gl/mygoo.glurlhere', u'myapikeyhere''', u'currenttemp', u'', u'', u'', u'')
This script should capture your incoming voice command and set the temperature accordingly:

Code: Select all

    
def eventHandler(base, pload):

    if str(base).find('Message.set-temp-')>-1:
        desired_temp = str(pload.split('-')[2])
        #print desired_temp
        try:
            eg.plugins.Nest.set_temp(desired_temp)            
        except:
            eg.PrintError('Failed setting the Nest temperature')
            pass

eg.event.prefix_copy = eg.event.prefix
eg.event.suffix_copy = eg.event.suffix
eg.event.payload_copy = eg.event.payload

if eg.event.prefix_copy.find('AutoRemote')>-1:
    eventHandler(eg.event.suffix_copy, eg.event.payload_copy)

#Sample event
#AutoRemote.Message.set-temp-85 params: [u'set-temp-85']; command(s): ;

When you put the last script in a macro you also need to put the event from your phone there to trigger it. Unfortunately you have to do it for all temperatures you want to set or you just put in * as event (then all events will be evaluated). The problem is that the event suffix also contains '-85', it should have been only in the payload to keep the event suffix more generic.

Re: Nest Thermostat plug-in

Posted: Wed Jun 19, 2013 12:03 pm
by abuttino
I've been emailing the guy that made that Tasker plug-in (auto-message) to understand how this message is supposed to be comprised so that it will be in the payload.

Here is what the instructions for EG are for the plug-in:
"If you use AutoRemote's command system in a message sent to EventGhost, all your parameters (words to the left of =:=) will be available to use in other EventGhost actions. Use {eg.event.payload.arpar[0]}, {eg.event.payload.arpar[1]}, etc to access them. To access your command (phrase on the right of =:=) use {eg.event.payload.arcomm}. "

Basically, I think I am not using the proper system and it's not sending "commands", it's sending "parameters"

Re: Nest Thermostat plug-in

Posted: Wed Jun 19, 2013 12:18 pm
by abuttino
AutoRemote.Message.set-temp params: [u'set-temp']; command(s): 72;

That's better :))

Re: Nest Thermostat plug-in

Posted: Wed Jun 19, 2013 12:37 pm
by abuttino
Ok, this is what I came up with.

Code: Select all

def eventHandler(base, pload):
 desired_temp = str(eg.event.payload.arcomm)
 print desired_temp
try:
    eg.plugins.Nest.set_temp(desired_temp)
except:
      eg.PrintError('Failed setting the Nest temperature')
pass

eg.event.prefix_copy = eg.event.prefix
eg.event.suffix_copy = eg.event.suffix
eg.event.payload_copy = eg.event.payload

if eg.event.prefix_copy.find('AutoRemote')>-1:
  eventHandler(eg.event.suffix_copy, eg.event.payload_copy)

#Sample event
#AutoRemote.Message.set-temp-85 params: [u'set-temp-85']; command(s): ;

Thank you VERY much for the help with the code. :)

What's everything after pass? It looks like I wouldn't need it if the command is properly set.