From 57f6fa55ea27b1f27c96ea0f5668f6779d92dd90 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Mon, 17 Aug 2020 14:07:47 +0200 Subject: [PATCH] Minor fix --- hue_controller.py | 11 +++++++---- hue_remote.py | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hue_controller.py b/hue_controller.py index 7f9dbfc..b7777b5 100644 --- a/hue_controller.py +++ b/hue_controller.py @@ -126,11 +126,14 @@ class controller: print("Error: Light index '" + str(index) + "' out of range") def setPreset( presetID:str, index:int=-1 ): - if( index == -1 ): - for key in LIGHTS: - controller.setLightPreset( key, presetID ) + if( PRESETS.get(presetID) ): + if( index == -1 ): + for key in LIGHTS: + controller.setLightPreset( key, presetID ) + else: + controller.setLightPreset( index, presetID ) else: - controller.setLightPreset( index, presetID ) + print("Error: Unknown preset '" + presetID + "'") def countLights(): return len(LIGHTS) diff --git a/hue_remote.py b/hue_remote.py index 231bb76..65005ff 100755 --- a/hue_remote.py +++ b/hue_remote.py @@ -81,8 +81,9 @@ def parseCommand( cmd:list, pos:int, i=-1 ): return help() # display help if function did nothing - except (RuntimeError, TypeError, NameError, IndexError): + except (RuntimeError, TypeError, NameError, IndexError) as err: help() # display the help page if parameters are missing (it will give out an IndexError) + print( "\n\nError: " + str(err) ) def parseCommandline():