This commit is contained in:
Mateusz Gruszczyński
2026-08-29 22:07:54 +02:00
parent 930cb7b1e1
commit 2383526a83
16 changed files with 296 additions and 79 deletions
+18 -1
View File
@@ -12,8 +12,25 @@ fn important_kind(kind: &str) -> bool {
"device.communication_error")
}
fn alert_type_enabled(cfg: &NotificationSettings, kind: &str) -> bool {
let types = &cfg.alert_types;
if kind == "ha.sensor_stale" { return types.stale_sensor; }
if kind.starts_with("ha.sensor_") { return types.sensor_errors; }
if matches!(kind, "device.offline" | "device.communication_error" | "device.command_unconfirmed") { return types.communication; }
if kind == "zone.target_timeout" { return types.target_timeout; }
if kind.starts_with("automation.") { return types.automation; }
if matches!(kind,
"zone.action_error" | "zone.mode_change_off_error" | "zone.local_power_error" |
"zone.device_missing" | "zone.sensor_discrepancy" |
"zone.temporary_quick_thermostat_cancelled" | "zone.temporary_quick_thermostat_poweroff_error" |
"group.power_error"
) { return types.control_errors; }
if important_kind(kind) { return types.important_events; }
types.other
}
fn should_send(cfg: &NotificationSettings, level: &str, kind: &str) -> bool {
if !cfg.enabled { return false; }
if !cfg.enabled || !alert_type_enabled(cfg, kind) { return false; }
if level == "error" || level == "warn" { return true; }
cfg.mode == "important" && important_kind(kind)
}