Nest Thermostat plug-in

Questions and comments specific to a particular plugin should go here.
abuttino
Experienced User
Posts: 144
Joined: Sun Jun 02, 2013 4:01 am

Re: Nest Thermostat plug-in

Post by abuttino » Wed Jun 26, 2013 6:05 am

Code: Select all

import time
import datetime
now = int(round(time.time() * 1000))
print now
projected = 1372233360000 # test string
#projected = str(eg.plugins.Nest.get_object(151) * 1000)
if projected == "0":
    print "no data"
else:
 ttt = projected - now
 print ttt
tims = datetime.datetime.fromtimestamp(float(ttt)/1000.)
real = "%Y-%m-%d %H:%M:%S"
realtime = t.strftime(real)
timettp = u'timett=:='+realtime
eg.plugins.AutoRemote.SendMessage(u'Razr-MAXX', u'', u'*****',timettp, u'', u'', u'', u'')
Almost there! I told you I was a quick learner :)

abuttino
Experienced User
Posts: 144
Joined: Sun Jun 02, 2013 4:01 am

Re: Nest Thermostat plug-in

Post by abuttino » Sun Jun 30, 2013 7:46 am

I finally got it. It took me a while because my thermostat was still learning. but this is the script to give you human time to target.

Code: Select all

def humanize_time(secs):
    mins, secs = divmod(secs, 60)
    hours, mins = divmod(mins, 60)
    return '%02d:%02d:%02d' % (hours, mins, secs)

nowm = str(eg.plugins.Nest.get_object(0))
now = int(nowm)
now = now/1000
print now
projected = str(eg.plugins.Nest.get_object(151))
if projected == "0":
    print "no data"
else:
 ttt = projected-now
 print ttt
 print humanize_time(ttt)
Hopefully someone else can use it..

Dragon470
Experienced User
Posts: 202
Joined: Thu Feb 10, 2011 2:16 am

Re: Nest Thermostat plug-in

Post by Dragon470 » Sun Aug 04, 2013 1:35 am

I have some time now to continue working on the Nest plugin. I am part way in to adding logging. I am wondering what format would work best so the information could eventually be used to make graphs/charts. I currently have the output dumped to a text file on the load of eg. After that only the changes are logged (to help conserve space). I have it in the format: 2013-08-03 16:41:26 current_temperature *** 27.8

Is there anything that can take this data and make a graph? If not, what needs to be added or specifically formatted to be used in to a graph making software?

I would also like to add weather information as well, but don't know what service is reliable and works with eg.

I added a test log so you see the format with everything.
Attachments
NestLog.txt
(11.02 KiB) Downloaded 172 times

krambriw
Plugin Developer
Posts: 2569
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Nest Thermostat plug-in

Post by krambriw » Sun Aug 04, 2013 6:15 am

Hi, it depends a bit on your personal need and taste but I have tested some and finally, I am very happy using another software named SwitchKing (SK).

SK has a nice feature supporting data sources that can be set from external, in my case from EventGhost (EG). In the example below you see a graph showing my outdoor temperature for the last two days (the sensor is actually a OneWire sensor and is positioned in south/east, therefore the big variations).

What you need?
- download and install TelldusCenter from here (you do not need the actual TellStick device but SK has a dependency to the software)
http://www.telldus.se/download/latest/win

- download and install SK server and client from here:
http://www.switchking.se/en

- add the SK plugin to EG found here:
viewtopic.php?f=9&t=4054
The author has made a typo so you have to fix this yourself, in line 264, change from to:

Code: Select all

        self.cnnect(URL,"RESTDataSource")

Code: Select all

        self.connect(URL,"RESTDataSource")
- define data sources in SK to be used for your thermostats (one per thermostat)
- configure one or several macros with a python script(s) in your EG configuration that retrieves the temperature(s) from your Nest plugin and sets the data source(s) in SK
- as soon as the macro runs and fetches the data from the plugin, you should see this being updated in the graph in SK

What are the limitations?
- as I see it, it is not possible to combine multiple data sources into one single graph

In addition, SK can do so much more, it is worth checking this out. No license is needed for using only data sources

Best regards, Walter

Sample python script:

Code: Select all

try:
    currenttemp = str(eg.plugins.Nest.get_object(38))
except:
    print 'Failed to get the temperature value'
try:
    eg.plugins.SwitchkingTellStick.DSSet(u'', u'Name_ofYour_data_source', currenttemp, 0)
except:
    print 'Failed to send the data to SK'
Image2.gif
My latest plugins
http://plugins.krambriw.net/index.html

Two men in front of a huge excavator...
- that beast steels work from 100 men with shovels
- well, a 1000 men could do the same using teaspoons

Dragon470
Experienced User
Posts: 202
Joined: Thu Feb 10, 2011 2:16 am

Re: Nest Thermostat plug-in

Post by Dragon470 » Thu Aug 08, 2013 12:05 am

I have added logging to the nest plugin. This outputs to a text file of your choosing in the main config window. You will get an error on loading eg the first time after updating the plugin if it is already installed. In this case just reopen the plugin config window and redo the setting. This will affect everyone not just people who want to do loging.

As far as my graph making, I might be making a new plugin based on Chart Director. I can use it to make graphs with many data points and lines. Right now I use suntracker weather to get my outside information.

An example of what can be done:
Attachments
multiline.png

abuttino
Experienced User
Posts: 144
Joined: Sun Jun 02, 2013 4:01 am

Re: Nest Thermostat plug-in

Post by abuttino » Mon Aug 26, 2013 11:34 pm

Hey guys, I just thought I would show you this..

Thanks to Dragon and Walter, and a lot of programming. I was able make a nice widget for my phone.

http://wordpress.tinozplace.com/?p=282

Enjoy!

Dragon470
Experienced User
Posts: 202
Joined: Thu Feb 10, 2011 2:16 am

Re: Nest Thermostat plug-in

Post by Dragon470 » Fri Sep 06, 2013 9:45 pm

Some additions to the plugin:
set heat/cool/range/off
set away temps
set high low range temps

The set away temps might not be correct yet, but seems to be right on my thermostat.

I would like to find someone who has a humidistat system as well as someone who has an alternate heat system to do the testing of these potential actions.

abuttino
Experienced User
Posts: 144
Joined: Sun Jun 02, 2013 4:01 am

Re: Nest Thermostat plug-in

Post by abuttino » Mon Sep 09, 2013 9:58 pm

Error starting plugin: Nest Thermostat
Traceback (most recent call last) (1610):
File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInstanceInfo.py", line 177, in Start
self.instance.__start__(*self.args)
TypeError: __start__() takes exactly 6 arguments (5 given)

Any idea what's up with this?

abuttino
Experienced User
Posts: 144
Joined: Sun Jun 02, 2013 4:01 am

Re: Nest Thermostat plug-in

Post by abuttino » Mon Sep 09, 2013 10:06 pm

Nevermind, figured it out..

The username was put into the log path and the password was put into the username after the upgrade..

Thank you for putting this in!

abuttino
Experienced User
Posts: 144
Joined: Sun Jun 02, 2013 4:01 am

Re: Nest Thermostat plug-in

Post by abuttino » Wed Sep 11, 2013 2:42 pm

Have you been able to find what object has "AWAY" set in it?

I figured that the Schedule_mode object would have that, but it doesn't.

I put the nest in away and it doesn't seem to give much information about the fact it's in away mode

Dragon470
Experienced User
Posts: 202
Joined: Thu Feb 10, 2011 2:16 am

Re: Nest Thermostat plug-in

Post by Dragon470 » Thu Sep 12, 2013 12:47 am

I never looked for the away status before. Just never used it. I will have added information from the structure of the device as well now. This added 30+ new objects. It did add "away" which is True or False. The additions are not listed alphabetically for now. This may change, but I know many of you have large/complicated configurations in eg. I know I do.


On another note if you have more than one Nest on an account it will not work well at all. I would have to do a major rework in-order to accommodate a scenario.

abuttino
Experienced User
Posts: 144
Joined: Sun Jun 02, 2013 4:01 am

Re: Nest Thermostat plug-in

Post by abuttino » Thu Sep 12, 2013 1:13 pm

Wow, thank you.

abuttino
Experienced User
Posts: 144
Joined: Sun Jun 02, 2013 4:01 am

Re: Nest Thermostat plug-in

Post by abuttino » Thu Sep 12, 2013 4:50 pm

I have had to change my script for Time to Temperature a couple times for these new updates but this time, the timestamp isn't even being reported so I can't even get it from a payload.

If you wouldn't mind, please put a timestamp object in seconds or DateTime (not just DateTime).

You can see the script I used on the second or beginning of the third page of this thread if you'd like to put it in the plug-in to get the real/human Time to Target so there would be no use for these scripts.

Thank you!

Oh, gt this error when I start eventghost. Might it be from your plugin? (It loads fine)
Error compiling script.
Traceback (most recent call last) (1630):
File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionItem.py", line 121, in SetArguments
self.compiled = self.executable.Compile(*args)
File "C:\Program Files (x86)\EventGhost\plugins\EventGhost\PythonScript.py", line 71, in __init__
self.PrintTraceback()
File "C:\Program Files (x86)\EventGhost\plugins\EventGhost\PythonScript.py", line 97, in PrintTraceback
treeItem.PrintError("Traceback (most recent call last):")
AttributeError: 'NoneType' object has no attribute 'PrintError'

Dragon470
Experienced User
Posts: 202
Joined: Thu Feb 10, 2011 2:16 am

Re: Nest Thermostat plug-in

Post by Dragon470 » Thu Sep 12, 2013 6:39 pm

My timestamp is still being received. The reason why I have the output from timestamp output in this format is so that it is easier to read in the log window. You might want to check out the python datetime library http://docs.python.org/2/library/datetime.html.

My Nest is in the off position most of its life so mine still is not out of the learning state, so I have not done anything with time to temp. I will look be changing the time_to_target output from the get_object.

As far as the scripts you have made, you can use the Values_variable like this:

Code: Select all

from datetime import datetime

now = datetime.fromtimestamp(int(eg.plugins.Nest.plugin.Values_timestamp)/1000)
projected = datetime.fromtimestamp(int(eg.plugins.Nest.plugin.Values_time_to_target)/1000)
if int(eg.plugins.Nest.plugin.Values_time_to_target) == 0:
    print "no data"
else:
 ttt = now-projected
 print ttt

Dragon470
Experienced User
Posts: 202
Joined: Thu Feb 10, 2011 2:16 am

Re: Nest Thermostat plug-in

Post by Dragon470 » Thu Sep 12, 2013 7:24 pm

Check if the new output works on the time_to_target. If not I need to know what the outputs are, current Values_timestamp and Values_time_to_target are. This is for version 2013-09-12

Post Reply