Add handler for relay states
This commit is contained in:
parent
82f2d49dc6
commit
55617dbd7c
8 changed files with 53 additions and 20 deletions
emgauwa-core/src/handlers/v1/ws/controllers
|
@ -1,7 +1,10 @@
|
|||
use std::hash::{Hash, Hasher};
|
||||
|
||||
use actix::{Actor, AsyncContext};
|
||||
use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule};
|
||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
|
||||
use emgauwa_lib::models::{Controller, FromDbModel};
|
||||
use emgauwa_lib::types::{ControllerUid, RelayStates};
|
||||
use futures::executor::block_on;
|
||||
use sqlx::pool::PoolConnection;
|
||||
use sqlx::Sqlite;
|
||||
|
@ -81,4 +84,18 @@ impl ControllerWs {
|
|||
log::debug!("Done registering controller");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn handle_relay_states(
|
||||
&mut self,
|
||||
ctx: &mut <ControllerWs as Actor>::Context,
|
||||
controller_uid: ControllerUid,
|
||||
relay_states: RelayStates,
|
||||
) -> Result<(), EmgauwaError> {
|
||||
log::debug!(
|
||||
"Received relay states: {:?} for {}",
|
||||
relay_states,
|
||||
controller_uid
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,9 @@ impl ControllerWs {
|
|||
) {
|
||||
let action_res = match action {
|
||||
ControllerWsAction::Register(controller) => self.handle_register(conn, ctx, controller),
|
||||
ControllerWsAction::RelayStates((controller_uid, relay_states)) => {
|
||||
self.handle_relay_states(ctx, controller_uid, relay_states)
|
||||
}
|
||||
_ => Ok(()),
|
||||
};
|
||||
if let Err(e) = action_res {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue