Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c58ae4603e | |||
| e7f6374200 |
+8
-4
@@ -323,6 +323,14 @@ def alert():
|
||||
alert_type = alert_info.get("type", "Unknown")
|
||||
alert_message = alert_info.get("message", "No message provided")
|
||||
|
||||
webex_room_id = None
|
||||
room_link = None
|
||||
room_title = None
|
||||
webex_status = "skipped"
|
||||
sms_sent = False
|
||||
|
||||
if alert_type != "COOKING_SAFETY":
|
||||
|
||||
client_name = f"Unknown Client (Orchestrator {orchestrator_id})" if orchestrator_id else "Unknown Client"
|
||||
client_email = None
|
||||
client_phone = None
|
||||
@@ -343,11 +351,7 @@ def alert():
|
||||
client_email = contact_info.get("email")
|
||||
client_phone = contact_info.get("phone")
|
||||
|
||||
webex_room_id = None
|
||||
room_title = f"Support - {client_name}"
|
||||
room_link = None
|
||||
webex_status = "skipped"
|
||||
sms_sent = False
|
||||
|
||||
three_minutes_ago = datetime.now(timezone.utc) - timedelta(minutes=3)
|
||||
|
||||
|
||||
@@ -346,6 +346,7 @@ async def lora_process_task():
|
||||
if alert:
|
||||
alert.timestamp = data.get("timestamp", time.time())
|
||||
alert_manager.add_alert(alert)
|
||||
microwave_state = MicrowaveState.ALERT
|
||||
|
||||
elif action == LoraCommands.MICROVAVE_STATE_UPDATE:
|
||||
new_state = data.get("new_microwave_state")
|
||||
|
||||
@@ -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.IDLE, 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):
|
||||
# Send to LoRa device if state changed
|
||||
lora.send_reliable(payloads.lora_microwave_state(state.state), max_retries=5)
|
||||
|
||||
@@ -472,7 +472,7 @@ async def on_new_alert(alert: Alert):
|
||||
|
||||
response.raise_for_status()
|
||||
res_json = response.json()
|
||||
print(f"[Alert Handling] Alert sent to cloud: {alert_dict}, Response: {res_json}")
|
||||
log(f"[Alert Handling] Alert sent to cloud: {alert_dict}, Response: {res_json}")
|
||||
|
||||
if not alert.redistributed: # If not redistributed from microwaves
|
||||
# Send the alert to the lora device
|
||||
@@ -480,7 +480,6 @@ async 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):
|
||||
@@ -669,7 +668,7 @@ async def request_cloud_cooking_plan(microwave_id, sensors_data):
|
||||
microwave_states[microwave_id].set_state(MicrowaveState.DONE)
|
||||
|
||||
if not res_json['is_safe']: # The cooking area is not safe, raise an alert
|
||||
alert = Alert(AlertType.COOKING_SAFETY, res_json['warning_message'])
|
||||
alert = Alert(AlertType.COOKING_SAFETY, res_json['warning_message'], redistributed=False)
|
||||
alert_manager.add_alert(alert)
|
||||
else:
|
||||
alert = Alert(AlertType.ERROR, f"Cloud API error for microwave {microwave_id}: {res_json['error']}")
|
||||
|
||||
Reference in New Issue
Block a user