Return real relay state to devices

This commit is contained in:
Pierre HUBERT 2024-09-20 22:43:16 +02:00
parent ae366a84a2
commit f0bac090e4
2 changed files with 7 additions and 4 deletions

View File

@ -282,11 +282,14 @@ impl Handler<SynchronizeDevice> for EnergyActor {
self.devices.synchronise_dev_info(&msg.0, msg.1.clone())?; self.devices.synchronise_dev_info(&msg.0, msg.1.clone())?;
self.engine.device_state(&msg.0).record_ping(); 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![]; let mut v = vec![];
for i in 0..msg.1.max_relays { for d in &device.relays {
v.push(RelaySyncStatus { v.push(RelaySyncStatus {
enabled: i % 2 == 0, enabled: self.engine.relay_state(d.id).is_on(),
}); });
} }
Ok(v) Ok(v)

View File

@ -32,7 +32,7 @@ pub struct RelayState {
} }
impl RelayState { impl RelayState {
fn is_on(&self) -> bool { pub fn is_on(&self) -> bool {
self.on self.on
} }