diff --git a/custom_components/mammotion/button.py b/custom_components/mammotion/button.py index df0fa54..337c6a7 100644 --- a/custom_components/mammotion/button.py +++ b/custom_components/mammotion/button.py @@ -53,6 +53,10 @@ class MammotionButtonSensorEntityDescription(ButtonEntityDescription): key="cancel_task", press_fn=lambda coordinator: coordinator.async_cancel_task(), ), + MammotionButtonSensorEntityDescription( + key="clear_all_mapdata", + press_fn=lambda coordinator: coordinator.clear_all_maps(), + ), ) diff --git a/custom_components/mammotion/coordinator.py b/custom_components/mammotion/coordinator.py index 49ef684..cf81e1f 100644 --- a/custom_components/mammotion/coordinator.py +++ b/custom_components/mammotion/coordinator.py @@ -14,7 +14,7 @@ from homeassistant.helpers import device_registry as dr from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from pymammotion.aliyun.cloud_gateway import DeviceOfflineException, SetupException -from pymammotion.data.model import GenerateRouteInformation +from pymammotion.data.model import GenerateRouteInformation, HashList from pymammotion.data.model.account import Credentials from pymammotion.data.model.device import MowingDevice from pymammotion.data.model.device_config import OperationSettings, create_path_order @@ -274,6 +274,10 @@ async def async_plan_route(self) -> None: "generate_route_information", generate_route_information=route_information ) + def clear_all_maps(self) -> None: + data = self.manager.get_device_by_name(self.device_name).mower_state() + data.map = HashList() + async def _async_update_notification(self) -> None: """Update data from incoming messages.""" self.async_set_updated_data(self.manager.mower(self.device_name)) diff --git a/custom_components/mammotion/manifest.json b/custom_components/mammotion/manifest.json index bbb95a7..5401c0c 100644 --- a/custom_components/mammotion/manifest.json +++ b/custom_components/mammotion/manifest.json @@ -30,6 +30,6 @@ ], "iot_class": "local_push", "requirements": [ - "pymammotion==0.2.40" + "pymammotion==0.2.41" ] } diff --git a/custom_components/mammotion/translations/en.json b/custom_components/mammotion/translations/en.json index 751926a..8bb9fc7 100644 --- a/custom_components/mammotion/translations/en.json +++ b/custom_components/mammotion/translations/en.json @@ -131,6 +131,9 @@ }, "cancel_task": { "name": "Cancel current task" + }, + "clear_all_mapdata": { + "name": "Clear maps and area names" } }, "switch": { diff --git a/pyproject.toml b/pyproject.toml index 3ced8a6..a79e7fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ readme = "README.md" [tool.poetry.dependencies] python = "~3.12.0" -pymammotion = "0.2.40" +pymammotion = "0.2.41" homeassistant = "^2024.7.4" autotyping = "^24.3.0"