This commit is contained in:
Mateusz Gruszczyński
2026-09-04 11:30:48 +02:00
parent 236540e0f0
commit 9b4fafdfa6
14 changed files with 262 additions and 62 deletions
+4
View File
@@ -161,6 +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();
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
}));
@@ -181,6 +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.log("error", "automation.error", &err.to_string(), json!({"automation_id": item.id, "flow_id": item.flow_id, "flow_node_id": item.flow_node_id}));
}
}