Add second test device for Roborock (#100565)
parent
6f8734167f
commit
77001b26de
|
@ -24,9 +24,21 @@ def bypass_api_fixture() -> None:
|
|||
"homeassistant.components.roborock.RoborockMqttClient.async_connect"
|
||||
), patch(
|
||||
"homeassistant.components.roborock.RoborockMqttClient._send_command"
|
||||
), patch(
|
||||
"homeassistant.components.roborock.RoborockApiClient.get_home_data",
|
||||
return_value=HOME_DATA,
|
||||
), patch(
|
||||
"homeassistant.components.roborock.RoborockMqttClient.get_networking",
|
||||
return_value=NETWORK_INFO,
|
||||
), patch(
|
||||
"homeassistant.components.roborock.coordinator.RoborockLocalClient.get_prop",
|
||||
return_value=PROP,
|
||||
), patch(
|
||||
"homeassistant.components.roborock.coordinator.RoborockLocalClient.send_message"
|
||||
), patch(
|
||||
"homeassistant.components.roborock.RoborockMqttClient._wait_response"
|
||||
), patch(
|
||||
"homeassistant.components.roborock.coordinator.RoborockLocalClient._wait_response"
|
||||
), patch(
|
||||
"roborock.api.AttributeCache.async_value"
|
||||
), patch(
|
||||
|
@ -53,25 +65,11 @@ def mock_roborock_entry(hass: HomeAssistant) -> MockConfigEntry:
|
|||
|
||||
@pytest.fixture
|
||||
async def setup_entry(
|
||||
hass: HomeAssistant, mock_roborock_entry: MockConfigEntry
|
||||
hass: HomeAssistant,
|
||||
bypass_api_fixture,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
) -> MockConfigEntry:
|
||||
"""Set up the Roborock platform."""
|
||||
with patch(
|
||||
"homeassistant.components.roborock.RoborockApiClient.get_home_data",
|
||||
return_value=HOME_DATA,
|
||||
), patch(
|
||||
"homeassistant.components.roborock.RoborockMqttClient.get_networking",
|
||||
return_value=NETWORK_INFO,
|
||||
), patch(
|
||||
"homeassistant.components.roborock.coordinator.RoborockLocalClient.get_prop",
|
||||
return_value=PROP,
|
||||
), patch(
|
||||
"homeassistant.components.roborock.coordinator.RoborockLocalClient.send_message"
|
||||
), patch(
|
||||
"homeassistant.components.roborock.RoborockMqttClient._wait_response"
|
||||
), patch(
|
||||
"homeassistant.components.roborock.coordinator.RoborockLocalClient._wait_response"
|
||||
):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
return mock_roborock_entry
|
||||
|
|
|
@ -13,6 +13,9 @@ from roborock.containers import (
|
|||
)
|
||||
from roborock.roborock_typing import DeviceProp
|
||||
|
||||
from homeassistant.components.roborock import CONF_BASE_URL, CONF_USER_DATA
|
||||
from homeassistant.const import CONF_USERNAME
|
||||
|
||||
# All data is based on a U.S. customer with a Roborock S7 MaxV Ultra
|
||||
USER_EMAIL = "user@domain.com"
|
||||
|
||||
|
@ -48,9 +51,9 @@ USER_DATA = UserData.from_dict(
|
|||
)
|
||||
|
||||
MOCK_CONFIG = {
|
||||
"username": USER_EMAIL,
|
||||
"user_data": USER_DATA.as_dict(),
|
||||
"base_url": None,
|
||||
CONF_USERNAME: USER_EMAIL,
|
||||
CONF_USER_DATA: USER_DATA.as_dict(),
|
||||
CONF_BASE_URL: None,
|
||||
}
|
||||
|
||||
HOME_DATA_RAW = {
|
||||
|
@ -61,7 +64,7 @@ HOME_DATA_RAW = {
|
|||
"geoName": None,
|
||||
"products": [
|
||||
{
|
||||
"id": "abc123",
|
||||
"id": "s7_product",
|
||||
"name": "Roborock S7 MaxV",
|
||||
"code": "a27",
|
||||
"model": "roborock.vacuum.a27",
|
||||
|
@ -227,7 +230,7 @@ HOME_DATA_RAW = {
|
|||
"runtimeEnv": None,
|
||||
"timeZoneId": "America/Los_Angeles",
|
||||
"iconUrl": "",
|
||||
"productId": "abc123",
|
||||
"productId": "s7_product",
|
||||
"lon": None,
|
||||
"lat": None,
|
||||
"share": False,
|
||||
|
@ -255,7 +258,45 @@ HOME_DATA_RAW = {
|
|||
"120": 0,
|
||||
},
|
||||
"silentOtaSwitch": True,
|
||||
}
|
||||
},
|
||||
{
|
||||
"duid": "device_2",
|
||||
"name": "Roborock S7 2",
|
||||
"attribute": None,
|
||||
"activeTime": 1672364449,
|
||||
"localKey": "device_2",
|
||||
"runtimeEnv": None,
|
||||
"timeZoneId": "America/Los_Angeles",
|
||||
"iconUrl": "",
|
||||
"productId": "s7_product",
|
||||
"lon": None,
|
||||
"lat": None,
|
||||
"share": False,
|
||||
"shareTime": None,
|
||||
"online": True,
|
||||
"fv": "02.56.02",
|
||||
"pv": "1.0",
|
||||
"roomId": 2362003,
|
||||
"tuyaUuid": None,
|
||||
"tuyaMigrated": False,
|
||||
"extra": '{"RRPhotoPrivacyVersion": "1"}',
|
||||
"sn": "abc123",
|
||||
"featureSet": "2234201184108543",
|
||||
"newFeatureSet": "0000000000002041",
|
||||
"deviceStatus": {
|
||||
"121": 8,
|
||||
"122": 100,
|
||||
"123": 102,
|
||||
"124": 203,
|
||||
"125": 94,
|
||||
"126": 90,
|
||||
"127": 87,
|
||||
"128": 0,
|
||||
"133": 1,
|
||||
"120": 0,
|
||||
},
|
||||
"silentOtaSwitch": True,
|
||||
},
|
||||
],
|
||||
"receivedDevices": [],
|
||||
"rooms": [
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
'name': 'Roborock S7 MaxV',
|
||||
'newFeatureSet': '0000000000002041',
|
||||
'online': True,
|
||||
'productId': 'abc123',
|
||||
'productId': 's7_product',
|
||||
'pv': '1.0',
|
||||
'roomId': 2362003,
|
||||
'share': False,
|
||||
|
@ -77,7 +77,268 @@
|
|||
'capability': 0,
|
||||
'category': 'robot.vacuum.cleaner',
|
||||
'code': 'a27',
|
||||
'id': 'abc123',
|
||||
'id': 's7_product',
|
||||
'model': 'roborock.vacuum.a27',
|
||||
'name': 'Roborock S7 MaxV',
|
||||
'schema': list([
|
||||
dict({
|
||||
'code': 'rpc_request',
|
||||
'id': '101',
|
||||
'mode': 'rw',
|
||||
'name': 'rpc_request',
|
||||
'type': 'RAW',
|
||||
}),
|
||||
dict({
|
||||
'code': 'rpc_response',
|
||||
'id': '102',
|
||||
'mode': 'rw',
|
||||
'name': 'rpc_response',
|
||||
'type': 'RAW',
|
||||
}),
|
||||
dict({
|
||||
'code': 'error_code',
|
||||
'id': '120',
|
||||
'mode': 'ro',
|
||||
'name': '错误代码',
|
||||
'type': 'ENUM',
|
||||
}),
|
||||
dict({
|
||||
'code': 'state',
|
||||
'id': '121',
|
||||
'mode': 'ro',
|
||||
'name': '设备状态',
|
||||
'type': 'ENUM',
|
||||
}),
|
||||
dict({
|
||||
'code': 'battery',
|
||||
'id': '122',
|
||||
'mode': 'ro',
|
||||
'name': '设备电量',
|
||||
'type': 'ENUM',
|
||||
}),
|
||||
dict({
|
||||
'code': 'fan_power',
|
||||
'id': '123',
|
||||
'mode': 'rw',
|
||||
'name': '清扫模式',
|
||||
'type': 'ENUM',
|
||||
}),
|
||||
dict({
|
||||
'code': 'water_box_mode',
|
||||
'id': '124',
|
||||
'mode': 'rw',
|
||||
'name': '拖地模式',
|
||||
'type': 'ENUM',
|
||||
}),
|
||||
dict({
|
||||
'code': 'main_brush_life',
|
||||
'id': '125',
|
||||
'mode': 'rw',
|
||||
'name': '主刷寿命',
|
||||
'type': 'VALUE',
|
||||
}),
|
||||
dict({
|
||||
'code': 'side_brush_life',
|
||||
'id': '126',
|
||||
'mode': 'rw',
|
||||
'name': '边刷寿命',
|
||||
'type': 'VALUE',
|
||||
}),
|
||||
dict({
|
||||
'code': 'filter_life',
|
||||
'id': '127',
|
||||
'mode': 'rw',
|
||||
'name': '滤网寿命',
|
||||
'type': 'VALUE',
|
||||
}),
|
||||
dict({
|
||||
'code': 'additional_props',
|
||||
'id': '128',
|
||||
'mode': 'ro',
|
||||
'name': '额外状态',
|
||||
'type': 'RAW',
|
||||
}),
|
||||
dict({
|
||||
'code': 'task_complete',
|
||||
'id': '130',
|
||||
'mode': 'ro',
|
||||
'name': '完成事件',
|
||||
'type': 'RAW',
|
||||
}),
|
||||
dict({
|
||||
'code': 'task_cancel_low_power',
|
||||
'id': '131',
|
||||
'mode': 'ro',
|
||||
'name': '电量不足任务取消',
|
||||
'type': 'RAW',
|
||||
}),
|
||||
dict({
|
||||
'code': 'task_cancel_in_motion',
|
||||
'id': '132',
|
||||
'mode': 'ro',
|
||||
'name': '运动中任务取消',
|
||||
'type': 'RAW',
|
||||
}),
|
||||
dict({
|
||||
'code': 'charge_status',
|
||||
'id': '133',
|
||||
'mode': 'ro',
|
||||
'name': '充电状态',
|
||||
'type': 'RAW',
|
||||
}),
|
||||
dict({
|
||||
'code': 'drying_status',
|
||||
'id': '134',
|
||||
'mode': 'ro',
|
||||
'name': '烘干状态',
|
||||
'type': 'RAW',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'props': dict({
|
||||
'cleanSummary': dict({
|
||||
'cleanArea': 1159182500,
|
||||
'cleanCount': 31,
|
||||
'cleanTime': 74382,
|
||||
'dustCollectionCount': 25,
|
||||
'records': list([
|
||||
1672543330,
|
||||
1672458041,
|
||||
]),
|
||||
'squareMeterCleanArea': 1159.2,
|
||||
}),
|
||||
'consumable': dict({
|
||||
'cleaningBrushWorkTimes': 65,
|
||||
'dustCollectionWorkTimes': 25,
|
||||
'filterElementWorkTime': 0,
|
||||
'filterTimeLeft': 465618,
|
||||
'filterWorkTime': 74382,
|
||||
'mainBrushTimeLeft': 1005618,
|
||||
'mainBrushWorkTime': 74382,
|
||||
'sensorDirtyTime': 74382,
|
||||
'sensorTimeLeft': 33618,
|
||||
'sideBrushTimeLeft': 645618,
|
||||
'sideBrushWorkTime': 74382,
|
||||
'strainerWorkTimes': 65,
|
||||
}),
|
||||
'lastCleanRecord': dict({
|
||||
'area': 20965000,
|
||||
'avoidCount': 19,
|
||||
'begin': 1672543330,
|
||||
'beginDatetime': '2023-01-01T03:22:10+00:00',
|
||||
'cleanType': 3,
|
||||
'complete': 1,
|
||||
'duration': 1176,
|
||||
'dustCollectionStatus': 1,
|
||||
'end': 1672544638,
|
||||
'endDatetime': '2023-01-01T03:43:58+00:00',
|
||||
'error': 0,
|
||||
'finishReason': 56,
|
||||
'mapFlag': 0,
|
||||
'squareMeterArea': 21.0,
|
||||
'startType': 2,
|
||||
'washCount': 2,
|
||||
}),
|
||||
'status': dict({
|
||||
'adbumperStatus': list([
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
]),
|
||||
'autoDustCollection': 1,
|
||||
'avoidCount': 19,
|
||||
'backType': -1,
|
||||
'battery': 100,
|
||||
'cameraStatus': 3457,
|
||||
'chargeStatus': 1,
|
||||
'cleanArea': 20965000,
|
||||
'cleanTime': 1176,
|
||||
'collisionAvoidStatus': 1,
|
||||
'debugMode': 0,
|
||||
'dndEnabled': 0,
|
||||
'dockErrorStatus': 0,
|
||||
'dockType': 3,
|
||||
'dustCollectionStatus': 0,
|
||||
'errorCode': 0,
|
||||
'fanPower': 102,
|
||||
'homeSecEnablePassword': 0,
|
||||
'homeSecStatus': 0,
|
||||
'inCleaning': 0,
|
||||
'inFreshState': 1,
|
||||
'inReturning': 0,
|
||||
'isExploring': 0,
|
||||
'isLocating': 0,
|
||||
'labStatus': 1,
|
||||
'lockStatus': 0,
|
||||
'mapPresent': 1,
|
||||
'mapStatus': 3,
|
||||
'mopForbiddenEnable': 1,
|
||||
'mopMode': 300,
|
||||
'msgSeq': 458,
|
||||
'msgVer': 2,
|
||||
'squareMeterCleanArea': 21.0,
|
||||
'state': 8,
|
||||
'switchMapMode': 0,
|
||||
'unsaveMapFlag': 0,
|
||||
'unsaveMapReason': 0,
|
||||
'washPhase': 0,
|
||||
'washReady': 0,
|
||||
'waterBoxCarriageStatus': 1,
|
||||
'waterBoxMode': 203,
|
||||
'waterBoxStatus': 1,
|
||||
'waterShortageStatus': 0,
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
'**REDACTED-1**': dict({
|
||||
'api': dict({
|
||||
}),
|
||||
'roborock_device_info': dict({
|
||||
'device': dict({
|
||||
'activeTime': 1672364449,
|
||||
'deviceStatus': dict({
|
||||
'120': 0,
|
||||
'121': 8,
|
||||
'122': 100,
|
||||
'123': 102,
|
||||
'124': 203,
|
||||
'125': 94,
|
||||
'126': 90,
|
||||
'127': 87,
|
||||
'128': 0,
|
||||
'133': 1,
|
||||
}),
|
||||
'duid': '**REDACTED**',
|
||||
'extra': '{"RRPhotoPrivacyVersion": "1"}',
|
||||
'featureSet': '2234201184108543',
|
||||
'fv': '02.56.02',
|
||||
'iconUrl': '',
|
||||
'localKey': '**REDACTED**',
|
||||
'name': 'Roborock S7 2',
|
||||
'newFeatureSet': '0000000000002041',
|
||||
'online': True,
|
||||
'productId': 's7_product',
|
||||
'pv': '1.0',
|
||||
'roomId': 2362003,
|
||||
'share': False,
|
||||
'silentOtaSwitch': True,
|
||||
'sn': 'abc123',
|
||||
'timeZoneId': 'America/Los_Angeles',
|
||||
'tuyaMigrated': False,
|
||||
}),
|
||||
'network_info': dict({
|
||||
'bssid': '**REDACTED**',
|
||||
'ip': '123.232.12.1',
|
||||
'mac': '**REDACTED**',
|
||||
'rssi': 90,
|
||||
'ssid': 'wifi',
|
||||
}),
|
||||
'product': dict({
|
||||
'capability': 0,
|
||||
'category': 'robot.vacuum.cleaner',
|
||||
'code': 'a27',
|
||||
'id': 's7_product',
|
||||
'model': 'roborock.vacuum.a27',
|
||||
'name': 'Roborock S7 MaxV',
|
||||
'schema': list([
|
||||
|
|
|
@ -9,7 +9,7 @@ async def test_binary_sensors(
|
|||
hass: HomeAssistant, setup_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test binary sensors and check test values are correctly set."""
|
||||
assert len(hass.states.async_all("binary_sensor")) == 2
|
||||
assert len(hass.states.async_all("binary_sensor")) == 4
|
||||
assert hass.states.get("binary_sensor.roborock_s7_maxv_mop_attached").state == "on"
|
||||
assert (
|
||||
hass.states.get("binary_sensor.roborock_s7_maxv_water_box_attached").state
|
||||
|
|
|
@ -21,7 +21,7 @@ async def test_unload_entry(
|
|||
) as mock_disconnect:
|
||||
assert await hass.config_entries.async_unload(setup_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_disconnect.call_count == 1
|
||||
assert mock_disconnect.call_count == 2
|
||||
assert setup_entry.state is ConfigEntryState.NOT_LOADED
|
||||
assert not hass.data.get(DOMAIN)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ from tests.common import MockConfigEntry
|
|||
|
||||
async def test_sensors(hass: HomeAssistant, setup_entry: MockConfigEntry) -> None:
|
||||
"""Test sensors and check test values are correctly set."""
|
||||
assert len(hass.states.async_all("sensor")) == 12
|
||||
assert len(hass.states.async_all("sensor")) == 24
|
||||
assert hass.states.get("sensor.roborock_s7_maxv_main_brush_time_left").state == str(
|
||||
MAIN_BRUSH_REPLACE_TIME - 74382
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue