v0.7.11
This commit is contained in:
-20
@@ -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(()); };
|
||||
|
||||
+12
-3
@@ -2301,11 +2301,20 @@ mod tests {
|
||||
#[test]
|
||||
fn local_thermostat_ownership_blocks_direct_automation() {
|
||||
let mut zone = test_zone("device");
|
||||
assert!(!device_blocked_by_local_thermostat(&zone.device_id, &[zone.clone()]));
|
||||
assert!(!device_blocked_by_local_thermostat(
|
||||
&zone.device_id,
|
||||
std::slice::from_ref(&zone),
|
||||
));
|
||||
zone.local_thermostat_power = Some(true);
|
||||
assert!(device_blocked_by_local_thermostat(&zone.device_id, &[zone.clone()]));
|
||||
assert!(device_blocked_by_local_thermostat(
|
||||
&zone.device_id,
|
||||
std::slice::from_ref(&zone),
|
||||
));
|
||||
zone.local_thermostat_power = Some(false);
|
||||
assert!(device_blocked_by_local_thermostat(&zone.device_id, &[zone]));
|
||||
assert!(device_blocked_by_local_thermostat(
|
||||
&zone.device_id,
|
||||
std::slice::from_ref(&zone),
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user