This commit is contained in:
Mateusz Gruszczyński committed 2026-10-17 20:00:28 +02:00
1 parent ccf85a2fb8
commit f376f0a7b6
32 files changed
+312 -114

No files matched your search

+28 -5
View File
@@ -3,6 +3,17 @@ mod tests {
use super::*;
use chrono::TimeZone;
#[test]
fn heat_coasting_modulates_setpoint_without_power_cycle() {
assert!(!heat_coasting_next_state(false, "heat", 19.8, 20.8, 0.9));
assert!(heat_coasting_next_state(false, "heat", 19.9, 20.8, 0.9));
assert!(heat_coasting_next_state(true, "heat", 19.6, 20.8, 0.9));
assert!(!heat_coasting_next_state(true, "heat", 19.5, 20.8, 0.9));
assert!(!heat_coasting_next_state(true, "heat", 21.0, 20.8, 0.0));
assert!(!heat_coasting_next_state(true, "cool", 21.0, 20.8, 0.9));
assert_eq!(round_device_setpoint("heat", false, 20.8 - 5.0), 16.0);
}
#[test]
fn thermostat_target_normalization_preserves_tenths() {
assert!((normalize_thermostat_target(24.2) - 24.2).abs() < 1e-9);
@@ -242,7 +253,15 @@ mod tests {
..Default::default()
};
assert!(flow_zone_action_already_satisfied(
&zone, false, 0, 0, Some("custom"), &on
&zone, false, 0, 0, Some("custom"), &on, None, None
));
assert!(!flow_zone_action_already_satisfied(
&zone, false, 0, 0, Some("custom"), &on, Some(1.1), Some(5.0)
));
zone.heat_anticipation_c = 1.1;
zone.standby_offset_c = 5.0;
assert!(flow_zone_action_already_satisfied(
&zone, false, 0, 0, Some("custom"), &on, Some(1.1), Some(5.0)
));
zone.manual_preset = None;
@@ -257,10 +276,10 @@ mod tests {
..Default::default()
};
assert!(flow_zone_action_already_satisfied(
&zone, false, 0, 0, Some("auto"), &off
&zone, false, 0, 0, Some("auto"), &off, None, None
));
assert!(!flow_zone_action_already_satisfied(
&zone, true, 0, 0, Some("auto"), &off
&zone, true, 0, 0, Some("auto"), &off, None, None
));
}
@@ -279,10 +298,10 @@ mod tests {
..Default::default()
};
assert!(!flow_zone_action_already_satisfied(
&zone, true, 0, 0, Some("custom"), &action
&zone, true, 0, 0, Some("custom"), &action, None, None
));
assert!(flow_zone_action_already_satisfied(
&zone, true, 1, 0, Some("custom"), &action
&zone, true, 1, 0, Some("custom"), &action, None, None
));
}
@@ -547,6 +566,8 @@ mod tests {
last_trigger_trace: vec![],
action_zone_id: None,
action_zone_preset: None,
action_zone_heat_anticipation_c: None,
action_zone_standby_offset_c: None,
action_ha_domain: None,
action_ha_service: None,
action_ha_entity_id: None,
@@ -589,6 +610,8 @@ mod tests {
min_on_seconds: 180,
min_off_seconds: 180,
min_adjust_seconds: 120,
heat_anticipation_c: 0.0,
heat_coasting: false,
standby_offset_c: 2.0,
smart_fan: true,
sensor_source: source.into(),