Finished speech daemon

fetchIP
E. Almqvist 4 years ago
parent eaa72ef06b
commit 2cdef57b4f
  1. 4
      hue_cmd.py
  2. 4
      modules/hue/config.py
  3. 4
      modules/hue/hue_controller.py
  4. 6
      modules/hue/hue_remote.py
  5. 17
      speech_daemon.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()

@ -1,6 +1,4 @@
# Speech CMD settings
prefix = "computer"
# Hue Remote Settings
class hue_config:
address = "192.168.0.3"
username = "E0ru0AeVFKEH1E30X40JAJfovg4Uu1aTkdrKQ2Oi"

@ -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

@ -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()

@ -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()
if __name__ == "__main__":
daemon = speech_daemon()
cmdBuf = None
for inp in daemon.start():
for inp in self.voiceInpObj.start():
cmdBuf = inp.lower().split(" ")
if( cmdBuf[0] in prefixes ):
print("CMD:", cmdBuf)
parseCommandline( cmdBuf[1:], False )
parseCommandline( cmdBuf, False )
controller.end()
if __name__ == "__main__":
daemon = speech_daemon()
daemon.start()

Loading…
Cancel
Save