Fix iotstrip child device time handling (#1584)
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled

This fixes the time handling of the child devices for iotstrip to
pull from the parent device time module instead of having each child
with its own time module.
This commit is contained in:
ZeliardM
2025-10-31 16:32:13 -04:00
committed by GitHub
parent adc291b62e
commit 29007e1079
3 changed files with 66 additions and 0 deletions

View File

@@ -7,6 +7,9 @@ from collections import defaultdict
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from datetime import tzinfo
from ..device_type import DeviceType
from ..deviceconfig import DeviceConfig
from ..emeterstatus import EmeterStatus
@@ -349,6 +352,8 @@ class IotStripPlug(IotPlug):
self.add_module(Module.IotAntitheft, Antitheft(self, "anti_theft"))
self.add_module(Module.IotSchedule, Schedule(self, "schedule"))
self.add_module(Module.IotCountdown, Countdown(self, "countdown"))
# Note: do not add a Time module to the child; time is device-level.
# Child exposes time/timezone by delegating to the parent.
async def _initialize_features(self) -> None:
"""Initialize common features."""
@@ -441,6 +446,18 @@ class IotStripPlug(IotPlug):
"""
return False
@property # type: ignore
@requires_update
def time(self) -> datetime:
"""Return current time, delegated from the parent strip."""
return self._parent.time
@property # type: ignore
@requires_update
def timezone(self) -> tzinfo:
"""Return timezone, delegated from the parent strip."""
return self._parent.timezone
@property # type: ignore
@requires_update
def device_id(self) -> str: