Display relay consumption history

This commit is contained in:
2024-09-26 22:51:43 +02:00
parent 903f1fa8ce
commit 7895b9eca8
10 changed files with 101 additions and 12 deletions

View File

@@ -53,7 +53,7 @@ impl EnergyActor {
});
self.consumption_cache.add_value(latest_consumption);
let devices_list = self.devices.full_list();
let devices_list = self.devices.full_list_ref();
let mut history =
ConsumptionHistoryFile::open(time_secs(), ConsumptionHistoryType::GridConsumption)?;
@@ -119,7 +119,21 @@ impl Handler<GetCurrConsumption> for EnergyActor {
}
}
/// Get current consumption
/// Get relays consumption
#[derive(Message)]
#[rtype(result = "usize")]
pub struct RelaysConsumption;
impl Handler<RelaysConsumption> for EnergyActor {
type Result = usize;
fn handle(&mut self, _msg: RelaysConsumption, _ctx: &mut Context<Self>) -> Self::Result {
self.engine
.sum_relays_consumption(&self.devices.full_list_ref())
}
}
/// Check if device exists
#[derive(Message)]
#[rtype(result = "bool")]
pub struct CheckDeviceExists(pub DeviceId);