mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Create common Time module and add time set cli command (#1157)
This commit is contained in:
@@ -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
26
kasa/interfaces/time.py
Normal 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."""
|
Reference in New Issue
Block a user