Fix state report (#26406)

* Fix state report

* Update test
This commit is contained in:
Paulus Schoutsen authored and Andrew Sayre committed 2019-09-03 20:57:32 -05:00
1 parent 53720c5c48
commit 4e2fcdb9a3
2 files changed
+7 -4

No files matched your search

@@ -97,12 +97,15 @@ async def async_send_changereport_message(
_LOGGER.debug("Sent: %s", json.dumps(message_serialized))
_LOGGER.debug("Received (%s): %s", response.status, response_text)
if response.status == 202 and not invalidate_access_token:
if response.status == 202:
return
response_json = json.loads(response_text)
if response_json["payload"]["code"] == "INVALID_ACCESS_TOKEN_EXCEPTION":
if (
response_json["payload"]["code"] == "INVALID_ACCESS_TOKEN_EXCEPTION"
and not invalidate_access_token
):
config.async_invalidate_access_token()
return await async_send_changereport_message(
hass, config, alexa_entity, invalidate_access_token=False