Skip to content

Commit

Permalink
await the on/off switch and update pymammotion
Browse files Browse the repository at this point in the history
  • Loading branch information
mikey0000 committed Oct 6, 2024
1 parent b360011 commit afa2c00
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions custom_components/mammotion/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ def __init__(
self.update_failures = 0
self.enabled = True

def set_scheduled_updates(self, enabled: bool) -> None:
async def set_scheduled_updates(self, enabled: bool) -> None:
self.enabled = enabled
device = self.manager.get_device_by_name(self.device_name)
if self.enabled:
if device.has_cloud():
device.cloud().start()
await device.cloud().start()
else:
if device.has_cloud():
device.cloud().stop()
await device.cloud().stop()
device.cloud().mqtt.disconnect()
if device.has_ble():
device.ble().stop()
await device.ble().stop()

async def async_login(self) -> None:
"""Login to cloud servers."""
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.67"
"pymammotion==0.2.68"
]
}
6 changes: 3 additions & 3 deletions custom_components/mammotion/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MammotionUpdateSwitchEntityDescription(SwitchEntityDescription):
"""Describes Mammotion switch entity."""

key: str
set_fn: Callable[[MammotionDataUpdateCoordinator, bool], None]
set_fn: Callable[[MammotionDataUpdateCoordinator, bool], Awaitable[None]]
is_on_func: Callable[[MammotionDataUpdateCoordinator], bool]


Expand Down Expand Up @@ -214,12 +214,12 @@ def is_on(self) -> bool:

async def async_turn_on(self, **kwargs: Any) -> None:
self._attr_is_on = True
self.entity_description.set_fn(self.coordinator, True)
await self.entity_description.set_fn(self.coordinator, True)
self.async_write_ha_state()

async def async_turn_off(self, **kwargs: Any) -> None:
self._attr_is_on = False
self.entity_description.set_fn(self.coordinator, False)
await self.entity_description.set_fn(self.coordinator, False)
self.async_write_ha_state()


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.67"
pymammotion = "0.2.68"
homeassistant = "^2024.9.0"
autotyping = "^24.3.0"

Expand Down

0 comments on commit afa2c00

Please sign in to comment.