v0.13.6
This commit is contained in:
@@ -95,7 +95,10 @@ pub struct NotificationAlertTypes {
|
||||
/// Automation execution errors and conflicts.
|
||||
#[serde(default = "default_true")]
|
||||
pub automation: bool,
|
||||
/// Thermostat/group/device control failures and sensor discrepancies.
|
||||
/// GREE room temperature differs from the configured Home Assistant sensor beyond the zone limit.
|
||||
#[serde(default = "default_true")]
|
||||
pub sensor_discrepancy: bool,
|
||||
/// Thermostat/group/device control failures.
|
||||
#[serde(default = "default_true")]
|
||||
pub control_errors: bool,
|
||||
/// Informational state changes sent when notification mode is "important".
|
||||
@@ -114,6 +117,7 @@ impl Default for NotificationAlertTypes {
|
||||
communication: true,
|
||||
target_timeout: true,
|
||||
automation: true,
|
||||
sensor_discrepancy: true,
|
||||
control_errors: true,
|
||||
important_events: true,
|
||||
other: true,
|
||||
|
||||
+22
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user