Update general device information

This commit is contained in:
2024-09-09 21:43:57 +02:00
parent a97614ce44
commit 36ba4efd9f
8 changed files with 109 additions and 30 deletions

View File

@ -52,6 +52,17 @@ pub async fn get_single(actor: WebEnergyActor, id: web::Path<DeviceInPath>) -> H
Ok(HttpResponse::Ok().json(dev))
}
/// Get a single device state
pub async fn state_single(actor: WebEnergyActor, id: web::Path<DeviceInPath>) -> HttpResult {
let states = actor.send(energy_actor::GetDevicesState).await?;
let Some(state) = states.into_iter().find(|s| s.id == id.id) else {
return Ok(HttpResponse::NotFound().body("Requested device not found!"));
};
Ok(HttpResponse::Ok().json(state))
}
/// Validate a device
pub async fn validate_device(actor: WebEnergyActor, id: web::Path<DeviceInPath>) -> HttpResult {
actor