From 2df05fd6843ff166101fdfec98d34f0c49b98c55 Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Thu, 6 Aug 2026 15:19:54 +0200 Subject: [PATCH] Fix reset dish state and debug values --- orchestrateur/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/orchestrateur/main.py b/orchestrateur/main.py index 6653d47..b376d85 100644 --- a/orchestrateur/main.py +++ b/orchestrateur/main.py @@ -230,6 +230,9 @@ async def request_cloud_cooking_plan(microwave_id, sensors_data): print(f"[{microwave_id}] Cloud Plan Received! Starting microwave: {c_time}s @ {c_power}W") cloud_alert = False # Reset alert flag on success microwave_states[microwave_id] = MicrowaveState.COOKING + if config.DEBUG: + c_time = min(c_time, 10) # Limit to 10s for debug + c_temp = min(c_temp, 50) # Limit to 50°C for debug mqtt_client.publish( config.MQTT_TOPIC_COOKING, payloads.mqtt_cooking_config(microwave_id, c_time, c_power, c_temp), @@ -306,8 +309,8 @@ async def get_filtered_dish_height(samples=3, delay=0.04): valid_samples = [] for _ in range(samples): h = await asyncio.to_thread(ultrasonicRanger.get_dish_height) - # Discard 0.0 or near-zero timeout glitches - if h is not None and h > 0.5: + # Discard negative glitches + if h is not None and h >= 0.0: valid_samples.append(h) await asyncio.sleep(delay)