Add handler in AppState to handle relay states

This commit is contained in:
Tobias Reisinger 2024-04-25 17:21:54 +02:00
parent 55617dbd7c
commit 27739e2b71
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
4 changed files with 43 additions and 9 deletions
emgauwa-lib/src

View file

@ -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
}