Return real relay state to devices
This commit is contained in:
parent
ae366a84a2
commit
f0bac090e4
@ -282,11 +282,14 @@ impl Handler<SynchronizeDevice> 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)
|
||||
|
@ -32,7 +32,7 @@ pub struct RelayState {
|
||||
}
|
||||
|
||||
impl RelayState {
|
||||
fn is_on(&self) -> bool {
|
||||
pub fn is_on(&self) -> bool {
|
||||
self.on
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user