From e652831ce598897803f0fd35b110b887ef7c53bf Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Sun, 23 Aug 2026 16:12:15 +0200 Subject: [PATCH] Revert "Fix move to new messages" This reverts commit 3bead59b23672d102fc3056caf3056b38eca5926. --- orchestrateur/main.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/orchestrateur/main.py b/orchestrateur/main.py index 8dbd21f..1f86011 100644 --- a/orchestrateur/main.py +++ b/orchestrateur/main.py @@ -108,15 +108,6 @@ def on_microwave_change(state: MicrowaveState, field: MicrowaveStateFields): # Send to LoRa device if state changed lora.send_reliable(payloads.lora_microwave_state(state.state), max_retries=5) - if field == MicrowaveStateFields.COOKING_STATE: - update_lcd_microwave_count() - if state.cooking_state in (CookingStates.DONE, CookingStates.STIRRING_REQUIRED, CookingStates.ALERT): - # Trigger buzzer for user attention - beats = 5 if state.cooking_state == CookingStates.ALERT else (1 if state.cooking_state == CookingStates.STIRRING_REQUIRED else 3) - buzzer.buzzer_siren(beatsNb=beats) - elif state.cooking_state == CookingStates.DONE and state.state == MicrowaveState.COOKING: - state.set_state(MicrowaveState.DONE) - print(f"[{state.microwave_id}] Cooking finished. Waiting for user to remove dish.") def set_cloud_alert(state: bool): """Setter for cloud_alert that triggers a display update when changed.""" @@ -331,6 +322,20 @@ async def process_messages_task(): data = msg["data"] if source == "LoRa": + if "new_cooking_state" in data.get("data", {}): + mw_id = data["data"].get("id") + n_state = data["data"].get("new_cooking_state") + print(f"[LoRa] Microwave {mw_id} state changed to: {n_state}") + + microwave_states[mw_id].set_cooking_state(n_state) + update_lcd_microwave_count() # Update the LCD with new microwave count + + if n_state in (CookingStates.DONE, CookingStates.STIRRING_REQUIRED, CookingStates.ALERT): + beats = 5 if n_state == CookingStates.ALERT else (1 if n_state == CookingStates.STIRRING_REQUIRED else 3) + buzzer.buzzer_siren(beatsNb=beats) + if n_state == CookingStates.IDLE and microwave_states.get(mw_id).state == MicrowaveState.COOKING: + microwave_states[mw_id].set_state(MicrowaveState.DONE) + print(f"[{mw_id}] Cooking finished. Waiting for user to remove dish.") if "action" in data.get("data", {}): if type(data["data"]) != dict: print(f"[LoRa] Invalid data format received: {data['data']}")