mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add translations for Roborock Exceptions (#140964)
* Add translations to a few exceptions * match existing wording * fix regex * consolidate errors * fix test
This commit is contained in:
parent
212d39ba19
commit
2a4ed9ace7
@ -193,7 +193,12 @@ class RoborockDataUpdateCoordinator(DataUpdateCoordinator[DeviceProp]):
|
|||||||
try:
|
try:
|
||||||
maps = await self.api.get_multi_maps_list()
|
maps = await self.api.get_multi_maps_list()
|
||||||
except RoborockException as err:
|
except RoborockException as err:
|
||||||
raise UpdateFailed("Failed to get map data: {err}") from err
|
_LOGGER.debug("Failed to get maps: %s", err)
|
||||||
|
raise UpdateFailed(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="map_failure",
|
||||||
|
translation_placeholders={"error": str(err)},
|
||||||
|
) from err
|
||||||
# Rooms names populated later with calls to `set_current_map_rooms` for each map
|
# Rooms names populated later with calls to `set_current_map_rooms` for each map
|
||||||
roborock_maps = maps.map_info if (maps and maps.map_info) else ()
|
roborock_maps = maps.map_info if (maps and maps.map_info) else ()
|
||||||
stored_images = await asyncio.gather(
|
stored_images = await asyncio.gather(
|
||||||
@ -310,7 +315,10 @@ class RoborockDataUpdateCoordinator(DataUpdateCoordinator[DeviceProp]):
|
|||||||
await self.set_current_map_rooms()
|
await self.set_current_map_rooms()
|
||||||
except RoborockException as ex:
|
except RoborockException as ex:
|
||||||
_LOGGER.debug("Failed to update data: %s", ex)
|
_LOGGER.debug("Failed to update data: %s", ex)
|
||||||
raise UpdateFailed(ex) from ex
|
raise UpdateFailed(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="update_data_fail",
|
||||||
|
) from ex
|
||||||
if self.roborock_device_info.props.status.in_cleaning:
|
if self.roborock_device_info.props.status.in_cleaning:
|
||||||
if self._is_cloud_api:
|
if self._is_cloud_api:
|
||||||
self.update_interval = V1_CLOUD_IN_CLEANING_INTERVAL
|
self.update_interval = V1_CLOUD_IN_CLEANING_INTERVAL
|
||||||
|
@ -64,7 +64,7 @@ rules:
|
|||||||
status: exempt
|
status: exempt
|
||||||
comment: There are no noisy entities.
|
comment: There are no noisy entities.
|
||||||
entity-translations: done
|
entity-translations: done
|
||||||
exception-translations: todo
|
exception-translations: done
|
||||||
icon-translations: todo
|
icon-translations: todo
|
||||||
reconfiguration-flow: todo
|
reconfiguration-flow: todo
|
||||||
repair-issues:
|
repair-issues:
|
||||||
|
@ -457,6 +457,12 @@
|
|||||||
"map_failure": {
|
"map_failure": {
|
||||||
"message": "Something went wrong creating the map"
|
"message": "Something went wrong creating the map"
|
||||||
},
|
},
|
||||||
|
"position_not_found": {
|
||||||
|
"message": "Robot position not found"
|
||||||
|
},
|
||||||
|
"update_data_fail": {
|
||||||
|
"message": "Failed to update data"
|
||||||
|
},
|
||||||
"no_coordinators": {
|
"no_coordinators": {
|
||||||
"message": "No devices were able to successfully setup"
|
"message": "No devices were able to successfully setup"
|
||||||
},
|
},
|
||||||
|
@ -221,13 +221,18 @@ class RoborockVacuum(RoborockCoordinatedEntityV1, StateVacuumEntity):
|
|||||||
|
|
||||||
map_data = await self.coordinator.cloud_api.get_map_v1()
|
map_data = await self.coordinator.cloud_api.get_map_v1()
|
||||||
if not isinstance(map_data, bytes):
|
if not isinstance(map_data, bytes):
|
||||||
raise HomeAssistantError("Failed to retrieve map data.")
|
raise HomeAssistantError(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="map_failure",
|
||||||
|
)
|
||||||
parser = RoborockMapDataParser(ColorsPalette(), Sizes(), [], ImageConfig(), [])
|
parser = RoborockMapDataParser(ColorsPalette(), Sizes(), [], ImageConfig(), [])
|
||||||
parsed_map = parser.parse(map_data)
|
parsed_map = parser.parse(map_data)
|
||||||
robot_position = parsed_map.vacuum_position
|
robot_position = parsed_map.vacuum_position
|
||||||
|
|
||||||
if robot_position is None:
|
if robot_position is None:
|
||||||
raise HomeAssistantError("Robot position not found")
|
raise HomeAssistantError(
|
||||||
|
translation_domain=DOMAIN, translation_key="position_not_found"
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"x": robot_position.x,
|
"x": robot_position.x,
|
||||||
|
@ -291,7 +291,9 @@ async def test_get_current_position_no_map_data(
|
|||||||
"homeassistant.components.roborock.coordinator.RoborockMqttClientV1.get_map_v1",
|
"homeassistant.components.roborock.coordinator.RoborockMqttClientV1.get_map_v1",
|
||||||
return_value=None,
|
return_value=None,
|
||||||
),
|
),
|
||||||
pytest.raises(HomeAssistantError, match="Failed to retrieve map data."),
|
pytest.raises(
|
||||||
|
HomeAssistantError, match="Something went wrong creating the map"
|
||||||
|
),
|
||||||
):
|
):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user