UART commands for getting dish temperature

This commit is contained in:
2026-08-07 16:14:43 +02:00
parent ec9be8ac30
commit 053964e56c
5 changed files with 60 additions and 10 deletions
+7 -5
View File
@@ -195,14 +195,16 @@ async def uart_task():
try:
cmd = uart_device.read_as_command()
if cmd:
if cmd and hasattr(cmd, "command_type"):
print("[UART] Command received from LoRa board:", cmd.command_type, cmd.payload)
if (
hasattr(cmd, "command_type")
and cmd.command_type == UARTCommandType.COOKING_STATE_UPDATE
):
if cmd.command_type == UARTCommandType.COOKING_STATE_UPDATE:
if cooking_state:
cooking_state.set_state(cmd.payload.get("state"))
elif cmd.command_type == UARTCommandType.TEMPERATURE_REQUEST:
uart_device.send_as_command(UARTCommand(UARTCommandType.TEMPERATURE_RESPONSE, payloads.lora_sensor_data(
mlx_temperature_sensor.read_object_temp() if mlx_temperature_sensor else 0,
mlx_temperature_sensor.read_ambient_temp() if mlx_temperature_sensor else 0
)))
except Exception as e:
print("[UART Task] Error reading command:", e)