mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 11:43:34 +00:00
70c96b5a5d
Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
35 lines
818 B
Python
35 lines
818 B
Python
"""Implementation of trigger logs module."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from pydantic.v1 import BaseModel, Field, parse_obj_as
|
|
|
|
from ..smartmodule import SmartModule
|
|
|
|
|
|
class LogEntry(BaseModel):
|
|
"""Presentation of a single log entry."""
|
|
|
|
id: int
|
|
event_id: str = Field(alias="eventId")
|
|
timestamp: datetime
|
|
event: str
|
|
|
|
|
|
class TriggerLogs(SmartModule):
|
|
"""Implementation of trigger logs."""
|
|
|
|
REQUIRED_COMPONENT = "trigger_log"
|
|
MINIMUM_UPDATE_INTERVAL_SECS = 60 * 60
|
|
|
|
def query(self) -> dict:
|
|
"""Query to execute during the update cycle."""
|
|
return {"get_trigger_logs": {"start_id": 0}}
|
|
|
|
@property
|
|
def logs(self) -> list[LogEntry]:
|
|
"""Return logs."""
|
|
return parse_obj_as(list[LogEntry], self.data["logs"])
|