Update roborock services to raise ServiceNotSupported for new devices that don't yet support it (#167470)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Allen Porter
2026-04-06 03:05:06 -07:00
committed by GitHub
parent 11fac8ee48
commit 310af5a31a
2 changed files with 110 additions and 2 deletions

View File

@@ -19,7 +19,11 @@ from homeassistant.components.vacuum import (
VacuumEntityFeature,
)
from homeassistant.core import HomeAssistant, ServiceResponse, callback
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from homeassistant.exceptions import (
HomeAssistantError,
ServiceNotSupported,
ServiceValidationError,
)
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from .const import DOMAIN
@@ -484,6 +488,18 @@ class RoborockQ7Vacuum(RoborockCoordinatedEntityB01Q7, StateVacuumEntity):
},
) from err
async def get_maps(self) -> ServiceResponse:
"""Get map information such as map id and room ids."""
raise ServiceNotSupported(DOMAIN, "get_maps", self.entity_id)
async def get_vacuum_current_position(self) -> ServiceResponse:
"""Get the current position of the vacuum from the map."""
raise ServiceNotSupported(DOMAIN, "get_vacuum_current_position", self.entity_id)
async def async_set_vacuum_goto_position(self, x: int, y: int) -> None:
"""Set the vacuum to go to a specific position."""
raise ServiceNotSupported(DOMAIN, "set_vacuum_goto_position", self.entity_id)
class RoborockQ10Vacuum(RoborockCoordinatedEntityB01Q10, StateVacuumEntity):
"""Representation of a Roborock Q10 vacuum."""
@@ -654,3 +670,15 @@ class RoborockQ10Vacuum(RoborockCoordinatedEntityB01Q10, StateVacuumEntity):
"command": command,
},
) from err
async def get_maps(self) -> ServiceResponse:
"""Get map information such as map id and room ids."""
raise ServiceNotSupported(DOMAIN, "get_maps", self.entity_id)
async def get_vacuum_current_position(self) -> ServiceResponse:
"""Get the current position of the vacuum from the map."""
raise ServiceNotSupported(DOMAIN, "get_vacuum_current_position", self.entity_id)
async def async_set_vacuum_goto_position(self, x: int, y: int) -> None:
"""Set the vacuum to go to a specific position."""
raise ServiceNotSupported(DOMAIN, "set_vacuum_goto_position", self.entity_id)

View File

@@ -34,7 +34,11 @@ from homeassistant.components.vacuum import (
)
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from homeassistant.exceptions import (
HomeAssistantError,
ServiceNotSupported,
ServiceValidationError,
)
from homeassistant.helpers import (
device_registry as dr,
entity_registry as er,
@@ -217,6 +221,31 @@ async def test_get_maps(
assert response == snapshot
@pytest.mark.parametrize(
"entity_id",
[
Q7_ENTITY_ID,
Q10_ENTITY_ID,
],
)
async def test_get_maps_not_supported(
hass: HomeAssistant,
setup_entry: MockConfigEntry,
entity_id: str,
) -> None:
"""Test that unsupported vacuums raise ServiceNotSupported for get_maps."""
with pytest.raises(
ServiceNotSupported, match="does not support action roborock.get_maps"
):
await hass.services.async_call(
DOMAIN,
GET_MAPS_SERVICE_NAME,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
return_response=True,
)
async def test_goto(
hass: HomeAssistant,
setup_entry: MockConfigEntry,
@@ -239,6 +268,31 @@ async def test_goto(
)
@pytest.mark.parametrize(
"entity_id",
[
Q7_ENTITY_ID,
Q10_ENTITY_ID,
],
)
async def test_goto_not_supported(
hass: HomeAssistant,
setup_entry: MockConfigEntry,
entity_id: str,
) -> None:
"""Test that unsupported vacuums raise ServiceNotSupported for goto."""
with pytest.raises(
ServiceNotSupported,
match="does not support action roborock.set_vacuum_goto_position",
):
await hass.services.async_call(
DOMAIN,
SET_VACUUM_GOTO_POSITION_SERVICE_NAME,
{ATTR_ENTITY_ID: entity_id, "x": 25500, "y": 25500},
blocking=True,
)
async def test_get_current_position(
hass: HomeAssistant,
setup_entry: MockConfigEntry,
@@ -305,6 +359,32 @@ async def test_get_current_position_no_robot_position(
)
@pytest.mark.parametrize(
"entity_id",
[
Q7_ENTITY_ID,
Q10_ENTITY_ID,
],
)
async def test_get_current_position_not_supported(
hass: HomeAssistant,
setup_entry: MockConfigEntry,
entity_id: str,
) -> None:
"""Test that the current-position service raises ServiceNotSupported."""
with pytest.raises(
ServiceNotSupported,
match="does not support action roborock.get_vacuum_current_position",
):
await hass.services.async_call(
DOMAIN,
GET_VACUUM_CURRENT_POSITION_SERVICE_NAME,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
return_response=True,
)
async def test_get_segments(
hass: HomeAssistant,
setup_entry: MockConfigEntry,