mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2025-01-26 22:22:10 +01:00
Fix not trying to disconnect cleanly on forced disconnect (#512)
This commit is contained in:
parent
762d00faff
commit
48b56ad25c
@ -825,6 +825,19 @@ class APIConnection:
|
|||||||
self._cleanup()
|
self._cleanup()
|
||||||
|
|
||||||
async def force_disconnect(self) -> None:
|
async def force_disconnect(self) -> None:
|
||||||
self._set_connection_state(ConnectionState.CLOSED)
|
"""Forcefully disconnect from the API."""
|
||||||
self._expected_disconnect = True
|
self._expected_disconnect = True
|
||||||
|
if self._is_socket_open and self._frame_helper:
|
||||||
|
# Still try to tell the esp to disconnect gracefully
|
||||||
|
# but don't wait for it to finish
|
||||||
|
try:
|
||||||
|
self.send_message(DisconnectRequest())
|
||||||
|
except APIConnectionError as err:
|
||||||
|
_LOGGER.error(
|
||||||
|
"%s: Failed to send (forced) disconnect request: %s",
|
||||||
|
self.log_name,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
|
||||||
|
self._set_connection_state(ConnectionState.CLOSED)
|
||||||
self._cleanup()
|
self._cleanup()
|
||||||
|
Loading…
Reference in New Issue
Block a user