diff --git a/central_backend/src/energy/energy_actor.rs b/central_backend/src/energy/energy_actor.rs index 9b677cb..766eca7 100644 --- a/central_backend/src/energy/energy_actor.rs +++ b/central_backend/src/energy/energy_actor.rs @@ -282,11 +282,14 @@ impl Handler for EnergyActor { self.devices.synchronise_dev_info(&msg.0, msg.1.clone())?; self.engine.device_state(&msg.0).record_ping(); - // TODO : implement real code + let Some(device) = self.devices.get_single(&msg.0) else { + return Ok(vec![]); + }; + let mut v = vec![]; - for i in 0..msg.1.max_relays { + for d in &device.relays { v.push(RelaySyncStatus { - enabled: i % 2 == 0, + enabled: self.engine.relay_state(d.id).is_on(), }); } Ok(v) diff --git a/central_backend/src/energy/engine.rs b/central_backend/src/energy/engine.rs index d583830..54d3190 100644 --- a/central_backend/src/energy/engine.rs +++ b/central_backend/src/energy/engine.rs @@ -32,7 +32,7 @@ pub struct RelayState { } impl RelayState { - fn is_on(&self) -> bool { + pub fn is_on(&self) -> bool { self.on }