Add missing device information synchronization

This commit is contained in:
Pierre HUBERT 2024-09-15 22:06:24 +02:00
parent 9c45e541dd
commit 79b2ad12d8
3 changed files with 19 additions and 1 deletions

View File

@ -143,6 +143,23 @@ impl DevicesList {
Ok(())
}
/// Update a device general information
pub fn synchronise_dev_info(
&mut self,
id: &DeviceId,
general_info: DeviceInfo,
) -> anyhow::Result<()> {
let dev = self
.0
.get_mut(id)
.ok_or(DevicesListError::UpdateDeviceFailedDeviceNotFound)?;
dev.info = general_info;
self.persist_dev_config(id)?;
Ok(())
}
/// Update a device general information
pub fn update_general_info(
&mut self,

View File

@ -260,6 +260,7 @@ impl Handler<SynchronizeDevice> for EnergyActor {
type Result = anyhow::Result<Vec<RelaySyncStatus>>;
fn handle(&mut self, msg: SynchronizeDevice, _ctx: &mut Context<Self>) -> Self::Result {
self.devices.synchronise_dev_info(&msg.0, msg.1.clone())?;
self.engine.device_state(&msg.0).record_ping();
// TODO : implement real code

View File

@ -36,7 +36,7 @@ export function EditDeviceRelaysDialog(p: {
p.relay ?? {
id: "",
name: "relay",
enabled: false,
enabled: true,
priority: 1,
consumption: 500,
minimal_downtime: 60 * 5,