initial, step 2 already

This commit is contained in:
2025-10-31 14:25:12 +01:00
commit ea17d048ad
24 changed files with 1431 additions and 0 deletions

1
packages/__init__.py Normal file
View File

@@ -0,0 +1 @@
"""Packages."""

View File

@@ -0,0 +1,5 @@
"""Home capabilities package."""
from packages.home_capabilities.light import CAP_VERSION, LightState
__all__ = ["LightState", "CAP_VERSION"]

View File

@@ -0,0 +1,52 @@
"""Light capability models and constants."""
from typing import Literal, Optional
from pydantic import BaseModel, Field, field_validator
CAP_VERSION = "light@1.2.0"
class LightState(BaseModel):
"""Represents the state of a light device.
Attributes:
power: Whether the light is "on" or "off"
brightness: Optional brightness level (0-100)
color_temp: Optional color temperature in Kelvin (150-500)
color: Optional hex color string in format "#RRGGBB"
"""
power: Literal["on", "off"] = Field(
...,
description="Power state of the light"
)
brightness: Optional[int] = Field(
None,
ge=0,
le=100,
description="Brightness level from 0 to 100"
)
color_temp: Optional[int] = Field(
None,
ge=150,
le=500,
description="Color temperature in Kelvin (150-500)"
)
color: Optional[str] = Field(
None,
pattern=r"^#[0-9A-Fa-f]{6}$",
description="Hex color string in format #RRGGBB"
)
@field_validator("color")
@classmethod
def validate_color_format(cls, v: Optional[str]) -> Optional[str]:
"""Ensure color is uppercase if provided."""
if v is not None:
return v.upper()
return v