This commit is contained in:
Mateusz Gruszczyński
2026-09-01 14:18:00 +02:00
parent 97c26c67b6
commit d0346dd797
33 changed files with 327 additions and 270 deletions
+7 -4
View File
@@ -8,11 +8,13 @@ async fn update_settings(State(state): State<AppState>, Json(mut input): Json<Ru
let _house_guard = state.lock_house_operation().await;
let _cycle_guard = state.lock_zone_control_cycle().await;
let old = state.settings.read().await.clone();
if input.house_power_enabled != old.house_power_enabled || input.house_mode != old.house_mode {
if input.house_mode != old.house_mode {
return Err(AppError::BadRequest(
"house_power_enabled and house_mode must be changed through the House Control API".into(),
"house_mode must be changed through the House Control API".into(),
));
}
// Compatibility-only field: global ON/OFF is one-shot and never disables automation.
input.house_power_enabled = true;
input.poll_interval_seconds = input.poll_interval_seconds.clamp(2, 3600);
input.zone_interval_seconds = input.zone_interval_seconds.clamp(2, 3600);
input.discovery_timeout_ms = input.discovery_timeout_ms.clamp(300, 30_000);
@@ -274,6 +276,8 @@ fn validate_configuration_export(export: &ConfigurationExport) -> Result<(), App
fn sanitize_configuration_runtime(export: &mut ConfigurationExport) {
let now = Utc::now();
// Do not restore the pre-v0.9.3 persistent global-OFF gate from backups.
export.settings.house_power_enabled = true;
for device in &mut export.devices {
device.power = false;
device.mode = "cool".into();
@@ -420,8 +424,7 @@ async fn import_settings(State(state): State<AppState>, Json(mut export): Json<C
let controllable_devices: std::collections::HashSet<String> = export.zones.iter()
.filter(|zone| {
let effective_mode = if zone.inherit_house_mode { export.settings.house_mode.as_str() } else { zone.mode.as_str() };
export.settings.house_power_enabled
&& zone.enabled
zone.enabled
&& effective_mode != "off"
})
.map(|zone| zone.device_id.clone())