added manual mode
This commit is contained in:
19
model.py
19
model.py
@@ -49,7 +49,7 @@ class ControllerStateConfig(BaseModel):
|
||||
elevation: Optional[float] = None
|
||||
direction: Optional[Annotated[SunDirection, BeforeValidator(str_to_direction)]] = None
|
||||
off_duration: Optional[OffDuration] = None
|
||||
scene: dict[str, State]
|
||||
scene: dict[str, State] | str
|
||||
|
||||
@root_validator(pre=True)
|
||||
def check_args(cls, values):
|
||||
@@ -68,6 +68,8 @@ class RoomControllerConfig(BaseModel):
|
||||
states: List[ControllerStateConfig] = Field(default_factory=list)
|
||||
off_duration: Optional[OffDuration] = None
|
||||
sleep_state: Optional[ControllerStateConfig] = None
|
||||
rich: Optional[str] = None
|
||||
manual_mode: Optional[str] = None
|
||||
|
||||
@classmethod
|
||||
def from_yaml(cls: Self, yaml_path: Path) -> Self:
|
||||
@@ -86,12 +88,15 @@ class RoomControllerConfig(BaseModel):
|
||||
collapse_padding=True,
|
||||
)
|
||||
for state in self.states:
|
||||
scene_json = state.to_apply_kwargs()
|
||||
lines = [
|
||||
f'{name:20}{state["state"]} Brightness: {state["brightness"]:<4} Temp: {state["color_temp"]}'
|
||||
for name, state in scene_json['entities'].items()
|
||||
]
|
||||
table.add_row(state.time.strftime('%I:%M:%S %p'), '\n'.join(lines))
|
||||
if isinstance(state, str):
|
||||
pass
|
||||
elif isinstance(state, dict):
|
||||
scene_json = state.to_apply_kwargs()
|
||||
lines = [
|
||||
f'{name:20}{state["state"]} Brightness: {state.get("brightness", ""):<4} Temp: {state.get("color_temp", "")}'
|
||||
for name, state in scene_json['entities'].items()
|
||||
]
|
||||
table.add_row(state.time.strftime('%I:%M:%S %p'), '\n'.join(lines))
|
||||
yield table
|
||||
|
||||
def sort_states(self):
|
||||
|
||||
Reference in New Issue
Block a user