Skip to content

Commit

Permalink
New remote class for direct access.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben174 committed Sep 23, 2014
1 parent 76f3377 commit e54e1ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
7 changes: 4 additions & 3 deletions command.py
Expand Up @@ -13,9 +13,10 @@ class Command:
def __init__(self, command_line=None):
global logger
logger = logging.getLogger(__name__)
self.command_line = command_line
self.clean_command()
self.parse_command()
if command_line:
self.command_line = command_line
self.clean_command()
self.parse_command()

def __repr__(self):
return "Room: %s, Action: %s, Value: %s" % (
Expand Down
13 changes: 8 additions & 5 deletions control.py
@@ -1,4 +1,3 @@
from nest import Nest
from phue import Bridge
import settings
import logging
Expand All @@ -14,11 +13,12 @@ def __init__(self):
global logger
logger = logging.getLogger(__name__)
# connect to nest
self.nest = Nest(
username=settings.NEST_LOGIN,
password=settings.NEST_PASS
)
try:
from nest import Nest
self.nest = Nest(
username=settings.NEST_LOGIN,
password=settings.NEST_PASS
)
self.nest.login()
self.nest.get_status()
except:
Expand Down Expand Up @@ -69,6 +69,9 @@ def execute_command(self, command):
self.bridge.set_light(light_index, 'sat', 255)
return True
elif command.action == 'temperature':
if not self.nest:
logger.error('Nest thermostat not initialized.')
return False
if command.value:
self.nest.set_temperature(command.value)
return True
Expand Down
13 changes: 13 additions & 0 deletions remote.py
@@ -0,0 +1,13 @@
from control import Control
from command import Command

def main():
command = Command()
command.room='office'
command.action='power'
command.value='on'
control = Control()
control.execute_command(command)

if __name__ == '__main__':
main()

0 comments on commit e54e1ba

Please sign in to comment.