From 9fa883f3e7404f8144ccd82a33eea108d38b5e41 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Sat, 20 Jul 2019 17:36:38 -0700 Subject: [PATCH] add exception handling to the lights on/lights off action so script does not bail --- fauxmo/fauxmo.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fauxmo/fauxmo.py b/fauxmo/fauxmo.py index 254b183..3051917 100755 --- a/fauxmo/fauxmo.py +++ b/fauxmo/fauxmo.py @@ -235,11 +235,17 @@ class fauxmo(upnp_device): if data.find('1') != -1: # on dbg("Responding to ON for %s" % self.name) - success = self.action_handler.on() + try: + success = self.action_handler.on() + except Exception as e: + dbg("WARNING: Failed to turn ON: %s" % str(e)) elif data.find('0') != -1: # off dbg("Responding to OFF for %s" % self.name) - success = self.action_handler.off() + try: + success = self.action_handler.off() + except Exception as e: + dbg("WARNING: Failed to turn OFF: %s" % str(e)) else: dbg("Unknown Binary State request:") dbg(data)