mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-12-01 13:48:15 +00:00
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
This adds `hold_on` to the known states to allow downstreams handle the hold mode (idle, but heating if the temperature gets lower than the target).
68 lines
1.7 KiB
Python
68 lines
1.7 KiB
Python
"""Interact with a TPLink Thermostat."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from enum import Enum
|
|
from typing import Annotated, Literal
|
|
|
|
from ..module import FeatureAttribute, Module
|
|
|
|
|
|
class ThermostatState(Enum):
|
|
"""Thermostat state."""
|
|
|
|
Heating = "heating"
|
|
Calibrating = "progress_calibration"
|
|
Idle = "idle"
|
|
Hold = "hold_on"
|
|
Off = "off"
|
|
Shutdown = "shutdown"
|
|
Unknown = "unknown"
|
|
|
|
|
|
class Thermostat(Module, ABC):
|
|
"""Base class for TP-Link Thermostat."""
|
|
|
|
@property
|
|
@abstractmethod
|
|
def state(self) -> bool:
|
|
"""Return thermostat state."""
|
|
|
|
@abstractmethod
|
|
async def set_state(self, enabled: bool) -> dict:
|
|
"""Set thermostat state."""
|
|
|
|
@property
|
|
@abstractmethod
|
|
def mode(self) -> ThermostatState:
|
|
"""Return thermostat state."""
|
|
|
|
@property
|
|
@abstractmethod
|
|
def target_temperature(self) -> Annotated[float, FeatureAttribute()]:
|
|
"""Return target temperature."""
|
|
|
|
@abstractmethod
|
|
async def set_target_temperature(
|
|
self, target: float
|
|
) -> Annotated[dict, FeatureAttribute()]:
|
|
"""Set target temperature."""
|
|
|
|
@property
|
|
@abstractmethod
|
|
def temperature(self) -> Annotated[float, FeatureAttribute()]:
|
|
"""Return current humidity in percentage."""
|
|
return self._device.sys_info["current_temp"]
|
|
|
|
@property
|
|
@abstractmethod
|
|
def temperature_unit(self) -> Literal["celsius", "fahrenheit"]:
|
|
"""Return current temperature unit."""
|
|
|
|
@abstractmethod
|
|
async def set_temperature_unit(
|
|
self, unit: Literal["celsius", "fahrenheit"]
|
|
) -> dict:
|
|
"""Set the device temperature unit."""
|