From ade7388e44ef1c3eced4b3f8bc86e3c01a4fe7f1 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 12 Apr 2016 08:40:43 -0400 Subject: [PATCH] Changed some comments, added datestamp to off.lights file, added ValueError exception catch --- hue_off.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hue_off.py b/hue_off.py index bc7eb89..60c5d9b 100755 --- a/hue_off.py +++ b/hue_off.py @@ -55,6 +55,10 @@ def main(argv): except getopt.GetoptError: optUsage() sys.exit(2) + except ValueError: + print "Incorrect option usage!" + opUsage() + sys.exit(2) for opt, arg in opts: if opt == '-h': optUsage() @@ -79,7 +83,7 @@ def main(argv): print "Error, App not registered. Press Bridge button and try again." if createnew: - print "You've requested to create a new user. Creating..." + print "You've requested to connect to a new Bridge. Connecting..." print "Press the button on your Bridge, then press Enter." bridge.connect() @@ -94,6 +98,8 @@ def main(argv): lights_list = bridge.get_light_objects('list') lights_file = open("off.lights", 'w') lights_file.truncate() + lights_file.write(datestamp()) + lights_file.write("\n") # Store list of lights that are currently off off_lights = [] for light in lights_list: @@ -145,7 +151,7 @@ def checkPowerOutage(): def waitSetlights(off_lights,check_interval): # Periodically check for return to Utility power, and then turn off lights that were off prior to event. while True: - # Loop in here until + # Loop in here until mains power returns outage = checkPowerOutage() if not outage: # Turn off the lights that were off prior to the power outage