From 39dcb5a2b57001689877a71cb47f7c58a7ef1ddf Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 5 Jul 2023 12:53:07 +0200 Subject: [PATCH] Adjust services and properties supported by roborock vacuum (#95789) * Update supported features * Raise issue when vacuum.start_pause is called --- .../components/roborock/strings.json | 6 ++++ homeassistant/components/roborock/vacuum.py | 17 +++++---- tests/components/roborock/test_vacuum.py | 36 ++++++++++++++++++- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/roborock/strings.json b/homeassistant/components/roborock/strings.json index 72a83850f93..1cd95914808 100644 --- a/homeassistant/components/roborock/strings.json +++ b/homeassistant/components/roborock/strings.json @@ -139,5 +139,11 @@ } } } + }, + "issues": { + "service_deprecation_start_pause": { + "title": "Roborock vaccum support for vacuum.start_pause is being removed", + "description": "Roborock vaccum support for the vacuum.start_pause service is deprecated and will be removed in Home Assistant 2024.2; Please adjust any automation or script that uses the service to instead call vacuum.pause or vacuum.start and select submit below to mark this issue as resolved." + } } } diff --git a/homeassistant/components/roborock/vacuum.py b/homeassistant/components/roborock/vacuum.py index 5f66338ecc1..804c0826578 100644 --- a/homeassistant/components/roborock/vacuum.py +++ b/homeassistant/components/roborock/vacuum.py @@ -16,6 +16,7 @@ from homeassistant.components.vacuum import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant +from homeassistant.helpers import issue_registry as ir from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.util import slugify @@ -75,7 +76,6 @@ class RoborockVacuum(RoborockCoordinatedEntity, StateVacuumEntity): | VacuumEntityFeature.RETURN_HOME | VacuumEntityFeature.FAN_SPEED | VacuumEntityFeature.BATTERY - | VacuumEntityFeature.STATUS | VacuumEntityFeature.SEND_COMMAND | VacuumEntityFeature.LOCATE | VacuumEntityFeature.CLEAN_SPOT @@ -110,11 +110,6 @@ class RoborockVacuum(RoborockCoordinatedEntity, StateVacuumEntity): """Return the fan speed of the vacuum cleaner.""" return self._device_status.fan_power.name - @property - def status(self) -> str | None: - """Return the status of the vacuum cleaner.""" - return self._device_status.state.name - async def async_start(self) -> None: """Start the vacuum.""" await self.send(RoborockCommand.APP_START) @@ -152,6 +147,16 @@ class RoborockVacuum(RoborockCoordinatedEntity, StateVacuumEntity): await self.async_pause() else: await self.async_start() + ir.async_create_issue( + self.hass, + DOMAIN, + "service_deprecation_start_pause", + breaks_in_ha_version="2024.2.0", + is_fixable=True, + is_persistent=True, + severity=ir.IssueSeverity.WARNING, + translation_key="service_deprecation_start_pause", + ) async def async_send_command( self, diff --git a/tests/components/roborock/test_vacuum.py b/tests/components/roborock/test_vacuum.py index 80fbd4092c0..080893f1d95 100644 --- a/tests/components/roborock/test_vacuum.py +++ b/tests/components/roborock/test_vacuum.py @@ -20,7 +20,7 @@ from homeassistant.components.vacuum import ( ) from homeassistant.const import ATTR_ENTITY_ID, Platform from homeassistant.core import HomeAssistant -from homeassistant.helpers import entity_registry as er +from homeassistant.helpers import entity_registry as er, issue_registry as ir from tests.common import MockConfigEntry @@ -88,3 +88,37 @@ async def test_commands( assert mock_send_command.call_count == 1 assert mock_send_command.call_args[0][0] == command assert mock_send_command.call_args[0][1] == called_params + + +@pytest.mark.parametrize( + ("service", "issue_id"), + [ + (SERVICE_START_PAUSE, "service_deprecation_start_pause"), + ], +) +async def test_issues( + hass: HomeAssistant, + bypass_api_fixture, + setup_entry: MockConfigEntry, + service: str, + issue_id: str, +) -> None: + """Test issues raised by calling deprecated services.""" + vacuum = hass.states.get(ENTITY_ID) + assert vacuum + + data = {ATTR_ENTITY_ID: ENTITY_ID} + with patch( + "homeassistant.components.roborock.coordinator.RoborockLocalClient.send_command" + ): + await hass.services.async_call( + Platform.VACUUM, + service, + data, + blocking=True, + ) + + issue_registry = ir.async_get(hass) + issue = issue_registry.async_get_issue("roborock", issue_id) + assert issue.is_fixable is True + assert issue.is_persistent is True