improved brightness handling
This commit is contained in:
@@ -141,13 +141,15 @@ class SmartLight(SmartSwitch):
|
||||
# light_brightness_pct: build ordered evaluator list, run initial pass
|
||||
if "light_brightness_pct" in self.args:
|
||||
self.always_change_brightness = False
|
||||
|
||||
if isinstance(self.args["light_brightness_pct"], int):
|
||||
self.light_brightness_pct = self.args["light_brightness_pct"]
|
||||
else:
|
||||
for key in self.args["light_brightness_pct"]:
|
||||
if key == 'always_change_brightness':
|
||||
self.always_change_brightness = bool(self.args["light_brightness_pct"][key])
|
||||
else:
|
||||
self.light_brightness_pct_list.append((SmartCondition.Evaluator(self,self.args["light_brightness_pct"][key],condition_name = key, on_update_cb = self.on_update_light_brightness_pct,constants = self.constants, templates_library = self.templates_library, log_callback_trigger_reason = False),key))
|
||||
self. on_update_light_brightness_pct()
|
||||
self.on_update_light_brightness_pct()
|
||||
|
||||
self.listen_state(self.on_state_change,self.entity_id)
|
||||
|
||||
@@ -183,7 +185,7 @@ class SmartLight(SmartSwitch):
|
||||
# EventHandler callback for on_events_with_transition. Jumps to 1 %
|
||||
# first so the ramp always starts from a known low level, then
|
||||
# transitions to the configured brightness over transition_time seconds.
|
||||
def on_turn_on_with_transition(self, event_name, data, kwargs, event_category):
|
||||
def on_turn_on_with_transition(self, event_name, data, event_category):
|
||||
transition_time = self.args["on_events_with_transition"][event_category]["transition_time"]
|
||||
brightness_pct = self.args["on_events_with_transition"][event_category]["brightness_pct"]
|
||||
self.log(f"Turn on at {brightness_pct}% with a transition of {transition_time}s")
|
||||
|
||||
Reference in New Issue
Block a user