Ver Fonte

Fix LEDs not turning back on when Still Sands period ends

Power LEDs back on unconditionally when Still Sands ends, regardless of
whether a playing effect is configured. Previously the set_power(1) call
was gated behind should_trigger_led, so DW LED users without a playing
effect configured would have LEDs stay off permanently after a quiet
period ended.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tuanchris há 4 meses atrás
pai
commit
fcd5a54e67
1 ficheiros alterados com 16 adições e 17 exclusões
  1. 16 17
      modules/core/pattern_manager.py

+ 16 - 17
modules/core/pattern_manager.py

@@ -1354,19 +1354,18 @@ async def _execute_pattern_internal(file_path):
 
                 logger.info("Execution resumed...")
                 if state.led_controller:
-                    # Turn LED controller back on if it was turned off for scheduled pause
+                    # Always power LEDs back on if they were turned off for scheduled pause,
+                    # regardless of whether a playing effect is configured
+                    if wled_was_off_for_scheduled:
+                        logger.info("Turning LED lights back on as Still Sands period ended")
+                        await state.led_controller.set_power_async(1)
+                        # CRITICAL: Give LED controller time to fully power on before sending more commands
+                        # Without this delay, rapid-fire requests can crash controllers on resource-constrained Pis
+                        await asyncio.sleep(0.5)
+                    # Apply playing effect if configured
                     # For WLED: always trigger (uses hardcoded preset 2)
                     # For DW_LED: only trigger if effect is configured
                     should_trigger_led = state.led_provider == "wled" or state.dw_led_playing_effect
-                    if wled_was_off_for_scheduled:
-                        if should_trigger_led:
-                            logger.info("Turning LED lights back on as Still Sands period ended")
-                            await state.led_controller.set_power_async(1)
-                            # CRITICAL: Give LED controller time to fully power on before sending more commands
-                            # Without this delay, rapid-fire requests can crash controllers on resource-constrained Pis
-                            await asyncio.sleep(0.5)
-                        else:
-                            logger.info("No playing effect configured, keeping LEDs off after Still Sands")
                     if should_trigger_led:
                         await state.led_controller.effect_playing_async(state.dw_led_playing_effect)
                     # Cancel idle timeout when resuming from pause
@@ -1613,16 +1612,16 @@ async def run_theta_rho_files(file_paths, pause_time=0, clear_pattern=None, run_
                     if result == 'completed':
                         logger.info("Still Sands period ended. Resuming playlist...")
                         if state.led_controller:
+                            # Always power LEDs back on if they were turned off for scheduled pause,
+                            # regardless of whether a playing effect is configured
+                            if wled_was_off_for_scheduled:
+                                logger.info("Turning LED lights back on as Still Sands period ended")
+                                await state.led_controller.set_power_async(1)
+                                await asyncio.sleep(0.5)
+                            # Apply playing effect if configured
                             # For WLED: always trigger (uses hardcoded preset 2)
                             # For DW_LED: only trigger if effect is configured
                             should_trigger_led = state.led_provider == "wled" or state.dw_led_playing_effect
-                            if wled_was_off_for_scheduled:
-                                if should_trigger_led:
-                                    logger.info("Turning LED lights back on as Still Sands period ended")
-                                    await state.led_controller.set_power_async(1)
-                                    await asyncio.sleep(0.5)
-                                else:
-                                    logger.info("No playing effect configured, keeping LEDs off after Still Sands")
                             if should_trigger_led:
                                 await state.led_controller.effect_playing_async(state.dw_led_playing_effect)
                             idle_timeout_manager.cancel_timeout()