add exception handling to the lights on/lights off action so script does not bail

This commit is contained in:
Emil Lerch 2019-07-20 17:36:38 -07:00
parent 4fd2ae599c
commit 9fa883f3e7
Signed by: lobo
GPG Key ID: CEC5F37C1BE5A481

View File

@ -235,11 +235,17 @@ class fauxmo(upnp_device):
if data.find('<BinaryState>1</BinaryState>') != -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('<BinaryState>0</BinaryState>') != -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)