This commit is contained in:
Mateusz Gruszczyński
2026-08-27 16:44:41 +02:00
parent ba61cb77b1
commit 65eaf50fb6
12 changed files with 64 additions and 49 deletions
-20
View File
@@ -50,7 +50,6 @@ pub fn router(state: AppState) -> Router {
.route("/api/zones", get(list_zones).post(create_zone))
.route("/api/zones/:id", get(get_zone).put(update_zone).delete(delete_zone))
.route("/api/zones/:id/control", post(update_zone_control))
.route("/api/zones/:id/manual-power", post(update_zone_manual_power))
.route("/api/zones/:id/schedule-template", post(apply_schedule_template))
.route("/api/groups", get(list_groups).post(create_group))
.route("/api/groups/:id", get(get_group).put(update_group).delete(delete_group))
@@ -720,25 +719,6 @@ async fn update_zone_control(State(state): State<AppState>, Path(id): Path<Strin
}
#[derive(Debug, Deserialize)]
struct ZoneManualPowerPatch { power: bool }
async fn update_zone_manual_power(
State(state): State<AppState>,
Path(id): Path<String>,
Json(input): Json<ZoneManualPowerPatch>,
) -> Result<Json<Value>, AppError> {
// Backward-compatible route: despite the historical name this now controls the local
// thermostat, not the physical unit like a pilot. Direct/pilot semantics stay on /devices.
let zone = apply_zone_control_patch(
&state,
&id,
ZoneControlPatch { power: Some(input.power), ..Default::default() },
).await?;
let device = state.db.get_device(&zone.device_id)?;
Ok(Json(json!({"zone": zone, "device": device})))
}
async fn ensure_device_stopped_for_detach(state: &AppState, device_id: &str, source: &str) -> Result<(), AppError> {
let Some(device) = state.db.get_device(device_id)? else { return Ok(()); };