diff --git a/hue_cmd.py b/hue_cmd.py index 73e8793..8a048b9 100755 --- a/hue_cmd.py +++ b/hue_cmd.py @@ -4,9 +4,9 @@ from modules.hue.hue_controller import controller from modules.hue.hue_remote import parseCommandline def init(): - hue.controller.init() # very important to initialize the controller + controller.init() # very important to initialize the controller parseCommandline() - hue.controller.end() # also to end it + controller.end() # also to end it if __name__ == "__main__": init() diff --git a/modules/hue/config.py b/modules/hue/config.py index 2328100..6e7119e 100644 --- a/modules/hue/config.py +++ b/modules/hue/config.py @@ -1,6 +1,4 @@ -# Speech CMD settings -prefix = "computer" - # Hue Remote Settings -address = "192.168.0.3" -username = "E0ru0AeVFKEH1E30X40JAJfovg4Uu1aTkdrKQ2Oi" +class hue_config: + address = "192.168.0.3" + username = "E0ru0AeVFKEH1E30X40JAJfovg4Uu1aTkdrKQ2Oi" diff --git a/modules/hue/hue_controller.py b/modules/hue/hue_controller.py index 2cbbd14..629fd1e 100644 --- a/modules/hue/hue_controller.py +++ b/modules/hue/hue_controller.py @@ -5,7 +5,7 @@ import time from .lib.func import * # useful functions -#import .config as config # Configuration for the controller (/config.py <- change this file) +from .config import * # Configuration for the controller (/config.py <- change this file) from .presets import * # presets for the lights LIGHTS = {} # dictionary of all the lights @@ -13,7 +13,7 @@ LIGHTS = {} # dictionary of all the lights loop = asyncio.get_event_loop() # ASync loop def genUrl(params: str): - return "http://" + config.address + "/api/" + config.username + params + return "http://" + hue_config.address + "/api/" + hue_config.username + params class APIrequest: # Get Req diff --git a/modules/hue/hue_remote.py b/modules/hue/hue_remote.py index b97cb97..46e890f 100755 --- a/modules/hue/hue_remote.py +++ b/modules/hue/hue_remote.py @@ -31,8 +31,7 @@ boolConvert = { # this is the most spaghetti-ish code I have ever written but it works -def parseCommand( cmd:list, pos:int, i=-1, displayHelp=True ): - index = int(i) +def parseCommand( cmd:list, pos:int, index=-1, displayHelp=True ): try: if( cmd[pos] == "on" or cmd[pos] == "off" ): if( index == -1 ): @@ -94,6 +93,7 @@ def parseCommandline( cmd=sys.argv, needHelp=True ): parseCommand( cmd, 3, cmd[2], displayHelp=needHelp ) elif( cmd[1] == "lights" ): + print("gothere1") parseCommand( cmd, 2, displayHelp=needHelp ) - else: + elif( needHelp ): help() diff --git a/speech_daemon.py b/speech_daemon.py index 896744b..f2f7a01 100755 --- a/speech_daemon.py +++ b/speech_daemon.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from modules.hue.hue_remote import parseCommandline +from modules.hue.hue_controller import controller from modules.speech.speech import voiceInput prefixes = ["computer", "computers"] @@ -13,14 +14,16 @@ class speech_daemon(object): self.voiceInpObj.setMuted(False) def start(self): - return self.voiceInpObj.start() + controller.init() + + for inp in self.voiceInpObj.start(): + cmdBuf = inp.lower().split(" ") + if( cmdBuf[0] in prefixes ): + print("CMD:", cmdBuf) + parseCommandline( cmdBuf, False ) + + controller.end() if __name__ == "__main__": daemon = speech_daemon() - - cmdBuf = None - for inp in daemon.start(): - cmdBuf = inp.lower().split(" ") - if( cmdBuf[0] in prefixes ): - print("CMD:", cmdBuf) - parseCommandline( cmdBuf[1:], False ) + daemon.start()