v0.13.4
This commit is contained in:
+1
-1
@@ -543,7 +543,7 @@ fn resolve_temporary_target(
|
||||
"temporary thermostat target must be between 8 and 30 C".into(),
|
||||
));
|
||||
}
|
||||
let target = (target * 2.0).round() / 2.0;
|
||||
let target = engine::normalize_thermostat_target(target);
|
||||
let tolerance_mode = if zone.effective_mode.is_empty() {
|
||||
zone.mode.as_str()
|
||||
} else {
|
||||
|
||||
@@ -868,7 +868,7 @@ async fn apply_flow_zone_action(state: &AppState, zone_id: &str, preset: Option<
|
||||
"auto" => { zone.manual_preset = None; zone.manual_setpoint = None; zone.manual_override_until = None; }
|
||||
"custom" => {
|
||||
let target = action.target_temperature.ok_or_else(|| AppError::BadRequest("Flow custom thermostat action has no target".into()))?;
|
||||
zone.manual_preset = Some("custom".into()); zone.manual_setpoint = Some((target.clamp(8.0,30.0)*2.0).round()/2.0);
|
||||
zone.manual_preset = Some("custom".into()); zone.manual_setpoint = Some(normalize_thermostat_target(target.clamp(8.0, 30.0)));
|
||||
zone.manual_override_until = next_schedule_boundary_utc(&zone.id, &state.db.list_schedules()?, Local::now());
|
||||
}
|
||||
value @ ("comfort" | "sleep" | "away") => {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
pub(crate) fn normalize_thermostat_target(value: f64) -> f64 {
|
||||
(value * 10.0).round() / 10.0
|
||||
}
|
||||
|
||||
fn profile_setpoint(zone: &Zone, preset: &str, mode: &str) -> f64 {
|
||||
if zone.profile_version == 0 && preset == "comfort" {
|
||||
return zone.setpoint;
|
||||
|
||||
@@ -3,6 +3,14 @@ mod tests {
|
||||
use super::*;
|
||||
use chrono::TimeZone;
|
||||
|
||||
#[test]
|
||||
fn thermostat_target_normalization_preserves_tenths() {
|
||||
assert!((normalize_thermostat_target(24.2) - 24.2).abs() < 1e-9);
|
||||
assert!((normalize_thermostat_target(24.24) - 24.2).abs() < 1e-9);
|
||||
assert!((normalize_thermostat_target(24.25) - 24.3).abs() < 1e-9);
|
||||
assert!((normalize_thermostat_target(24.5) - 24.5).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn global_ha_sensor_stale_timeout_is_used_for_default_zone_value() {
|
||||
assert_eq!(effective_sensor_stale_after_seconds(300, 600), 600);
|
||||
|
||||
@@ -236,7 +236,7 @@ async fn apply_automatic_device_action(
|
||||
}
|
||||
}
|
||||
if let Some(target) = command.target_temperature {
|
||||
zone.manual_setpoint = Some((target.clamp(8.0, 30.0) * 2.0).round() / 2.0);
|
||||
zone.manual_setpoint = Some(normalize_thermostat_target(target.clamp(8.0, 30.0)));
|
||||
zone.manual_override_until =
|
||||
next_schedule_boundary_utc(&zone.id, &state.db.list_schedules()?, Local::now());
|
||||
domain_changed = true;
|
||||
|
||||
Reference in New Issue
Block a user