Ver Fonte

fix idel timeout

tuanchris há 3 meses atrás
pai
commit
df64e40e2e
2 ficheiros alterados com 13 adições e 7 exclusões
  1. 3 1
      main.py
  2. 10 6
      modules/led/dw_led_controller.py

+ 3 - 1
main.py

@@ -198,7 +198,9 @@ async def lifespan(app: FastAPI):
                 # Turn off LEDs if timeout expired
                 if idle_seconds >= timeout_seconds:
                     status = state.led_controller.check_status()
-                    if status.get("power", False):  # Only turn off if currently on
+                    # Check both "power" (WLED) and "power_on" (DW LEDs) keys
+                    is_powered_on = status.get("power", False) or status.get("power_on", False)
+                    if is_powered_on:  # Only turn off if currently on
                         logger.info(f"Idle timeout ({state.dw_led_idle_timeout_minutes} minutes) expired, turning off LEDs")
                         state.led_controller.set_power(0)
                         # Reset activity time to prevent repeated turn-off attempts

+ 10 - 6
modules/led/dw_led_controller.py

@@ -553,9 +553,11 @@ def effect_idle(controller: DWLEDController, effect_settings: Optional[dict] = N
                 g3 = int(color3[3:5], 16)
                 b3 = int(color3[5:7], 16)
 
-                controller.set_color_slot(0, r1, g1, b1)
-                controller.set_color_slot(1, r2, g2, b2)
-                controller.set_color_slot(2, r3, g3, b3)
+                controller.set_colors(
+                    color1=(r1, g1, b1),
+                    color2=(r2, g2, b2),
+                    color3=(r3, g3, b3)
+                )
 
             return True
 
@@ -614,9 +616,11 @@ def effect_playing(controller: DWLEDController, effect_settings: Optional[dict]
                 g3 = int(color3[3:5], 16)
                 b3 = int(color3[5:7], 16)
 
-                controller.set_color_slot(0, r1, g1, b1)
-                controller.set_color_slot(1, r2, g2, b2)
-                controller.set_color_slot(2, r3, g3, b3)
+                controller.set_colors(
+                    color1=(r1, g1, b1),
+                    color2=(r2, g2, b2),
+                    color3=(r3, g3, b3)
+                )
 
             return True