This commit is contained in:
Mateusz Gruszczyński
2026-08-30 09:50:03 +02:00
parent 2383526a83
commit fbc66b0c26
22 changed files with 2911 additions and 1632 deletions
+14 -1
View File
@@ -208,9 +208,13 @@ async fn bootstrap(State(state): State<AppState>) -> Result<Json<Value>, AppErro
async fn build_bootstrap(state: &AppState) -> Result<Value, AppError> {
let settings = state.settings.read().await.clone();
let devices = state.db.list_devices()?;
let device_count = devices.len();
let online_count = devices.iter().filter(|value| value.online).count();
let simulator_count = devices.iter().filter(|value| value.simulated).count();
let (received_frames_total, received_frames_by_device) = state.gree.received_frame_stats();
Ok(json!({
"devices": state.db.list_devices()?,
"devices": devices,
"zones": state.db.list_zones()?,
"groups": state.db.list_groups()?,
"schedules": state.db.list_schedules()?,
@@ -223,6 +227,13 @@ async fn build_bootstrap(state: &AppState) -> Result<Value, AppError> {
"uptime_seconds": state.started.elapsed().as_secs(),
"auth_required": !state.config.app_token.trim().is_empty(),
"control_ready": state.initial_device_sync_complete.load(Ordering::Acquire),
"database": state.config.database.display().to_string(),
"device_count": device_count,
"online_count": online_count,
"simulator_count": simulator_count,
"bind": state.config.bind.to_string(),
"base_path": if state.config.base_path.is_empty() { "/" } else { state.config.base_path.as_str() },
"gree_interface": if state.config.gree_interface.trim().is_empty() { "auto" } else { state.config.gree_interface.trim() },
"gree_received_frames": received_frames_total,
"gree_received_frames_by_device": received_frames_by_device,
}
@@ -240,7 +251,9 @@ async fn system_info(State(state): State<AppState>) -> Result<Json<Value>, AppEr
"online_count": devices.iter().filter(|v| v.online).count(),
"simulator_count": devices.iter().filter(|v| v.simulated).count(),
"control_ready": state.initial_device_sync_complete.load(Ordering::Acquire),
"auth_required": !state.config.app_token.trim().is_empty(),
"bind": state.config.bind.to_string(),
"base_path": if state.config.base_path.is_empty() { "/" } else { state.config.base_path.as_str() },
"gree_interface": if state.config.gree_interface.trim().is_empty() { "auto" } else { state.config.gree_interface.trim() },
"gree_received_frames": received_frames_total,
"gree_received_frames_by_device": received_frames_by_device,