mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
parent
8cf02e0b22
commit
7bccbcbcc3
@ -97,12 +97,15 @@ async def async_send_changereport_message(
|
|||||||
_LOGGER.debug("Sent: %s", json.dumps(message_serialized))
|
_LOGGER.debug("Sent: %s", json.dumps(message_serialized))
|
||||||
_LOGGER.debug("Received (%s): %s", response.status, response_text)
|
_LOGGER.debug("Received (%s): %s", response.status, response_text)
|
||||||
|
|
||||||
if response.status == 202 and not invalidate_access_token:
|
if response.status == 202:
|
||||||
return
|
return
|
||||||
|
|
||||||
response_json = json.loads(response_text)
|
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()
|
config.async_invalidate_access_token()
|
||||||
return await async_send_changereport_message(
|
return await async_send_changereport_message(
|
||||||
hass, config, alexa_entity, invalidate_access_token=False
|
hass, config, alexa_entity, invalidate_access_token=False
|
||||||
|
@ -5,7 +5,7 @@ from . import TEST_URL, DEFAULT_CONFIG
|
|||||||
|
|
||||||
async def test_report_state(hass, aioclient_mock):
|
async def test_report_state(hass, aioclient_mock):
|
||||||
"""Test proactive state reports."""
|
"""Test proactive state reports."""
|
||||||
aioclient_mock.post(TEST_URL, json={"data": "is irrelevant"}, status=202)
|
aioclient_mock.post(TEST_URL, text="", status=202)
|
||||||
|
|
||||||
hass.states.async_set(
|
hass.states.async_set(
|
||||||
"binary_sensor.test_contact",
|
"binary_sensor.test_contact",
|
||||||
@ -39,7 +39,7 @@ async def test_report_state(hass, aioclient_mock):
|
|||||||
|
|
||||||
async def test_send_add_or_update_message(hass, aioclient_mock):
|
async def test_send_add_or_update_message(hass, aioclient_mock):
|
||||||
"""Test sending an AddOrUpdateReport message."""
|
"""Test sending an AddOrUpdateReport message."""
|
||||||
aioclient_mock.post(TEST_URL, json={"data": "is irrelevant"})
|
aioclient_mock.post(TEST_URL, text="")
|
||||||
|
|
||||||
hass.states.async_set(
|
hass.states.async_set(
|
||||||
"binary_sensor.test_contact",
|
"binary_sensor.test_contact",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user