From e2beef511c83267ddda06a0452eb0ec8d1173bfe Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Thu, 6 Aug 2026 15:19:14 +0200 Subject: [PATCH] Send status updae after doing changes --- micro_ondes/esp_lora/main.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/micro_ondes/esp_lora/main.py b/micro_ondes/esp_lora/main.py index f5c95b2..76ba5b6 100644 --- a/micro_ondes/esp_lora/main.py +++ b/micro_ondes/esp_lora/main.py @@ -84,14 +84,7 @@ def cooking_state_temperature_provider(): def cooking_state_on_state_change(state): print(f"[Main] Cooking state changed to: {state.state}") - - # Send to the Wifi board the current state - uart_device.send_as_command(UARTCommand(UARTCommandType.COOKING_STATE_UPDATE, {"state": state.state})) - # Send to the orchestrator the current state - lora.send_reliable({"id": DEVICE_ID, "new_cooking_state": state.state}) - - display.text(cookingState.CookingStates.get_state_name(state.state), 1, 2, 1) - display.show() + if state.paused or state.state == cookingState.CookingStates.DONE or state.state == cookingState.CookingStates.IDLE: magnetron_led.off() @@ -108,6 +101,15 @@ def cooking_state_on_state_change(state): if state.state == cookingState.CookingStates.ALERT: pass + # Send to the Wifi board the current state + uart_device.send_as_command(UARTCommand(UARTCommandType.COOKING_STATE_UPDATE, {"state": state.state})) + # Send to the orchestrator the current state + lora.send_reliable({"id": DEVICE_ID, "new_cooking_state": state.state}) + + display.fill(0) + display.text(cookingState.CookingStates.get_state_name(state.state), 1, 2, 1) + display.show() + def cooking_state_on_refresh(state): # TODO Show screen information pass