This commit is contained in:
Mateusz Gruszczyński
2026-08-27 16:38:51 +02:00
parent 7102d05cb3
commit ba61cb77b1
19 changed files with 406 additions and 109 deletions
+10 -1
View File
@@ -2,7 +2,13 @@ use std::{collections::HashMap, sync::{Arc, atomic::AtomicBool}, time::Instant};
use chrono::Utc;
use serde_json::Value;
use tokio::sync::{broadcast, Mutex, Notify, OwnedMutexGuard, RwLock};
use crate::{config::Config, db::Db, models::{ApiEvent, RuntimeSettings}, protocol::GreeClient};
use crate::{config::Config, db::Db, models::{ApiEvent, DeviceCommand, RuntimeSettings}, protocol::GreeClient};
#[derive(Debug, Clone)]
pub(crate) struct PendingControllerCommand {
pub command: DeviceCommand,
pub expires_at: Instant,
}
#[derive(Clone)]
pub struct AppState {
@@ -20,6 +26,9 @@ pub struct AppState {
/// Explicit thermostat changes wake the regulator instead of waiting for the next fixed interval.
pub zone_control_wakeup: Arc<Notify>,
pub(crate) device_operation_locks: Arc<Mutex<HashMap<String, Arc<Mutex<()>>>>>,
/// Short-lived expected climate state from controller-originated commands. It prevents
/// a delayed GREE status update from being mistaken for remote/manual takeover.
pub(crate) pending_controller_commands: Arc<Mutex<HashMap<String, PendingControllerCommand>>>,
pub started: Instant,
}