add set functionality to control outlets
This commit is contained in:
parent
987150c9b6
commit
633a57ff23
5 changed files with 42 additions and 22 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use crate::control::Control;
|
||||
use crate::monitor::Monitoring;
|
||||
use crate::tasmota::{TasmotaInterface, TasmotaInterfaceConfig};
|
||||
use crate::types::Error;
|
||||
use crate::types::{self, Error};
|
||||
use reqwest::Client;
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
|
|
@ -38,7 +39,7 @@ impl System {
|
|||
v
|
||||
}
|
||||
|
||||
pub async fn get_power(&self) -> Result<(), Error> {
|
||||
pub async fn try_get_power(&self) -> Result<(), Error> {
|
||||
for component in &self.components {
|
||||
if let Ok(res) = component.get_power().await {
|
||||
component.print();
|
||||
|
|
@ -48,4 +49,10 @@ impl System {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn try_set_power(&self, index: usize, state: types::PowerState) -> Result<(), Error> {
|
||||
//TODO: check bounds
|
||||
self.components[index].set_power(state).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue