Skip to content

Commit

Permalink
Partial merge of #272 - handle not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
roysjosh authored and Jc2k committed Dec 28, 2022
1 parent 269c7dd commit 9345d55
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aiohomekit/controller/coap/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ async def post_bytes(self, payload: bytes, timeout: int = 16.0):
except (NetworkError, asyncio.TimeoutError):
raise AccessoryDisconnectedError("Request timeout")

if response.code != Code.CHANGED:
if response.code == Code.NOT_FOUND:
# maybe the accessory lost power or was otherwise rebooted
logger.error("CoAP POST returned 404, our session is gone.")
await self.coap_ctx.shutdown()
self.coap_ctx = None
elif response.code != Code.CHANGED:
logger.warning(f"CoAP POST returned unexpected code {response}")

return await self._decrypt_response(response)
Expand Down

0 comments on commit 9345d55

Please sign in to comment.