Fix state report (#26406)

* Fix state report

* Update test
This commit is contained in:
Paulus Schoutsen 2019-09-03 18:57:32 -07:00 committed by Andrew Sayre
parent 53720c5c48
commit 4e2fcdb9a3
2 changed files with 7 additions and 4 deletions

View file

@ -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