v0.9.7
This commit is contained in:
+7
-1
@@ -1,7 +1,7 @@
|
||||
use std::{collections::HashMap, sync::{Arc, atomic::AtomicBool}, time::Instant};
|
||||
use chrono::Utc;
|
||||
use serde_json::Value;
|
||||
use tokio::sync::{broadcast, Mutex, OwnedMutexGuard, RwLock};
|
||||
use tokio::sync::{broadcast, Mutex, Notify, OwnedMutexGuard, RwLock};
|
||||
use crate::{config::Config, db::Db, models::{ApiEvent, RuntimeSettings}, protocol::GreeClient};
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -17,6 +17,8 @@ pub struct AppState {
|
||||
/// Thermostat/automation control stays passive until every enabled device has had
|
||||
/// one startup poll, preventing stale persisted device state from causing restart commands.
|
||||
pub initial_device_sync_complete: Arc<AtomicBool>,
|
||||
/// 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<()>>>>>,
|
||||
pub started: Instant,
|
||||
}
|
||||
@@ -30,6 +32,10 @@ impl AppState {
|
||||
lock.lock_owned().await
|
||||
}
|
||||
|
||||
pub fn wake_zone_control(&self) {
|
||||
self.zone_control_wakeup.notify_one();
|
||||
}
|
||||
|
||||
pub fn broadcast(&self, event: impl Into<String>, data: Value) {
|
||||
let _ = self.events.send(ApiEvent {
|
||||
event: event.into(),
|
||||
|
||||
Reference in New Issue
Block a user