Update roborock to ensure every room has a name, falling back to a placeholder (#134733)
* Update roborock to ensure every room has a name, falling back to a placeholder * Change Map to Roompull/134906/head
parent
74613ae0c4
commit
2f295efb3f
|
@ -133,7 +133,9 @@ class RoborockDataUpdateCoordinator(DataUpdateCoordinator[DeviceProp]):
|
|||
if maps and maps.map_info:
|
||||
for roborock_map in maps.map_info:
|
||||
self.maps[roborock_map.mapFlag] = RoborockMapInfo(
|
||||
flag=roborock_map.mapFlag, name=roborock_map.name, rooms={}
|
||||
flag=roborock_map.mapFlag,
|
||||
name=roborock_map.name or f"Map {roborock_map.mapFlag}",
|
||||
rooms={},
|
||||
)
|
||||
|
||||
async def get_rooms(self) -> None:
|
||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .mock_data import PROP
|
||||
from .mock_data import MULTI_MAP_LIST, PROP
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -86,3 +86,33 @@ async def test_none_map_select(
|
|||
await async_setup_component(hass, DOMAIN, {})
|
||||
select_entity = hass.states.get("select.roborock_s7_maxv_selected_map")
|
||||
assert select_entity.state == STATE_UNKNOWN
|
||||
|
||||
|
||||
async def test_selected_map_name(
|
||||
hass: HomeAssistant,
|
||||
bypass_api_fixture,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that the selected map is set to the correct map name."""
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
select_entity = hass.states.get("select.roborock_s7_maxv_selected_map")
|
||||
assert select_entity.state == "Upstairs"
|
||||
|
||||
|
||||
async def test_selected_map_without_name(
|
||||
hass: HomeAssistant,
|
||||
bypass_api_fixture_v1_only,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that maps without a name are given a placeholder name."""
|
||||
map_list = copy.deepcopy(MULTI_MAP_LIST)
|
||||
map_list.map_info[0].name = ""
|
||||
with patch(
|
||||
"homeassistant.components.roborock.coordinator.RoborockLocalClientV1.get_multi_maps_list",
|
||||
return_value=map_list,
|
||||
):
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
select_entity = hass.states.get("select.roborock_s7_maxv_selected_map")
|
||||
assert select_entity
|
||||
assert select_entity.state == "Map 0"
|
||||
|
|
Loading…
Reference in New Issue