v0.8.10
This commit is contained in:
+18
-1
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user