From 2566ed8ddbab0525eea1e94083cdb71160523df5 Mon Sep 17 00:00:00 2001 From: Rich O Date: Wed, 27 Nov 2019 15:42:18 -0500 Subject: [PATCH] removed from wront place for testing --- r0b3bot.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index ae4177b..9d25ba2 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -265,13 +265,13 @@ async def printstat(ctx): # REST API call to home assistant to turn the light off. #remote.call_service(hassapi, 'switch', 'turn_on', {'entity_id':'{}'.format(HASS_LIGHT)}) hassAPIURL = HASS_IP_ADDRESS + "/api/services/switch/turn_on" - payload = f'service_data={{"entity_id": "{HASS_LIGHT}"}}' + payload = f'{{"entity_id": "{HASS_LIGHT}"}}' print(f" - Payload String: {payload}") response = requests.post(hassAPIURL, headers=hassHEADERS, data=payload) print(f" - POST Response: {response.text}") + except Exception as e: - # Do nothing if this fails - print(f" ! Unable to turn on light; DUMP: {e}") + print(f" ! Unable to turn on light; ERROR: {e}") await ctx.send("Sorry, I was unable to turn on the light.") pass @@ -294,9 +294,10 @@ async def printstat(ctx): hassAPIURL = HASS_IP_ADDRESS + "/api/services/switch/turn_off" payload = f'{{"entity_id": "{HASS_LIGHT}"}}' response = requests.post(hassAPIURL, headers=hassHEADERS, data=payload) - - except: - # Do nothing is this fails + print(f" - POST Response: {response.text}") + + except Exception as e: + print(f" ! Unable to turn on light; ERROR: {e}") print(" ! Unable to turn off light") pass -- 2.39.5