Eliminated defunct code and added comments #15

Merged
Rich merged 1 commits from 3-r0b3bot-does-not-handle-homeassistant-api-failure-gracefully into master 2019-11-22 14:41:29 +00:00
+7 -8
View File
@@ -216,18 +216,17 @@ async def printstat(ctx):
# Try to get the status of the 3D printer light
print(" - Getting Printer Light Status")
try:
work_lights = remote.get_state(hassapi, 'switch.work_lights')
except:
# 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")
work_lights = remote.get_state(hassapi, 'switch.work_lights')
# Making sure that the API request succeeded. If it has, there will be a state attribute added to
# work_lights.
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")
print(" ! Unable to get light status from Homeassistant, notifying chat channel")
await ctx.send("Hmm, I can't tell if the light is on... oh well [Hass API error]")
# Create State class and add state attribute to work_lights
class State:
state = "unknown"
work_lights = State()