Skip to content

Commit 474ec3f

Browse files
committed
Add timestamp to indicate when initialization should be finished
1 parent b9880a3 commit 474ec3f

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

plugwise_usb/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
STICK_TIME_OUT: Final = 11 # Stick responds with timeout messages within 10s.
3535
NODE_TIME_OUT: Final = 15 # In bigger networks a response from a node could take up a while, so lets use 15 seconds.
3636
MAX_RETRIES: Final = 3
37+
SUPPRESS_INITIALIZATION_WARNINGS: Final = 10 # Minutes to suppress (expected) communication warning messages after initialization
3738

3839
# plugwise year information is offset from y2k
3940
PLUGWISE_EPOCH: Final = 2000

plugwise_usb/nodes/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
RelayState,
2121
)
2222
from ..connection import StickController
23-
from ..constants import UTF8, MotionSensitivity
23+
from ..constants import SUPPRESS_INITIALIZATION_WARNINGS, UTF8, MotionSensitivity
2424
from ..exceptions import NodeError
2525
from ..messages.requests import NodeInfoRequest, NodePingRequest
2626
from ..messages.responses import NodeInfoResponse, NodePingResponse
@@ -79,6 +79,7 @@ def __init__(
7979

8080
self._connected: bool = False
8181
self._initialized: bool = False
82+
self._initialization_delay_expired: datetime | None = None
8283
self._loaded: bool = False
8384
self._node_protocols: SupportedVersions | None = None
8485
self._node_last_online: datetime | None = None
@@ -412,6 +413,7 @@ async def initialize(self) -> bool:
412413
"""Initialize node."""
413414
if self._initialized:
414415
return True
416+
self._initialization_delay_expired = datetime.now(UTC) + timedelta(minutes=SUPPRESS_INITIALIZATION_WARNINGS)
415417
self._initialized = True
416418
return True
417419

0 commit comments

Comments
 (0)