Skip to content

Commit 78516e8

Browse files
committed
Use MAX_LOG_HOUR as in pulses.py
1 parent 750d93c commit 78516e8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
)
2525
from ..connection import StickController
2626
from ..constants import (
27+
DAY_IN_HOURS,
2728
DEFAULT_CONS_INTERVAL,
2829
MAX_TIME_DRIFT,
2930
MINIMAL_POWER_UPDATE,
@@ -72,6 +73,8 @@
7273
# Default firmware if not known
7374
DEFAULT_FIRMWARE: Final = datetime(2008, 8, 26, 15, 46, tzinfo=UTC)
7475

76+
MAX_LOG_HOURS = DAY_IN_HOURS
77+
7578
FuncT = TypeVar("FuncT", bound=Callable[..., Any])
7679
_LOGGER = logging.getLogger(__name__)
7780

@@ -468,7 +471,7 @@ async def _get_initial_energy_logs(self) -> None:
468471
if not result:
469472
# Handle case with None-data in all address slots
470473
_LOGGER.debug(
471-
"All slots at log address %s are empty or outdated – stopping initial collection",
474+
"All slots at log address %s are empty or outdated – stopping initial collection",
472475
log_address,
473476
)
474477
break
@@ -580,12 +583,12 @@ def _check_timestamp_is_recent(
580583
) -> bool:
581584
"""Check if the timestamp of the received log-record is recent.
582585
583-
A timestamp from within the last 24 hours is considered recent.
586+
A timestamp newer than MAX_LOG_HOURS is considered recent.
584587
"""
585588
age_seconds = (
586589
datetime.now(tz=UTC) - timestamp.replace(tzinfo=UTC)
587590
).total_seconds()
588-
if age_seconds > DAY_IN_HOURS * 3600:
591+
if age_seconds > MAX_LOG_HOURS * 3600:
589592
_LOGGER.warning(
590593
"EnergyLog from Node %s | address %s | slot %s | timestamp %s is outdated, ignoring...",
591594
self._mac_in_str,

0 commit comments

Comments
 (0)