use std::{collections::HashMap, sync::atomic::Ordering, time::{Duration, Instant}}; use anyhow::Result; use chrono::{DateTime, Datelike, Local, NaiveTime, Timelike, Utc, Weekday}; use serde_json::{json, Value}; use tokio::time::sleep; use crate::{ error::AppError, home_assistant, influxdb, models::{Automation, AutomationPlanRule, ControlPlan, ControlPlanEvent, Device, DeviceCommand, GroupControlPatch, HaReading, NightModeSettings, Reading, Schedule, TemporaryQuickThermostat, Zone, ZoneControlPlan, ZoneReading}, state::{AppState, PendingControllerCommand}, }; // Functional source split intentionally keeps items in the existing module namespace. include!("engine/runtime.rs"); include!("engine/commands.rs"); include!("engine/polling.rs"); include!("engine/local_thermostat.rs"); include!("engine/temporary_thermostat.rs"); include!("engine/deadlines.rs"); include!("engine/ownership.rs"); include!("engine/groups.rs"); include!("engine/zone_actions.rs"); include!("engine/zone_control.rs"); include!("engine/history.rs"); include!("engine/temperature.rs"); include!("engine/targets.rs"); include!("engine/schedules.rs"); include!("engine/control_plan.rs"); include!("engine/automations.rs"); include!("engine/tests.rs");