mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-11-06 11:57:26 +00:00
Add TemperatureRecords module (#1814)
Adds the temp_record module, exposing thermostat temperature history oldest first, converting missing readings to None, and refreshing every 15 minutes. Includes registration, exports, its missing-fixture fallback, and module tests.
This commit is contained in:
@@ -39,6 +39,7 @@ from .powerprotection import PowerProtection
|
||||
from .reportmode import ReportMode
|
||||
from .speaker import Speaker
|
||||
from .temperaturecontrol import TemperatureControl
|
||||
from .temperaturerecords import TemperatureRecords
|
||||
from .temperaturesensor import TemperatureSensor
|
||||
from .thermostat import Thermostat
|
||||
from .time import Time
|
||||
@@ -78,6 +79,7 @@ __all__ = [
|
||||
"TriggerLogs",
|
||||
"FrostProtection",
|
||||
"Thermostat",
|
||||
"TemperatureRecords",
|
||||
"Clean",
|
||||
"Consumables",
|
||||
"CleanRecords",
|
||||
|
||||
32
kasa/smart/modules/temperaturerecords.py
Normal file
32
kasa/smart/modules/temperaturerecords.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""Implementation of the thermostat temperature records module."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
from ..smartmodule import SmartModule
|
||||
|
||||
#: Value the device uses for slots without a reading.
|
||||
NO_READING = -1000
|
||||
|
||||
|
||||
class TemperatureRecords(SmartModule):
|
||||
"""Implementation of the temperature history of a thermostat.
|
||||
|
||||
The device keeps a reading for every 15 minutes of the last 24 hours,
|
||||
ordered oldest first, with the most recent reading last.
|
||||
"""
|
||||
|
||||
REQUIRED_COMPONENT = "temp_record"
|
||||
QUERY_GETTER_NAME = "get_temperature_records"
|
||||
INTERVAL = timedelta(minutes=15)
|
||||
MINIMUM_UPDATE_INTERVAL_SECS = 15 * 60
|
||||
MINIMUM_HUB_CHILD_UPDATE_INTERVAL_SECS = 15 * 60
|
||||
|
||||
@property
|
||||
def temperatures(self) -> list[float | None]:
|
||||
"""Return the readings oldest first, None where there is no reading."""
|
||||
return [
|
||||
None if value == NO_READING else value / 10
|
||||
for value in self.data.get("temp_data", [])
|
||||
]
|
||||
Reference in New Issue
Block a user