Add handler for relay states

This commit is contained in:
Tobias Reisinger 2024-04-25 14:10:32 +02:00
parent 82f2d49dc6
commit 55617dbd7c
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
8 changed files with 53 additions and 20 deletions
emgauwa-controller/src

View file

@ -3,6 +3,7 @@ use std::sync::Arc;
use actix::Addr;
use emgauwa_lib::errors::EmgauwaError;
use emgauwa_lib::models::Controller;
use emgauwa_lib::types::RelayStates;
use tokio::sync::Notify;
use crate::app_state;
@ -42,11 +43,11 @@ pub async fn app_state_reload(app_state: &Addr<AppState>) -> Result<(), EmgauwaE
pub async fn app_state_update_relays_on(
app_state: &Addr<AppState>,
relay_states: Vec<Option<bool>>,
relay_states: RelayStates,
) -> Result<(), EmgauwaError> {
app_state
.send(app_state::UpdateRelaysOn {
relays_are_on: relay_states,
.send(app_state::UpdateRelayStates {
relay_states: relay_states,
})
.await
.map_err(EmgauwaError::from)