mirror of
https://github.com/home-assistant/core.git
synced 2025-09-05 21:01:37 +02:00
Improve roborock resume cleaning logic (#150726)
This commit is contained in:
@@ -148,10 +148,14 @@ class RoborockVacuum(RoborockCoordinatedEntityV1, StateVacuumEntity):
|
|||||||
|
|
||||||
async def async_start(self) -> None:
|
async def async_start(self) -> None:
|
||||||
"""Start the vacuum."""
|
"""Start the vacuum."""
|
||||||
if self._device_status.in_cleaning == 2:
|
if self._device_status.in_returning == 1:
|
||||||
|
await self.send(RoborockCommand.APP_CHARGE)
|
||||||
|
elif self._device_status.in_cleaning == 2:
|
||||||
await self.send(RoborockCommand.RESUME_ZONED_CLEAN)
|
await self.send(RoborockCommand.RESUME_ZONED_CLEAN)
|
||||||
elif self._device_status.in_cleaning == 3:
|
elif self._device_status.in_cleaning == 3:
|
||||||
await self.send(RoborockCommand.RESUME_SEGMENT_CLEAN)
|
await self.send(RoborockCommand.RESUME_SEGMENT_CLEAN)
|
||||||
|
elif self._device_status.in_cleaning == 4:
|
||||||
|
await self.send(RoborockCommand.APP_RESUME_BUILD_MAP)
|
||||||
else:
|
else:
|
||||||
await self.send(RoborockCommand.APP_START)
|
await self.send(RoborockCommand.APP_START)
|
||||||
|
|
||||||
|
@@ -142,12 +142,14 @@ async def test_cloud_command(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("in_cleaning_int", "expected_command"),
|
("in_cleaning_int", "in_returning_int", "expected_command"),
|
||||||
[
|
[
|
||||||
(0, RoborockCommand.APP_START),
|
(0, 1, RoborockCommand.APP_CHARGE),
|
||||||
(1, RoborockCommand.APP_START),
|
(0, 0, RoborockCommand.APP_START),
|
||||||
(2, RoborockCommand.RESUME_ZONED_CLEAN),
|
(1, 0, RoborockCommand.APP_START),
|
||||||
(3, RoborockCommand.RESUME_SEGMENT_CLEAN),
|
(2, 0, RoborockCommand.RESUME_ZONED_CLEAN),
|
||||||
|
(3, 0, RoborockCommand.RESUME_SEGMENT_CLEAN),
|
||||||
|
(4, 0, RoborockCommand.APP_RESUME_BUILD_MAP),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_resume_cleaning(
|
async def test_resume_cleaning(
|
||||||
@@ -155,11 +157,13 @@ async def test_resume_cleaning(
|
|||||||
bypass_api_fixture,
|
bypass_api_fixture,
|
||||||
mock_roborock_entry: MockConfigEntry,
|
mock_roborock_entry: MockConfigEntry,
|
||||||
in_cleaning_int: int,
|
in_cleaning_int: int,
|
||||||
|
in_returning_int: int,
|
||||||
expected_command: RoborockCommand,
|
expected_command: RoborockCommand,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test resuming clean on start button when a clean is paused."""
|
"""Test resuming clean on start button when a clean is paused."""
|
||||||
prop = copy.deepcopy(PROP)
|
prop = copy.deepcopy(PROP)
|
||||||
prop.status.in_cleaning = in_cleaning_int
|
prop.status.in_cleaning = in_cleaning_int
|
||||||
|
prop.status.in_returning = in_returning_int
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.roborock.coordinator.RoborockLocalClientV1.get_prop",
|
"homeassistant.components.roborock.coordinator.RoborockLocalClientV1.get_prop",
|
||||||
return_value=prop,
|
return_value=prop,
|
||||||
|
Reference in New Issue
Block a user