Skip to content

Commit f63c0dd

Browse files
committed
fix: mark non vacuum v1 devices as not supported
1 parent 7a61bfa commit f63c0dd

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

roborock/devices/device_manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
HomeData,
1414
HomeDataDevice,
1515
HomeDataProduct,
16+
RoborockCategory,
1617
UserData,
1718
)
1819
from roborock.devices.device import DeviceReadyCallback, RoborockDevice
@@ -228,6 +229,10 @@ def device_creator(home_data: HomeData, device: HomeDataDevice, product: HomeDat
228229
device_cache: DeviceCache = DeviceCache(device.duid, cache)
229230
match device.pv:
230231
case DeviceVersion.V1:
232+
if product.category != RoborockCategory.VACUUM:
233+
raise UnsupportedDeviceError(
234+
f"Device {device.name} has unsupported V1 category {product.category}: {product.model}"
235+
)
231236
channel = create_v1_channel(user_data, mqtt_params, mqtt_session, device, device_cache)
232237
trait = v1.create(
233238
device.duid,

tests/devices/test_device_manager.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,55 @@ async def test_unsupported_protocol_version() -> None:
420420
assert diagnostics_data
421421
assert diagnostics_data.get("supported_devices") == {"1.0": 1}
422422
assert diagnostics_data.get("unsupported_devices") == {"unknown-pv": 1}
423+
424+
425+
async def test_unsupported_v1_category() -> None:
426+
"""Test that non-vacuum V1 devices are skipped as unsupported."""
427+
with patch("roborock.devices.device_manager.UserWebApiClient.get_home_data") as mock_home_data:
428+
home_data = HomeData.from_dict(
429+
{
430+
"id": 1,
431+
"name": "Test Home",
432+
"devices": [
433+
{
434+
"duid": "device-uid-1",
435+
"name": "Device 1",
436+
"pv": "1.0",
437+
"productId": "product-id-1",
438+
"localKey": mock_data.LOCAL_KEY,
439+
},
440+
{
441+
"duid": "device-uid-2",
442+
"name": "Device 2",
443+
"pv": "1.0",
444+
"productId": "product-id-2",
445+
"localKey": mock_data.LOCAL_KEY,
446+
},
447+
],
448+
"products": [
449+
{
450+
"id": "product-id-1",
451+
"name": "Roborock S7 MaxV",
452+
"model": "roborock.vacuum.a27",
453+
"category": "robot.vacuum.cleaner",
454+
},
455+
{
456+
"id": "product-id-2",
457+
"name": "Roborock RockNeo",
458+
"model": "roborock.mower.q105",
459+
"category": "roborock.mower",
460+
},
461+
],
462+
}
463+
)
464+
mock_home_data.return_value = home_data
465+
466+
device_manager = await create_device_manager(USER_PARAMS)
467+
devices = await device_manager.get_devices()
468+
assert [device.duid for device in devices] == ["device-uid-1"]
469+
470+
diagnostics = device_manager.diagnostic_data()
471+
diagnostics_data = diagnostics.get("diagnostics")
472+
assert diagnostics_data
473+
assert diagnostics_data.get("supported_devices") == {"1.0": 1}
474+
assert diagnostics_data.get("unsupported_devices") == {"1.0": 1}

0 commit comments

Comments
 (0)