Index: limitlessled_rf/__init__.py ================================================================== --- limitlessled_rf/__init__.py +++ limitlessled_rf/__init__.py @@ -585,42 +585,47 @@ use_max_button = False if initial_value == target_range_max: if 'has_max_{}'.format(button_prefix) in self._config['features']: use_max_button = True + # Now that we have forced the value to the extreme, move in + # steps from that value to the desired value + if initial_value < target_value: + final_steps = target_value - initial_value + else: + final_steps = initial_value - target_value + if use_max_button: self._debug("[INITIAL] Going to max {}".format(button_prefix)) getattr(self, "_max_{}".format(button_prefix))(zone) else: # Otherwise, step it step_command = {'button': "{}_{}".format(button_prefix, initial_direction)} if zone is not None: step_command['zone'] = zone for step in range(initial_steps): - self._debug("[INITIAL] Stepping {} {}".format(button_prefix, initial_direction)) - self._send_button(step_command) - - # Now that we have forced the value to the extreme, move in - # steps from that value to the desired value - if initial_value < target_value: - final_steps = target_value - initial_value - else: - final_steps = initial_value - target_value + transition_delay = None + if step == (initial_steps - 1) and transition is not None and final_steps > 1: + transition_delay = transition / final_steps + + self._debug("[INITIAL] Stepping {} {} with a delay of {} (s) afterwards".format(button_prefix, initial_direction, transition_delay)) + self._send_button(step_command, post_delay = transition_delay) + step_command = {'button': "{}_{}".format(button_prefix, final_direction)} if zone is not None: step_command['zone'] = zone transition_delay = None if transition is not None and final_steps > 1: - transition_delay = transition / (final_steps - 1) + transition_delay = transition / final_steps for step in range(final_steps): if step == (final_steps - 1): transition_delay = None - self._debug("[FINAL] Stepping {} {} with a delay of {} (ms) afterwards".format(button_prefix, final_direction, transition_delay)) + self._debug("[FINAL] Stepping {} {} with a delay of {} (s) afterwards".format(button_prefix, final_direction, transition_delay)) self._send_button(step_command, post_delay = transition_delay) return True def _step_brightness(self, brightness, brightness_min, brightness_max, zone = None, transition = None):