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..86edb1fd 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, None) + self.assertFalse(response)