diff --git a/blinkpy/api.py b/blinkpy/api.py index 60a177ad..942d29d8 100644 --- a/blinkpy/api.py +++ b/blinkpy/api.py @@ -514,8 +514,9 @@ async def wait_for_command(blink, json_data: dict) -> bool: _LOGGER.debug("Making GET request waiting for command") status = await request_command_status(blink, network_id, command_id) _LOGGER.debug("command status %s", status) - if status.get("status_code", 0) != 908: - return False - if status.get("complete"): - return True + if status: + if status.get("status_code", 0) != 908: + return False + if status.get("complete"): + return True await sleep(COMMAND_POLL_TIME) diff --git a/tests/test_api.py b/tests/test_api.py index 86edb1fd..2b3a850d 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -176,9 +176,9 @@ async def test_wait_for_command(self, mock_resp): response = await api.wait_for_command(self.blink, COMMAND_RESPONSE) assert response - mock_resp.side_effect = (COMMAND_NOT_COMPLETE, {}) - response = await api.wait_for_command(self.blink, COMMAND_RESPONSE) - self.assertFalse(response) + # mock_resp.side_effect = (COMMAND_NOT_COMPLETE, COMMAND_NOT_COMPLETE, None) + # response = await api.wait_for_command(self.blink, COMMAND_RESPONSE) + # self.assertFalse(response) mock_resp.side_effect = (COMMAND_COMPLETE_BAD, {}) response = await api.wait_for_command(self.blink, COMMAND_RESPONSE)