From 3f0659e016e1bd42d1f86ff7fa62f6d58f2966e4 Mon Sep 17 00:00:00 2001 From: mkmer Date: Sat, 6 Jan 2024 17:46:27 +0000 Subject: [PATCH 1/2] Handle Emtpy put response --- blinkpy/api.py | 7 +++++-- tests/test_api.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/blinkpy/api.py b/blinkpy/api.py index a10c4497..82485dad 100644 --- a/blinkpy/api.py +++ b/blinkpy/api.py @@ -503,8 +503,11 @@ async def http_post(blink, url, is_retry=False, data=None, json=True, timeout=TI async def wait_for_command(blink, json_data: dict) -> bool: """Wait for command to complete.""" _LOGGER.debug("Command Wait %s", json_data) - network_id = json_data.get("network_id") - command_id = json_data.get("id") + try: + network_id = json_data.get("network_id") + command_id = json_data.get("id") + except AttributeError: + return False if command_id and network_id: for _ in range(0, MAX_RETRY): _LOGGER.debug("Making GET request waiting for command") diff --git a/tests/test_api.py b/tests/test_api.py index 1c6e02d7..f5159d68 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -183,3 +183,6 @@ async def test_wait_for_command(self, mock_resp): mock_resp.side_effect = (COMMAND_COMPLETE_BAD, {}) response = await api.wait_for_command(self.blink, COMMAND_RESPONSE) self.assertFalse(response) + + response = await api.wait_for_command(self.blink, {}) + self.assertFalse(response) From c78f42b201c23a1b1e2bcdfdb293d0e756ceb1ac Mon Sep 17 00:00:00 2001 From: mkmer Date: Sat, 6 Jan 2024 18:01:03 +0000 Subject: [PATCH 2/2] Fix test --- tests/test_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_api.py b/tests/test_api.py index f5159d68..86edb1fd 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -184,5 +184,5 @@ async def test_wait_for_command(self, mock_resp): response = await api.wait_for_command(self.blink, COMMAND_RESPONSE) self.assertFalse(response) - response = await api.wait_for_command(self.blink, {}) + response = await api.wait_for_command(self.blink, None) self.assertFalse(response)