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-core/src/handlers/v1/ws/controllers

View file

@ -31,7 +31,15 @@ impl ControllerWs {
block_on(controller_db.update_active(conn, true))?;
for relay in &controller.relays {
log::debug!("Registering relay: {}", relay.r.name);
log::debug!(
"Registering relay: {} ({})",
relay.r.name,
match relay.is_on {
Some(true) => "+",
Some(false) => "-",
None => "?",
}
);
let (new_relay, created) = block_on(DbRelay::get_by_controller_and_num_or_create(
conn,
&controller_db,