Skip to content

Commit

Permalink
restore what I think causes increased updates add clear maps and area…
Browse files Browse the repository at this point in the history
… names button bump library, should not re-request areas when they are already fetched
  • Loading branch information
mikey0000 committed Sep 14, 2024
1 parent 76081a5 commit 960c72a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions custom_components/mammotion/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
)


Expand Down
6 changes: 5 additions & 1 deletion custom_components/mammotion/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion custom_components/mammotion/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
],
"iot_class": "local_push",
"requirements": [
"pymammotion==0.2.40"
"pymammotion==0.2.41"
]
}
3 changes: 3 additions & 0 deletions custom_components/mammotion/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
},
"cancel_task": {
"name": "Cancel current task"
},
"clear_all_mapdata": {
"name": "Clear maps and area names"
}
},
"switch": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 960c72a

Please sign in to comment.