Stabilise on_since value for smart devices (#1144)

Caches the `on_since` value to prevent jitter caused by the device calculations.
This commit is contained in:
Steven B.
2024-10-02 15:04:16 +01:00
committed by GitHub
parent 81e2685605
commit 1fcf3e44c2
4 changed files with 43 additions and 13 deletions

View File

@@ -435,7 +435,11 @@ class Device(ABC):
@property
@abstractmethod
def on_since(self) -> datetime | None:
"""Return the time that the device was turned on or None if turned off."""
"""Return the time that the device was turned on or None if turned off.
This returns a cached value if the device reported value difference is under
five seconds to avoid device-caused jitter.
"""
@abstractmethod
async def wifi_scan(self) -> list[WifiNetwork]: