From 42d42e7a6ced2302b392e68ec4e959802c56be48 Mon Sep 17 00:00:00 2001 From: Michael Arthur Date: Thu, 28 Nov 2024 21:01:08 +1300 Subject: [PATCH] remove device from saved data if it ends up there --- custom_components/mammotion/coordinator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/mammotion/coordinator.py b/custom_components/mammotion/coordinator.py index f0af7f8..4bace43 100644 --- a/custom_components/mammotion/coordinator.py +++ b/custom_components/mammotion/coordinator.py @@ -339,8 +339,10 @@ async def async_restore_data(self) -> None: restored_data = await store.async_load() try: if restored_data: - device_dict = LubaMsg().to_dict(casing=betterproto.Casing.SNAKE) + if restored_data.get("device"): + del restored_data["device"] mower_state = MowingDevice().from_dict(restored_data) + device_dict = LubaMsg().to_dict(casing=betterproto.Casing.SNAKE) mower_state.update_raw(device_dict) self.manager.get_device_by_name( self.device_name @@ -354,7 +356,7 @@ async def async_save_data(self, data: MowingDevice) -> None: """Get map data from the device.""" store = Store(self.hass, version=1, key=self.device_name) stored_data = asdict(data) - stored_data["device"] = None + del stored_data["device"] await store.async_save(stored_data)