Send alerts and reset
This commit is contained in:
@@ -104,7 +104,7 @@ def on_microwave_change(state: MicrowaveState, field: MicrowaveStateFields):
|
||||
if field != MicrowaveStateFields.STATE: # No external screen or lcd uses this field, so we can skip updates for it
|
||||
notify_display_update()
|
||||
|
||||
if field == MicrowaveStateFields.STATE and state.state in (MicrowaveState.DONE, MicrowaveState.ANALYZING, MicrowaveState.WAITING_FOR_CLOUD, MicrowaveState.ALERT):
|
||||
if field == MicrowaveStateFields.STATE and state.state in (MicrowaveState.IDLE, MicrowaveState.DONE, MicrowaveState.ANALYZING, MicrowaveState.WAITING_FOR_CLOUD, MicrowaveState.ALERT):
|
||||
# Send to LoRa device if state changed
|
||||
lora.send_reliable(payloads.lora_microwave_state(state.state), max_retries=5)
|
||||
|
||||
@@ -457,11 +457,11 @@ button.start_button_monitoring_thread()
|
||||
# --- Alert manager ---
|
||||
alert_manager = None
|
||||
|
||||
def on_new_alert(alert: Alert):
|
||||
async def on_new_alert(alert: Alert):
|
||||
# Sends to cloud server
|
||||
alert_dict = alert.to_dict()
|
||||
|
||||
logs_list = asyncio.run(get_systemd_logs(lines=200, service_name="smartwave"))
|
||||
logs_list = await get_systemd_logs(lines=200, service_name="smartwave")
|
||||
|
||||
payload = {
|
||||
"orchestrator_id": DEVICE_ID,
|
||||
@@ -485,6 +485,7 @@ def on_new_alert(alert: Alert):
|
||||
print(f"[Alert Handling] Sending alert to LoRa device: {payload}")
|
||||
if lora.send_reliable(payload):
|
||||
microwave_states["2"].set_cooking_state(CookingStates.ALERT)
|
||||
buzzer.buzzer_siren(beatsNb=5)
|
||||
|
||||
# --- HARDWARE CONTROLLERS ---
|
||||
def _stop_hardware(microwave_id: str):
|
||||
|
||||
Reference in New Issue
Block a user