Store last ping of devices

This commit is contained in:
2024-09-09 21:05:52 +02:00
parent 6bdebe6932
commit 7cac6aeb35
4 changed files with 80 additions and 0 deletions

View File

@ -144,6 +144,10 @@ pub async fn secure_server(energy_actor: EnergyActorAddr) -> anyhow::Result<()>
"/web_api/devices/list_validated",
web::get().to(devices_controller::list_validated),
)
.route(
"/web_api/devices/state",
web::get().to(devices_controller::devices_state),
)
.route(
"/web_api/device/{id}",
web::get().to(devices_controller::get_single),

View File

@ -28,6 +28,13 @@ pub async fn list_validated(actor: WebEnergyActor) -> HttpResult {
Ok(HttpResponse::Ok().json(list))
}
/// Get the state of devices
pub async fn devices_state(actor: WebEnergyActor) -> HttpResult {
let states = actor.send(energy_actor::GetDevicesState).await?;
Ok(HttpResponse::Ok().json(states))
}
#[derive(serde::Deserialize)]
pub struct DeviceInPath {
id: DeviceId,