Beginning of cooking cycle
Build, push image, and notify Watchtower / build-image (push) Successful in 1m21s
Build, push image, and notify Watchtower / notify (push) Successful in 17s

This commit is contained in:
2026-07-31 21:50:42 +02:00
parent 8ac5db22c1
commit 7299a50198
11 changed files with 552 additions and 86 deletions
+7 -9
View File
@@ -142,7 +142,7 @@ def read_sensors_for_cooking(microwave_id):
log(f"\nLecture du capteur Ultrason : {sensor_data['ultrasonic_distance']}")
# Read Temperature and Humidity
temperature, humidity = temp_hum.get_temperature_and_humidity()
temperature, humidity = temp_hum.get_temperature_and_humidity_with_retry()
if temperature is not None and humidity is not None:
log(f"\nLecture du capteur Temp/Hum : {temperature}, {humidity}")
sensor_data["temperature"] = temperature
@@ -170,22 +170,20 @@ def _stop_hardware(microwave_id: str):
"""
Hardware driver stop — halts magnetron/turntable immediately.
"""
log(f"[{microwave_id}] 🛑 Emergency stop issued to hardware.")
print(f"[{microwave_id}] 🛑 Emergency stop issued to hardware.")
# TODO: Add physical hardware stop command here
# e.g., gpio_controller.stop()
def _send_params_to_microwave(microwave_id: str, cook_time_seconds: int, power_level_pct: int, target_temp: float, cancel_event: threading.Event):
def _send_params_to_microwave(microwave_id: str, cook_time: int, power_level: int, target_temp: float, cancel_event: threading.Event):
"""
Triggers physical microwave execution.
"""
if cancel_event.is_set():
return
log(f"[{microwave_id}] ⚡ Starting microwave cooking : {cook_time_seconds}s @ {power_level_pct}W power, target temp {target_temp}°C.")
# TODO: Connect to microwave hardware driver here
# e.g., gpio_controller.start(time=cook_time_seconds, power=power_level_pct)
print(f"[{microwave_id}] Sending microwave {microwave_id} cooking parameters : {cook_time}s @ {power_level}W power, target temp {target_temp}°C.")
mqtt_client.publish(config.MQTT_TOPIC_COOKING, payloads.mqtt_cooking_config(microwave_id, cook_time, power_level, target_temp), qos=config.MQTT_QOS)
def _cooking_worker(microwave_id: str, sensors_data: dict, cancel_event: threading.Event):
"""Worker function executing cloud API calls and hardware triggers."""
@@ -211,9 +209,9 @@ def _cooking_worker(microwave_id: str, sensors_data: dict, cancel_event: threadi
print(f"[{microwave_id}] Job was canceled while waiting for cloud response. Discarding result.")
return
if (response.status_code != 200):
log(f"[{microwave_id}] Cloud API responded with : {response.json()}")
if response.status_code != 200 and response.status_code != 201:
print(f"[{microwave_id}] Cloud API returned error {response.status_code}: {response.json()}")
return
response.raise_for_status()
# 2. Extract Response Parameters