Fix global
This commit is contained in:
@@ -205,7 +205,7 @@ def cooking_state_temperature_provider():
|
|||||||
return (0.0, 0.0)
|
return (0.0, 0.0)
|
||||||
|
|
||||||
def cooking_state_on_state_change(state):
|
def cooking_state_on_state_change(state):
|
||||||
global cooking_start_time
|
global cooking_start_time, uart_device
|
||||||
print(f"[CookingState] State changed to: {state.state}")
|
print(f"[CookingState] State changed to: {state.state}")
|
||||||
|
|
||||||
if state.paused or state.state in (cookingState.CookingStates.DONE, cookingState.CookingStates.IDLE, cookingState.CookingStates.ALERT):
|
if state.paused or state.state in (cookingState.CookingStates.DONE, cookingState.CookingStates.IDLE, cookingState.CookingStates.ALERT):
|
||||||
@@ -214,7 +214,7 @@ def cooking_state_on_state_change(state):
|
|||||||
magnetron_led.on()
|
magnetron_led.on()
|
||||||
|
|
||||||
# Send state updates to WiFi board and Orchestrator
|
# Send state updates to WiFi board and Orchestrator
|
||||||
if uart_device:
|
if uart_device != None:
|
||||||
uart_device.send_as_command(UARTCommand(UARTCommandType.COOKING_STATE_UPDATE, {"state": state.state}))
|
uart_device.send_as_command(UARTCommand(UARTCommandType.COOKING_STATE_UPDATE, {"state": state.state}))
|
||||||
|
|
||||||
# Send LoRa update with start time and remaining time if beginning cooking process
|
# Send LoRa update with start time and remaining time if beginning cooking process
|
||||||
@@ -347,6 +347,8 @@ async def lora_process_task():
|
|||||||
alert.timestamp = data.get("timestamp", time.time())
|
alert.timestamp = data.get("timestamp", time.time())
|
||||||
alert_manager.add_alert(alert)
|
alert_manager.add_alert(alert)
|
||||||
microwave_state = MicrowaveState.ALERT
|
microwave_state = MicrowaveState.ALERT
|
||||||
|
if cooking_state is not None:
|
||||||
|
cooking_state.set_state(cookingState.CookingStates.ALERT)
|
||||||
|
|
||||||
elif action == LoraCommands.MICROVAVE_STATE_UPDATE:
|
elif action == LoraCommands.MICROVAVE_STATE_UPDATE:
|
||||||
new_state = data.get("new_microwave_state")
|
new_state = data.get("new_microwave_state")
|
||||||
@@ -356,7 +358,8 @@ async def lora_process_task():
|
|||||||
if new_state not in (MicrowaveState.ALERT): # Not alert so we can show the error
|
if new_state not in (MicrowaveState.ALERT): # Not alert so we can show the error
|
||||||
update_screen()
|
update_screen()
|
||||||
if new_state == MicrowaveState.IDLE:
|
if new_state == MicrowaveState.IDLE:
|
||||||
cooking_state = None
|
if cooking_state is not None:
|
||||||
|
cooking_state.set_state(cookingState.CookingStates.IDLE)
|
||||||
await asyncio.sleep_ms(20)
|
await asyncio.sleep_ms(20)
|
||||||
|
|
||||||
await asyncio.sleep_ms(100)
|
await asyncio.sleep_ms(100)
|
||||||
|
|||||||
Reference in New Issue
Block a user