Skip to content

Commit

Permalink
Merge pull request #847 from mkmer/Wait-command
Browse files Browse the repository at this point in the history
Handle Emtpy put response in wait_command
  • Loading branch information
fronzbot authored Jan 7, 2024
2 parents b5aca74 + c78f42b commit b5fe148
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions blinkpy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit b5fe148

Please sign in to comment.