37 lines
763 B
Python
37 lines
763 B
Python
import functools
|
|
from datetime import datetime, time
|
|
from pathlib import Path
|
|
from typing import Annotated, Any
|
|
|
|
from appdaemon.adapi import ADAPI
|
|
from pydantic import (
|
|
BaseModel,
|
|
BeforeValidator,
|
|
Field,
|
|
PrivateAttr,
|
|
TypeAdapter,
|
|
field_serializer,
|
|
field_validator,
|
|
)
|
|
from rich import print as rprint
|
|
|
|
|
|
class EntityState(BaseModel):
|
|
state: bool = True
|
|
color_temp_kelvin: int
|
|
brightness: int
|
|
|
|
@field_serializer("state")
|
|
def convert_state(self, val: Any):
|
|
if val:
|
|
return "on"
|
|
else:
|
|
return "off"
|
|
|
|
|
|
class Stage(BaseModel):
|
|
# start: Annotated[time, BeforeValidator(lambda v: parser(v).time())]
|
|
start: str
|
|
_start: time = PrivateAttr()
|
|
scene: dict[str, EntityState]
|