From 25892e1de8d017cb3c7610d43f0c167f3eefdd21 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Sun, 30 Nov 2025 16:41:46 -0600 Subject: [PATCH] added transition config --- apps/stages/bar.yaml | 1 + apps/stages/light.py | 14 +++++++++++--- apps/stages/stages.py | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/stages/bar.yaml b/apps/stages/bar.yaml index b63989c..6ab052d 100644 --- a/apps/stages/bar.yaml +++ b/apps/stages/bar.yaml @@ -2,6 +2,7 @@ bar_lights: module: light class: StagedLight activate-at-start: true + transition: 3 stages: - start: '03:00 am' scene: diff --git a/apps/stages/light.py b/apps/stages/light.py index dbecd0f..ca81557 100644 --- a/apps/stages/light.py +++ b/apps/stages/light.py @@ -75,9 +75,17 @@ class StagedLight(Hass): ### Actions - def activate(self, scene: dict | None = None, **kwargs): - scene = scene if scene is not None else self.current_scene() - return self.call_service('scene/apply', entities=scene, transition=5) + def activate(self, scene: dict | None = None, **kwargs: Any): + if scene is None: + stage = self.current_stage() + kwargs['entities'] = stage.scene_json() + else: + kwargs['entities'] = scene + + if t := self.args.get('transition'): + kwargs['transition'] = t + + return self.call_service('scene/apply', **kwargs) def deactivate(self, stage: Stage | None = None, **kwargs): stage = stage if stage is not None else self.current_stage() diff --git a/apps/stages/stages.py b/apps/stages/stages.py index 1fc2cdf..38541b1 100644 --- a/apps/stages/stages.py +++ b/apps/stages/stages.py @@ -23,8 +23,9 @@ class EntityState(BaseModel, extra='allow'): class Stage(BaseModel): # start: Annotated[time, BeforeValidator(lambda v: parser(v).time())] start: str - _start: datetime = PrivateAttr() scene: dict[str, EntityState] + _start: datetime = PrivateAttr() + transition: int | None = None def assign_start(self, dt: datetime): self._start = dt