From d8edd1b06786dd774dd9a57ad42c9c1ae6e3e7a2 Mon Sep 17 00:00:00 2001 From: Rich O Date: Fri, 22 Nov 2019 09:34:24 -0500 Subject: [PATCH] added try/except to check for state attribute --- r0b3bot.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index d364026..153ddf3 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -222,14 +222,20 @@ async def printstat(ctx): # We weren't able to get the status. Display this text to the chat channel print(" ! Unable to get light status, notifying chat channel") await ctx.send("Hmm, I can't tell if the light is on... oh well") + + try: + work_lights.state() + except: + print(" ! Unable to get light status, notifying chat channel") + await ctx.send("Hmm, I can't tell if the light is on... oh well") class State: state = "unknown" work_lights = State() work_lights.state = "Unknown" # If the light is off, let's turn it on before we take a picture - print(" - Lights are off, turning on for image capture") if work_lights.state == 'off': + print(" - Lights are off, turning on for image capture") turned_on_light = True try: # REST API call to home assistant to turn the light off. -- 2.39.5