From 04556d5cfe9be3504f656aad792a19edc408a687 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Tue, 28 Jul 2026 18:29:39 -0400 Subject: [PATCH] Ensure `self._start_time` always exists and is reset on reconnect --- zigpy_ziggurat/zigbee/application.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zigpy_ziggurat/zigbee/application.py b/zigpy_ziggurat/zigbee/application.py index 83f495a..8bb7989 100644 --- a/zigpy_ziggurat/zigbee/application.py +++ b/zigpy_ziggurat/zigbee/application.py @@ -105,6 +105,7 @@ class ControllerApplication(zigpy.application.ControllerApplication): def __init__(self, config: dict[str, Any]) -> None: super().__init__(config) self._api: ZigguratApi | None = None + self._start_time: datetime | None = None async def connect(self) -> None: # The device path is either the WebSocket URL of a ziggurat server or the @@ -128,6 +129,8 @@ async def connect(self) -> None: await api.request(p.Reset(hard=t.Bool(False))) async def disconnect(self) -> None: + self._start_time = None + if self._api is not None: try: await self._api.disconnect() @@ -863,9 +866,9 @@ async def send_packet(self, packet: t.ZigbeePacket) -> None: # Within the network startup period, provide route hints to the # stack to reduce routing congestion - if ( - device is not None - and datetime.now(timezone.utc) - self._start_time + if device is not None and ( + self._start_time is None + or datetime.now(timezone.utc) - self._start_time < ROUTE_HINT_DURATION ): maybe_relays = self.build_source_route_to(device)