thermostat

This commit is contained in:
2025-11-05 18:26:36 +01:00
parent 478450794f
commit cb555a1f67
10 changed files with 1293 additions and 11 deletions

View File

@@ -1,6 +1,18 @@
"""Home capabilities package."""
from packages.home_capabilities.light import CAP_VERSION, LightState
from packages.home_capabilities.light import CAP_VERSION as LIGHT_VERSION
from packages.home_capabilities.light import LightState
from packages.home_capabilities.thermostat import CAP_VERSION as THERMOSTAT_VERSION
from packages.home_capabilities.thermostat import ThermostatState
from packages.home_capabilities.layout import DeviceTile, Room, UiLayout, load_layout
__all__ = ["LightState", "CAP_VERSION", "DeviceTile", "Room", "UiLayout", "load_layout"]
__all__ = [
"LightState",
"LIGHT_VERSION",
"ThermostatState",
"THERMOSTAT_VERSION",
"DeviceTile",
"Room",
"UiLayout",
"load_layout",
]

View File

@@ -0,0 +1,77 @@
"""
Thermostat Capability Model
Pydantic v2 model for thermostat device state and commands.
"""
from decimal import Decimal
from typing import Literal
from pydantic import BaseModel, Field
CAP_VERSION = "thermostat@2.0.0"
class ThermostatState(BaseModel):
"""
Thermostat state model with validation.
Attributes:
mode: Operating mode (off, heat, auto)
target: Target temperature in °C [5.0..30.0]
current: Current temperature in °C (optional in SET, required in STATE)
battery: Battery level 0-100% (optional)
window_open: Window open detection (optional)
"""
mode: Literal["off", "heat", "auto"] = Field(
...,
description="Operating mode of the thermostat"
)
target: float | Decimal = Field(
...,
ge=5.0,
le=30.0,
description="Target temperature in degrees Celsius"
)
current: float | Decimal | None = Field(
None,
ge=0.0,
description="Current measured temperature in degrees Celsius"
)
battery: int | None = Field(
None,
ge=0,
le=100,
description="Battery level percentage"
)
window_open: bool | None = Field(
None,
description="Window open detection status"
)
model_config = {
"json_schema_extra": {
"examples": [
{
"mode": "heat",
"target": 21.0,
"current": 20.2,
"battery": 85,
"window_open": False
},
{
"mode": "auto",
"target": 22.5
},
{
"mode": "off",
"target": 5.0,
"current": 18.0
}
]
}
}