v0.10.0
This commit is contained in:
@@ -286,16 +286,30 @@ async fn flow_leaf_observation(
|
||||
overrides: &HashMap<String, Value>,
|
||||
) -> Result<(bool, Value), AppError> {
|
||||
let mut resolved_kind = condition.kind.as_str();
|
||||
let mut resolved_config: Option<&Value> = None;
|
||||
let mut resolved_config: Option<Value> = None;
|
||||
if condition.kind == "shared_input" {
|
||||
let input_id = condition.config.get("input_id").and_then(Value::as_str).unwrap_or("");
|
||||
let Some(shared) = settings.home_assistant.flow_inputs.iter().find(|item| item.id == input_id) else {
|
||||
return Ok((false, json!({"error": "missing_shared_input", "input_id": input_id})));
|
||||
};
|
||||
resolved_kind = shared.kind.as_str();
|
||||
resolved_config = Some(&shared.config);
|
||||
let mut config = shared.config.clone();
|
||||
if matches!(shared.kind.as_str(),
|
||||
"outdoor_temperature" | "device_temperature" | "zone_temperature" |
|
||||
"ha_state" | "ha_numeric" | "ha_attribute" | "house_mode" |
|
||||
"device_state" | "zone_state" | "group_state") {
|
||||
let Some(operator) = condition.config.get("operator").and_then(Value::as_str).map(str::trim).filter(|value| !value.is_empty()) else {
|
||||
return Ok((false, json!({"error": "missing_shared_input_operator", "input_id": input_id})));
|
||||
};
|
||||
let Some(map) = config.as_object_mut() else {
|
||||
return Ok((false, json!({"error": "invalid_shared_input_config", "input_id": input_id})));
|
||||
};
|
||||
map.insert("operator".into(), Value::String(operator.to_string()));
|
||||
map.insert("value".into(), condition.config.get("value").cloned().unwrap_or(Value::Null));
|
||||
}
|
||||
resolved_config = Some(config);
|
||||
}
|
||||
let c = resolved_config.unwrap_or(&condition.config);
|
||||
let c = resolved_config.as_ref().unwrap_or(&condition.config);
|
||||
let override_value = overrides.get(&condition.id).cloned();
|
||||
let (matched, actual) = match resolved_kind {
|
||||
"weekday" => {
|
||||
@@ -497,12 +511,13 @@ pub async fn evaluate_flow_conditions_trace(
|
||||
};
|
||||
values.insert(condition.id.clone(), matched);
|
||||
final_id = Some(condition.id.clone());
|
||||
let expected = condition.config.get("value").cloned();
|
||||
trace.push(json!({
|
||||
"node_id": condition.id,
|
||||
"kind": condition.kind,
|
||||
"matched": matched,
|
||||
"actual": actual,
|
||||
"expected": condition.config.get("value"),
|
||||
"expected": expected,
|
||||
"inputs": condition.inputs
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user