Remote progress, it works :D

fetchIP
E. Almqvist 4 years ago
parent c9880f792c
commit 4dcf07a15b
  1. 11
      hue_controller.py
  2. 31
      hue_remote.py

@ -126,13 +126,12 @@ class controller:
else:
print("Error: Light index '" + str(index) + "' out of range")
def setPreset( presetDict ):
if( type(presetDict) is dict ):
for index, preset in presetDict.items():
controller.setLightPreset( index, preset )
elif( type(presetDict) is str ):
def setPreset( presetID:str, index:int=-1 ):
if( index == -1 ):
for key in LIGHTS:
controller.setLightPreset( key, presetDict )
controller.setLightPreset( key, presetID )
else:
controller.setLightPreset( index, presetID )
# Controller "system" functions

@ -29,12 +29,13 @@ boolConvert = {
"off": False
}
def parseCommand( cmd:list, pos:int, index:int=-1 ):
def parseCommand( cmd:list, pos:int, i=-1 ):
index = int(i)
if( cmd[pos] == "on" or cmd[pos] == "off" ):
if( index == -1 ):
hue.controller.Power( boolConvert[cmd[pos]] )
else:
hue.controller.Power()
hue.controller.powerLight( index, boolConvert[cmd[pos]] )
elif( cmd[pos] == "switch" ):
if(index == -1):
@ -42,7 +43,33 @@ def parseCommand( cmd:list, pos:int, index:int=-1 ):
else:
hue.controller.switchLight(index)
elif( cmd[pos] == "set" ):
if( cmd[pos+1] == "preset" ):
hue.controller.setPreset( cmd[pos+2], index )
#elif( cmd[pos+1] == "color" ):
#elif( cmd[pos+1] == "preset" ):
def parseCommandline(): # this is the most spaghetti code I have ever written but it works and I do not intend to fix
cmd = sys.argv
print(cmd)
if( len(cmd) > 1 ):
if( cmd[1] == "light" ):
index = cmd[2]
parseCommand( cmd, 3, index )
elif( cmd[1] == "lights" ):
parseCommand( cmd, 2 )
else:
help()
def init():
hue.controller.init()
parseCommandline()
hue.controller.end()
init()

Loading…
Cancel
Save