Create common Time module and add time set cli command (#1157)

This commit is contained in:
Steven B.
2024-10-15 08:59:25 +01:00
committed by GitHub
parent 885a04d24f
commit 7fd8c14c1f
18 changed files with 350 additions and 69 deletions

View File

@@ -6,6 +6,7 @@ from .led import Led
from .light import Light, LightState
from .lighteffect import LightEffect
from .lightpreset import LightPreset
from .time import Time
__all__ = [
"Fan",
@@ -15,4 +16,5 @@ __all__ = [
"LightEffect",
"LightState",
"LightPreset",
"Time",
]

26
kasa/interfaces/time.py Normal file
View File

@@ -0,0 +1,26 @@
"""Module for time interface."""
from __future__ import annotations
from abc import ABC, abstractmethod
from datetime import datetime, tzinfo
from ..module import Module
class Time(Module, ABC):
"""Base class for tplink time module."""
@property
@abstractmethod
def time(self) -> datetime:
"""Return timezone aware current device time."""
@property
@abstractmethod
def timezone(self) -> tzinfo:
"""Return current timezone."""
@abstractmethod
async def set_time(self, dt: datetime) -> dict:
"""Set the device time."""