Skip to content

Commit aeb2453

Browse files
Paul JenningsPaul Jennings
authored andcommitted
Added usage information.
1 parent 54a5559 commit aeb2453

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

TStatGcal.py

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,72 @@
2929

3030
VERSION = 1.0
3131

32+
# TStatGcal.py
33+
# Script to pull commands from Google Calendar and update thermostat.
34+
#
35+
# Requirements:
36+
# * gdata (http://code.google.com/p/gdata-python-client/)
37+
# * ElementTree (http://effbot.org/zone/element-index.htm)
38+
# * Python-TStat (same place you got this script)
39+
#
40+
# Usage:
41+
# 1. Create a Google/GMail account (or Google Apps for domains).
42+
# 2. Go to http://calendar.google.com
43+
# 3. Create a calendar (called "Thermostat" for example).
44+
# 4. Add events with titles of the form:
45+
# "Heat 70" -- sets heat to 70 degrees
46+
# "Cool 70" -- sets cool to 70 degrees
47+
# "Fan On" -- forces fan on
48+
# "Mode Off" -- forces system off
49+
# 5. Run the following commands (assuming Unix/Linux system):
50+
# echo "youraccount@gmail.com" >> ~/.google
51+
# echo "yourpassword" >> ~/.google
52+
# chmod 400 ~/.google
53+
# (where "youraccount@gmail.com" is the account that you created in
54+
# step 1 and "yourpassword" is your password)
55+
# 6. Add the following to your crontab to run every 5 minutes or so:
56+
# TStatGcal.py <thermostat_address> <calendar_name>
57+
# Where <thermostat_address> is the IP address of your thermostat
58+
# and <calendar_name> is the name of the calendar you created in
59+
# step 3.
60+
#
61+
# Notes:
62+
# In order to limit the chance that this script sets your
63+
# thermostat to dangerous settings (e.g. too low or off during
64+
# the winter, there are some override variables below:
65+
# HEAT_MIN, HEAT_MAX: Minimum/maximum setting for heat
66+
# COOL_MIN, COOL_MAX: Minimum/maximum setting for cool
67+
# COMMANDS: What parts of the thermostat the script is
68+
# allowed to control
69+
#
70+
# Set the HEAT/COOL variables to appropriate values for your
71+
# situation. By default, this script will not set the
72+
# thermostat mode (on/off/auto). You probably want to leave
73+
# it on auto. This is to prevent a hacker (or a typo) from
74+
# turning your furnace off during the winter.
75+
#
76+
# By default, this script does not disable cloud updates.
77+
# That way, if this script does not run for some reason (e.g.
78+
# if your computer crashes), you can still have a reasonable
79+
# backup program running. When the cloud updates your thermostat,
80+
# there may be a short period where the setting does not match
81+
# what is on your calendar. If this behavior is undesirable, you
82+
# can disable cloud updates.
83+
#
84+
# At the start time of your event, the script will set the
85+
# the thermostat to the requested setting. The duration of the
86+
# events on your calendar is ignored. For example, a simple
87+
# program might look like this:
88+
# 6:30 -- Heat 70
89+
# 8:00 -- Heat 60
90+
# 16:00 -- Heat 70
91+
# 22:00 -- Heat 60
92+
# In order to create this program in your calendar, you would need
93+
# four events. If you create a "Heat 70" event that lasts from
94+
# 6:30-22:00 and an overlapping "Heat 60" event that lasts from
95+
# 8:00-16:00, you will effectively miss the "Heat 70" command at
96+
# 16:00. Only the start time of the event is used.
97+
3298
# Minimum and maximum values for heat and cool
3399
# The script will never set values outside of this range
34100
HEAT_MIN = 55
@@ -40,7 +106,8 @@
40106
# Remove commands that you don't want the script to execute here
41107
# mode in particular can be dangerous, because someone could create
42108
# a 'mode off' command and turn your heat off in the winter.
43-
COMMANDS = ['Heat', 'Cool', 'Mode', 'Fan']
109+
#COMMANDS = ['Heat', 'Cool', 'Mode', 'Fan']
110+
COMMANDS = ['Heat', 'Cool', 'Fan']
44111

45112
try:
46113
from xml.etree import ElementTree # for Python 2.5 users
@@ -93,6 +160,7 @@ def main(tstatAddr, username=None, password=None, calName="Thermostat"):
93160
return
94161

95162
# Search for the event that has passed but is closest to the current time
163+
# There is probably a better way to do this...
96164
closest = None
97165
closestDT = None
98166
closestWhen = None

0 commit comments

Comments
 (0)