Files
gree-controller/src/models/temporary_thermostat.rs
T

109 lines
4.9 KiB
Rust

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemporaryQuickThermostat {
/// now | delay | at. `started_at` is the effective start instant and may be in the future.
#[serde(default = "default_temporary_start_kind")]
pub start_kind: String,
/// duration | until | temperature_reached | temperature_stable | schedule_boundary
pub finish_kind: String,
/// Effective start instant. Future values mean the temporary thermostat is scheduled
/// but does not yet own the zone or block normal schedules/automations.
pub started_at: DateTime<Utc>,
/// Set when the controller actually activates ownership. Kept separate from started_at
/// so a delayed session can survive restarts without being mistaken for an active one.
#[serde(default)]
pub activated_at: Option<DateTime<Utc>>,
/// Explicit lifecycle state: scheduled | waiting_master | paused_manual | active.
#[serde(default = "default_temporary_state")]
pub state: String,
/// 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>,
/// within | at_or_below | at_or_above
#[serde(default)]
pub temperature_operator: Option<String>,
#[serde(default = "default_temporary_tolerance")]
pub tolerance_c: f64,
/// Continuous in-condition time required by temperature_stable.
#[serde(default)]
pub hold_seconds: u64,
/// 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>,
/// Group custom target received while the temporary thermostat owns the zone.
#[serde(default)]
pub deferred_setpoint: Option<f64>,
/// Optional fail-safe for temperature-based modes.
#[serde(default)]
pub safety_expires_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemporaryQuickThermostatRequest {
#[serde(default = "default_temporary_start_kind")]
pub start_kind: String,
#[serde(default)]
pub start_delay_minutes: Option<u64>,
#[serde(default)]
pub start_at: Option<DateTime<Utc>>,
pub finish_kind: String,
#[serde(default)]
pub duration_minutes: Option<u64>,
#[serde(default)]
pub until: Option<DateTime<Utc>>,
#[serde(default)]
pub target_temperature: Option<f64>,
#[serde(default)]
pub temperature_operator: Option<String>,
#[serde(default)]
pub tolerance_c: Option<f64>,
#[serde(default)]
pub hold_minutes: Option<u64>,
#[serde(default)]
pub max_duration_minutes: Option<u64>,
}