From 204f271fc2e407994659b13dbb297c9875b7536f Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Sun, 23 Aug 2026 20:04:26 +0200 Subject: [PATCH] Fix global --- micro_ondes/esp_lora/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/micro_ondes/esp_lora/main.py b/micro_ondes/esp_lora/main.py index 7f380f7..95e952d 100644 --- a/micro_ondes/esp_lora/main.py +++ b/micro_ondes/esp_lora/main.py @@ -205,7 +205,7 @@ def cooking_state_temperature_provider(): return (0.0, 0.0) def cooking_state_on_state_change(state): - global cooking_start_time + global cooking_start_time, uart_device print(f"[CookingState] State changed to: {state.state}") if state.paused or state.state in (cookingState.CookingStates.DONE, cookingState.CookingStates.IDLE, cookingState.CookingStates.ALERT): @@ -214,7 +214,7 @@ def cooking_state_on_state_change(state): magnetron_led.on() # Send state updates to WiFi board and Orchestrator - if uart_device: + if uart_device != None: uart_device.send_as_command(UARTCommand(UARTCommandType.COOKING_STATE_UPDATE, {"state": state.state})) # Send LoRa update with start time and remaining time if beginning cooking process @@ -347,6 +347,8 @@ async def lora_process_task(): alert.timestamp = data.get("timestamp", time.time()) alert_manager.add_alert(alert) microwave_state = MicrowaveState.ALERT + if cooking_state is not None: + cooking_state.set_state(cookingState.CookingStates.ALERT) elif action == LoraCommands.MICROVAVE_STATE_UPDATE: new_state = data.get("new_microwave_state") @@ -356,7 +358,8 @@ async def lora_process_task(): if new_state not in (MicrowaveState.ALERT): # Not alert so we can show the error update_screen() if new_state == MicrowaveState.IDLE: - cooking_state = None + if cooking_state is not None: + cooking_state.set_state(cookingState.CookingStates.IDLE) await asyncio.sleep_ms(20) await asyncio.sleep_ms(100)