code cleanup + better printing
This commit is contained in:
parent
e8fdbbaa45
commit
503bab511a
3 changed files with 8 additions and 4 deletions
|
|
@ -17,7 +17,6 @@ impl Commands {
|
|||
tokio::spawn(async move {
|
||||
m.get_power().await.unwrap();
|
||||
})
|
||||
// println!("[TODO] Power: ----W")
|
||||
}
|
||||
};
|
||||
handle.await.unwrap();
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@ impl Monitor {
|
|||
pub fn new_from_file(config_file: &str) -> Result<Self, Error> {
|
||||
let config_str = fs::read_to_string(config_file)?;
|
||||
let config: MonitorConfig = toml::from_str(&config_str)?;
|
||||
config.print();
|
||||
|
||||
Ok(Self {
|
||||
targets: Monitor::load_targets(&config.targets),
|
||||
client: Client::new(),
|
||||
|
|
@ -60,7 +58,9 @@ impl Monitor {
|
|||
pub async fn get_power(&self) -> Result<(), Error> {
|
||||
for target in &self.targets {
|
||||
if let Ok(res) = target.get_power().await {
|
||||
println!("POWER: {}W", res);
|
||||
target.print();
|
||||
println!("* POWER: {}W", res);
|
||||
println!("------------------")
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -26,11 +26,13 @@ pub struct StatusResponse {
|
|||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct TasmotaInterfaceConfig {
|
||||
name: String,
|
||||
target: String,
|
||||
}
|
||||
|
||||
impl TasmotaInterfaceConfig {
|
||||
pub fn print(&self) {
|
||||
println!("{}", self.name);
|
||||
println!("* {}", self.target);
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +49,9 @@ impl TasmotaInterface {
|
|||
client: Client::new(),
|
||||
}
|
||||
}
|
||||
pub fn print(&self) {
|
||||
println!("{}", self.config.name)
|
||||
}
|
||||
}
|
||||
|
||||
// Monitoring
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue