Add basic exchange of relay states

This commit is contained in:
Tobias Reisinger 2024-04-25 01:26:53 +02:00
parent 0460e838bc
commit 8a83602d6a
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
10 changed files with 153 additions and 41 deletions
emgauwa-controller/src

View file

@ -15,11 +15,20 @@ pub async fn app_state_get_this(app_state: &Addr<AppState>) -> Result<Controller
.map_err(EmgauwaError::from)
}
pub async fn app_state_get_notifier(
pub async fn app_state_get_relay_notifier(
app_state: &Addr<AppState>,
) -> Result<Arc<Notify>, EmgauwaError> {
app_state
.send(app_state::GetNotifier {})
.send(app_state::GetRelayNotifier {})
.await
.map_err(EmgauwaError::from)
}
pub async fn app_state_get_controller_notifier(
app_state: &Addr<AppState>,
) -> Result<Arc<Notify>, EmgauwaError> {
app_state
.send(app_state::GetControllerNotifier {})
.await
.map_err(EmgauwaError::from)
}
@ -30,3 +39,15 @@ pub async fn app_state_reload(app_state: &Addr<AppState>) -> Result<(), EmgauwaE
.await
.map_err(EmgauwaError::from)?
}
pub async fn app_state_update_relays_on(
app_state: &Addr<AppState>,
relay_states: Vec<Option<bool>>,
) -> Result<(), EmgauwaError> {
app_state
.send(app_state::UpdateRelaysOn {
relays_are_on: relay_states,
})
.await
.map_err(EmgauwaError::from)
}