This commit is contained in:
Mateusz Gruszczyński
2026-09-04 13:44:18 +02:00
parent 2882fd3523
commit 63e6e13a5d
16 changed files with 89 additions and 53 deletions
+22 -1
View File
@@ -43,13 +43,15 @@ fn alert_type_enabled(cfg: &NotificationSettings, kind: &str) -> bool {
if kind.starts_with("automation.") {
return types.automation;
}
if kind == "zone.sensor_discrepancy" {
return types.sensor_discrepancy;
}
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"
@@ -142,6 +144,25 @@ pub async fn dispatch(
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sensor_discrepancy_has_its_own_notification_toggle() {
let mut cfg = NotificationSettings::default();
cfg.alert_types.control_errors = true;
cfg.alert_types.sensor_discrepancy = false;
assert!(!alert_type_enabled(&cfg, "zone.sensor_discrepancy"));
assert!(alert_type_enabled(&cfg, "zone.action_error"));
cfg.alert_types.control_errors = false;
cfg.alert_types.sensor_discrepancy = true;
assert!(alert_type_enabled(&cfg, "zone.sensor_discrepancy"));
assert!(!alert_type_enabled(&cfg, "zone.action_error"));
}
}
async fn send_pushover(
state: &AppState,
cfg: &NotificationSettings,