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/ws

View file

@ -78,7 +78,9 @@ async fn read_app_state(
loop {
notifier.notified().await;
log::debug!("Relay change detected");
let ws_action = ControllerWsAction::Register(app_state_get_this(&app_state).await?);
let this = app_state_get_this(&app_state).await?;
let relay_states = this.get_relay_states();
let ws_action = ControllerWsAction::RelayStates((this.c.uid, relay_states));
let ws_action_json = serde_json::to_string(&ws_action)?;
tx.unbounded_send(Message::text(ws_action_json))
@ -122,9 +124,6 @@ async fn handle_message(
log::error!("Error deserializing action: {:?}", e);
}
},
Message::Ping(_) => {
log::debug!("Received ping");
}
_ => {}
}
}