UART commands for getting dish temperature
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user