Merge branch '3-r0b3bot-does-not-handle-homeassistant-api-failure-gracefully' into 'master'

Eliminated defunct code and added comments

Closes #3

See merge request Bots/r0b3BOT!5
This commit was merged in pull request #15.
This commit is contained in:
rich committed 2019-11-22 09:41:26 -05:00
commit f22591aee0
1 file changed
+7 -8
+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()