This commit is contained in:
Mateusz Gruszczyński
2026-08-28 12:56:36 +02:00
parent 556a031358
commit 615b2836b7
12 changed files with 1279 additions and 331 deletions
+52 -2
View File
@@ -39,6 +39,7 @@ fn default_night_max_fan_speed() -> u8 { 1 }
fn default_group_power_enabled() -> bool { true }
fn default_temporary_tolerance() -> f64 { 0.3 }
fn default_temporary_start_kind() -> String { "now".into() }
fn default_temporary_state() -> String { "scheduled".into() }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Device {
@@ -284,13 +285,44 @@ pub struct TemporaryQuickThermostat {
/// so a delayed session can survive restarts without being mistaken for an active one.
#[serde(default)]
pub activated_at: Option<DateTime<Utc>>,
/// Zone automation enabled-state from before the temporary session. A temporary
/// Explicit lifecycle state: scheduled | waiting_master | paused_manual | active.
#[serde(default = "default_temporary_state")]
pub state: String,
/// Fresh sessions use generation >= 1. Generation 0 identifies legacy payloads that
/// predate explicit activated_at/state semantics and may use the compatibility fallback.
#[serde(default)]
pub generation: u64,
/// Heat/cool mode captured when ownership really starts. It keeps a temporary session
/// independent from later whole-house mode changes until hand-back.
#[serde(default)]
pub active_mode: Option<String>,
/// Zone automation enabled-state from immediately before the actual takeover. A delayed
/// Quick Thermostat may run even when normal automation was disabled, then restore it.
#[serde(default)]
pub restore_zone_enabled: Option<bool>,
/// Ordinary local Quick Thermostat state hidden underneath this higher-priority session.
/// It is captured at actual takeover and restored on hand-back.
#[serde(default)]
pub restore_local_thermostat_power: Option<bool>,
#[serde(default)]
pub restore_local_thermostat_resume_at: Option<DateTime<Utc>>,
#[serde(default)]
pub restore_local_thermostat_zone_enabled: Option<bool>,
#[serde(default)]
pub restore_manual_preset: Option<String>,
#[serde(default)]
pub restore_manual_setpoint: Option<f64>,
#[serde(default)]
pub restore_manual_override_until: Option<DateTime<Utc>>,
/// Hard end for duration/until/schedule-boundary modes.
#[serde(default)]
pub expires_at: Option<DateTime<Utc>>,
/// Relative durations are retained so delayed/manual-waiting sessions start their clocks
/// when ownership actually begins rather than at the originally requested wall-clock time.
#[serde(default)]
pub duration_seconds: Option<u64>,
#[serde(default)]
pub safety_duration_seconds: Option<u64>,
/// Temperature condition used by reached/stable modes.
#[serde(default)]
pub temperature_target: Option<f64>,
@@ -302,9 +334,23 @@ pub struct TemporaryQuickThermostat {
/// Continuous in-condition time required by temperature_stable.
#[serde(default)]
pub hold_seconds: u64,
/// Set only while the latest room samples continuously satisfy the condition.
/// Set only while fresh consecutive room samples continuously satisfy the condition.
#[serde(default)]
pub condition_started_at: Option<DateTime<Utc>>,
/// Timestamp of the last fresh sensor sample used by the condition evaluator. This
/// prevents cached samples and controller downtime from counting as continuous hold time.
#[serde(default)]
pub condition_last_observed_at: Option<DateTime<Utc>>,
/// Start of a higher-priority direct/manual pause. Active deadlines are shifted by this
/// pause when ownership returns so hidden manual time is never consumed by the session.
#[serde(default)]
pub paused_at: Option<DateTime<Utc>>,
/// Group/house climate changes received while this session owns the zone. They are
/// applied only after hand-back instead of partially overwriting the active session.
#[serde(default)]
pub deferred_mode: Option<String>,
#[serde(default)]
pub deferred_preset: Option<String>,
/// Optional fail-safe for temperature-based modes.
#[serde(default)]
pub safety_expires_at: Option<DateTime<Utc>>,
@@ -425,6 +471,10 @@ pub struct Zone {
/// the current group/schedule state is evaluated again.
#[serde(default)]
pub local_thermostat_resume_at: Option<DateTime<Utc>>,
/// Zone automation enabled-state from before an ordinary local Quick Thermostat takeover.
/// Kept separate from the temporary-session restore state.
#[serde(default)]
pub local_thermostat_restore_zone_enabled: Option<bool>,
/// Separate, user-defined temporary Quick Thermostat session. This is intentionally
/// independent from local_thermostat_resume_at, which belongs to the local-OFF
/// hand-back mechanism.