mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-11-26 12:45:26 +01:00
Propagate if disconnect was expected to disconnect callback (#448)
This commit is contained in:
parent
b490d3b7e0
commit
4fe46f5aa0
@ -59,7 +59,9 @@ async def main(argv: List[str]) -> None:
|
||||
except APIConnectionError:
|
||||
await cli.disconnect()
|
||||
|
||||
async def on_disconnect() -> None:
|
||||
async def on_disconnect( # pylint: disable=unused-argument
|
||||
expected_disconnect: bool,
|
||||
) -> None:
|
||||
_LOGGER.warning("Disconnected from API")
|
||||
|
||||
logic = ReconnectLogic(
|
||||
|
@ -33,7 +33,7 @@ class ReconnectLogic(zeroconf.RecordUpdateListener):
|
||||
*,
|
||||
client: APIClient,
|
||||
on_connect: Callable[[], Awaitable[None]],
|
||||
on_disconnect: Callable[[], Awaitable[None]],
|
||||
on_disconnect: Callable[[bool], Awaitable[None]],
|
||||
zeroconf_instance: "zeroconf.Zeroconf",
|
||||
name: Optional[str] = None,
|
||||
on_connect_error: Optional[Callable[[Exception], Awaitable[None]]] = None,
|
||||
@ -86,7 +86,7 @@ class ReconnectLogic(zeroconf.RecordUpdateListener):
|
||||
)
|
||||
|
||||
# Run disconnect hook
|
||||
await self._on_disconnect_cb()
|
||||
await self._on_disconnect_cb(expected_disconnect)
|
||||
|
||||
async with self._connected_lock:
|
||||
self._connected = False
|
||||
|
Loading…
Reference in New Issue
Block a user