hopefully fixing this for the last time #36

Merged
Rich merged 1 commits from 2-homeassistant-api-connection-is-broken into master 2019-11-27 20:05:14 +00:00
+2 -2
View File
@@ -264,7 +264,7 @@ 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)})
hassAPIRUL = HASS_IP_ADDRESS + "/api/services/switch/turn_on"
payload = { "entity_id": HASS_LIGHT }
payload = f'service_data = {{ "entity_id": {HASS_LIGHT} }}'
print(f" - Payload String: {payload}")
requests.post(hassAPIURL, data=payload, headers=hassHEADERS)
except:
@@ -290,7 +290,7 @@ 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)})
hassAPIRUL = HASS_IP_ADDRESS + "/api/services/switch/turn_off"
payload = { "entity_id": '"' + HASS_LIGHT +'"' }
payload = f'service_data = {{ "entity_id": {HASS_LIGHT} }}'
requests.post(hassAPIURL, data=payload, headers=hassHEADERS)
except:
# Do nothing is this fails