Store relay consumption values
This commit is contained in:
@ -2,6 +2,12 @@ use crate::devices::device::{DeviceId, DeviceRelayID};
|
||||
use clap::{Parser, Subcommand};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum ConsumptionHistoryType {
|
||||
GridConsumption,
|
||||
RelayConsumption,
|
||||
}
|
||||
|
||||
/// Electrical consumption fetcher backend
|
||||
#[derive(Subcommand, Debug, Clone)]
|
||||
pub enum ConsumptionBackend {
|
||||
@ -262,10 +268,20 @@ impl AppConfig {
|
||||
}
|
||||
|
||||
/// Get energy consumption history file path for a given day
|
||||
pub fn energy_consumption_history_day(&self, number: u64) -> PathBuf {
|
||||
pub fn energy_consumption_history_day(
|
||||
&self,
|
||||
number: u64,
|
||||
r#type: ConsumptionHistoryType,
|
||||
) -> PathBuf {
|
||||
self.storage_path()
|
||||
.join("consumption_history")
|
||||
.join(number.to_string())
|
||||
.join(format!(
|
||||
"{number}-{}",
|
||||
match r#type {
|
||||
ConsumptionHistoryType::GridConsumption => "grid",
|
||||
ConsumptionHistoryType::RelayConsumption => "relay-consumption",
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user