This commit is contained in:
Mateusz Gruszczyński
2026-09-04 11:43:37 +02:00
parent 9b4fafdfa6
commit ade221bb76
16 changed files with 338 additions and 40 deletions
+4 -4
View File
@@ -161,9 +161,9 @@ async fn run_automations(state: &AppState) -> Result<()> {
item.last_fired_at = Some(fired_at);
item.updated_at = Utc::now();
state.db.save_automation(&item)?;
// last_fired_at/next_ready_at are part of ControlPlan.rules. Runtime execution
// does not emit automation.updated, so invalidate the plan directly.
state.invalidate_control_plan();
// Keep connected clients in sync with runtime metadata such as last_fired_at.
// automation.updated also invalidates the materialized control plan.
state.broadcast("automation.updated", serde_json::to_value(&item)?);
state.log("info", "automation.fired", &format!("Automation {} fired", item.name), json!({
"automation_id": item.id, "flow_id": item.flow_id, "flow_node_id": item.flow_node_id, "group_id": item.action_group_id, "device_id": item.action_device_id
}));
@@ -184,7 +184,7 @@ async fn run_automations(state: &AppState) -> Result<()> {
item.last_fired_at = Some(Utc::now());
item.updated_at = Utc::now();
state.db.save_automation(&item)?;
state.invalidate_control_plan();
state.broadcast("automation.updated", serde_json::to_value(&item)?);
state.log("error", "automation.error", &err.to_string(), json!({"automation_id": item.id, "flow_id": item.flow_id, "flow_node_id": item.flow_node_id}));
}
}