Add handler in AppState to handle relay states
This commit is contained in:
parent
55617dbd7c
commit
27739e2b71
4 changed files with 43 additions and 9 deletions
emgauwa-lib/src
|
@ -8,7 +8,7 @@ use simple_logger::SimpleLogger;
|
|||
|
||||
use crate::errors::EmgauwaError;
|
||||
use crate::settings::Permissions;
|
||||
use crate::types::Weekday;
|
||||
use crate::types::{RelayStates, Weekday};
|
||||
|
||||
|
||||
pub fn init_logging(level: &str) -> Result<(), EmgauwaError> {
|
||||
|
@ -100,3 +100,18 @@ pub fn get_weekday() -> Weekday {
|
|||
.number_from_monday()
|
||||
- 1) as Weekday
|
||||
}
|
||||
|
||||
pub fn printable_relay_states(relay_states: &RelayStates) -> String {
|
||||
let mut relay_debug = String::new();
|
||||
relay_states.iter().for_each(|state| {
|
||||
relay_debug.push_str(&format!(
|
||||
"{}",
|
||||
match state {
|
||||
Some(true) => "+",
|
||||
Some(false) => "-",
|
||||
None => "?",
|
||||
}
|
||||
));
|
||||
});
|
||||
relay_debug
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue