started stages logic
This commit is contained in:
36
apps/stages.py
Normal file
36
apps/stages.py
Normal file
@@ -0,0 +1,36 @@
|
||||
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]
|
||||
Reference in New Issue
Block a user