Can get the full list of relays through the API

This commit is contained in:
2024-07-24 23:35:58 +02:00
parent 4d5ba939d1
commit 73163e6e69
5 changed files with 43 additions and 2 deletions

View File

@ -1,5 +1,5 @@
use crate::constants;
use crate::devices::device::{Device, DeviceGeneralInfo, DeviceId, DeviceInfo};
use crate::devices::device::{Device, DeviceGeneralInfo, DeviceId, DeviceInfo, DeviceRelay};
use crate::devices::devices_list::DevicesList;
use crate::energy::consumption;
use crate::energy::consumption::EnergyConsumption;
@ -171,3 +171,16 @@ impl Handler<GetSingleDevice> for EnergyActor {
self.devices.get_single(&msg.0)
}
}
/// Get the full list of relays
#[derive(Message)]
#[rtype(result = "Vec<DeviceRelay>")]
pub struct GetRelaysList;
impl Handler<GetRelaysList> for EnergyActor {
type Result = Vec<DeviceRelay>;
fn handle(&mut self, _msg: GetRelaysList, _ctx: &mut Context<Self>) -> Self::Result {
self.devices.relays_list()
}
}