From 08dabb4c7f1e2b16de4c6813d1ac739b9f581caa Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 19 Apr 2026 22:47:33 +0200 Subject: [PATCH] add brightness step transition configuration for smoother adjustments --- apps/smartlight.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/smartlight.py b/apps/smartlight.py index 87ff0ce..b9f5ded 100644 --- a/apps/smartlight.py +++ b/apps/smartlight.py @@ -17,6 +17,10 @@ from ad_toolbox.eventhandler import EventHandler # brightness_pct_step: # optional, default 5 # Step size (% of full brightness) used by increase/decrease events. # +# brightness_step_transition: # optional, default 0.5 +# Transition duration applied to each increase/decrease brightness +# step. Smooths out the brightness change instead of jumping. +# # increase_brightness_events: # optional # # HA events that increase brightness by brightness_pct_step. @@ -69,6 +73,7 @@ from ad_toolbox.eventhandler import EventHandler # entity: light.living_room # # brightness_pct_step: 10 +# brightness_step_transition: 0.5 # # increase_brightness_events: # btn_up: @@ -126,6 +131,8 @@ class SmartLight(SmartSwitch): self.brightness_pct_step = self.args["brightness_pct_step"] else: self.brightness_pct_step = 5 + self.brightness_step_transition = self.args.get("brightness_step_transition", 0.8) + # on_events_with_transition: one EventHandler per labelled transition if "on_events_with_transition" in self.args: for key in self.args["on_events_with_transition"]: @@ -166,12 +173,12 @@ class SmartLight(SmartSwitch): # Increase brightness by brightness_pct_step while the light is on. def on_increase_brightness_event(self, event_name, data, kwargs): if self.get_state(self.entity_id) != 'off': - self.call_service("light/turn_on", entity_id = self.entity_id, brightness_step_pct = self.brightness_pct_step) + self.call_service("light/turn_on", entity_id = self.entity_id, brightness_step_pct = self.brightness_pct_step, transition = self.brightness_step_transition) # Decrease brightness by brightness_pct_step while the light is on. def on_decrease_brightness_event(self, event_name, data, kwargs): if self.get_state(self.entity_id) != 'off': - self.call_service("light/turn_on", entity_id = self.entity_id, brightness_step_pct = -self.brightness_pct_step) + self.call_service("light/turn_on", entity_id = self.entity_id, brightness_step_pct = -self.brightness_pct_step, transition = self.brightness_step_transition) # EventHandler callback for on_events_with_transition. Jumps to 1 % # first so the ramp always starts from a known low level, then