"""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: Optional[Literal["on", "off"]] = Field( None, 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