mirror of
https://github.com/home-assistant/core.git
synced 2026-04-20 15:45:03 +00:00
add update platform to vesync (#154915)
This commit is contained in:
@@ -25,6 +25,7 @@ PLATFORMS = [
|
||||
Platform.SELECT,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
Platform.UPDATE,
|
||||
]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
68
homeassistant/components/vesync/update.py
Normal file
68
homeassistant/components/vesync/update.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""Update entity for VeSync.."""
|
||||
|
||||
from pyvesync.base_devices.vesyncbasedevice import VeSyncBaseDevice
|
||||
|
||||
from homeassistant.components.update import UpdateDeviceClass, UpdateEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from .const import DOMAIN, VS_COORDINATOR, VS_DEVICES, VS_DISCOVERY, VS_MANAGER
|
||||
from .coordinator import VeSyncDataCoordinator
|
||||
from .entity import VeSyncBaseEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up update entity."""
|
||||
coordinator = hass.data[DOMAIN][VS_COORDINATOR]
|
||||
|
||||
@callback
|
||||
def discover(devices):
|
||||
"""Add new devices to platform."""
|
||||
_setup_entities(devices, async_add_entities, coordinator)
|
||||
|
||||
config_entry.async_on_unload(
|
||||
async_dispatcher_connect(hass, VS_DISCOVERY.format(VS_DEVICES), discover)
|
||||
)
|
||||
|
||||
_setup_entities(
|
||||
hass.data[DOMAIN][VS_MANAGER].devices, async_add_entities, coordinator
|
||||
)
|
||||
|
||||
|
||||
@callback
|
||||
def _setup_entities(
|
||||
devices: list[VeSyncBaseDevice],
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
coordinator: VeSyncDataCoordinator,
|
||||
) -> None:
|
||||
"""Check if device is a light and add entity."""
|
||||
|
||||
async_add_entities(
|
||||
VeSyncDeviceUpdate(
|
||||
device=device,
|
||||
coordinator=coordinator,
|
||||
)
|
||||
for device in devices
|
||||
)
|
||||
|
||||
|
||||
class VeSyncDeviceUpdate(VeSyncBaseEntity, UpdateEntity):
|
||||
"""Representation of a VeSync device update entity."""
|
||||
|
||||
_attr_device_class = UpdateDeviceClass.FIRMWARE
|
||||
|
||||
@property
|
||||
def installed_version(self) -> str | None:
|
||||
"""Return installed_version."""
|
||||
return self.device.current_firm_version
|
||||
|
||||
@property
|
||||
def latest_version(self) -> str | None:
|
||||
"""Return latest_version."""
|
||||
return self.device.latest_firm_version
|
||||
@@ -112,6 +112,7 @@ def mock_devices_response(
|
||||
f"https://smartapi.vesync.com{fixture[1]}",
|
||||
json=load_json_object_fixture(fixture[2], DOMAIN),
|
||||
)
|
||||
mock_firmware(aioclient_mock)
|
||||
|
||||
|
||||
def mock_multiple_device_responses(
|
||||
@@ -148,6 +149,7 @@ def mock_multiple_device_responses(
|
||||
f"https://smartapi.vesync.com{fixture[1]}",
|
||||
json=load_json_object_fixture(fixture[2], DOMAIN),
|
||||
)
|
||||
mock_firmware(aioclient_mock)
|
||||
|
||||
|
||||
def mock_device_response(
|
||||
@@ -176,6 +178,7 @@ def mock_device_response(
|
||||
f"https://smartapi.vesync.com{item[1]}",
|
||||
json=load_and_merge(item[2]),
|
||||
)
|
||||
mock_firmware(aioclient_mock)
|
||||
|
||||
|
||||
def mock_outlet_energy_response(
|
||||
@@ -200,3 +203,11 @@ def mock_outlet_energy_response(
|
||||
f"https://smartapi.vesync.com{fixture[1]}",
|
||||
json=load_and_merge(fixture[2]),
|
||||
)
|
||||
|
||||
|
||||
def mock_firmware(aioclient_mock: AiohttpClientMocker):
|
||||
"""Always mock the firmware update info endpoint with the same fixture."""
|
||||
aioclient_mock.post(
|
||||
"https://smartapi.vesync.com/cloud/v2/deviceManaged/getFirmwareUpdateInfoList",
|
||||
json=load_json_object_fixture("vesync-firmware.json", DOMAIN),
|
||||
)
|
||||
|
||||
@@ -31,15 +31,6 @@ from tests.common import MockConfigEntry
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def patch_vesync_firmware():
|
||||
"""Patch VeSync to disable firmware checks."""
|
||||
with patch(
|
||||
"pyvesync.vesync.VeSync.check_firmware", new=AsyncMock(return_value=True)
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def patch_vesync_login():
|
||||
"""Patch VeSync login method."""
|
||||
@@ -54,13 +45,7 @@ def patch_vesync():
|
||||
"enabled": True,
|
||||
}
|
||||
|
||||
with (
|
||||
patch.multiple(
|
||||
"pyvesync.vesync.VeSync",
|
||||
check_firmware=AsyncMock(return_value=True),
|
||||
),
|
||||
ExitStack() as stack,
|
||||
):
|
||||
with ExitStack() as stack:
|
||||
for name, value in props.items():
|
||||
mock = stack.enter_context(
|
||||
patch.object(VeSync, name, new_callable=PropertyMock)
|
||||
@@ -163,6 +148,7 @@ def fan_fixture():
|
||||
modes=[],
|
||||
connection_status="online",
|
||||
current_firm_version="1.0.0",
|
||||
latest_firm_version="1.0.1",
|
||||
)
|
||||
|
||||
|
||||
@@ -236,6 +222,7 @@ def humidifier_fixture():
|
||||
),
|
||||
connection_status="online",
|
||||
current_firm_version="1.0.0",
|
||||
latest_firm_version="1.0.1",
|
||||
)
|
||||
|
||||
|
||||
@@ -271,6 +258,7 @@ def humidifier_300s_fixture():
|
||||
),
|
||||
config_module="configModule",
|
||||
current_firm_version="1.0.0",
|
||||
latest_firm_version="1.0.1",
|
||||
)
|
||||
|
||||
|
||||
|
||||
301
tests/components/vesync/fixtures/vesync-firmware.json
Normal file
301
tests/components/vesync/fixtures/vesync-firmware.json
Normal file
@@ -0,0 +1,301 @@
|
||||
{
|
||||
"traceId": "1234",
|
||||
"code": 0,
|
||||
"msg": "request success",
|
||||
"module": null,
|
||||
"stacktrace": null,
|
||||
"result": {
|
||||
"cidFwInfoList": [
|
||||
{
|
||||
"deviceCid": "200s-humidifier",
|
||||
"deviceName": "Humidifier 200s",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 100,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "600s-humidifier",
|
||||
"deviceName": "Humidifier 600S",
|
||||
"deviceImg": "https://image.vesync.com/defaultImages/LV_600S_Series/icon_lv600s_humidifier_160.png",
|
||||
"defaultImg": "https://image.vesync.com/defaultImages/LV_600S_Series/icon_lv600s_humidifier_160.png",
|
||||
"uuid": "00000000-1111-2222-3333-555555555555",
|
||||
"configModule": "WFON_AHM_LUH-A602S-WUS_US",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 101,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "air-purifier",
|
||||
"deviceName": "Air Purifier 131s",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 102,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "asd_sdfKIHG7IJHGwJGJ7GJ_ag5h3G55",
|
||||
"deviceName": "Air Purifier 200s",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 103,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "400s-purifier",
|
||||
"deviceName": "Air Purifier 400s",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 104,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "600s-purifier",
|
||||
"deviceName": "Air Purifier 600s",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 105,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "dimmable-bulb",
|
||||
"deviceName": "Dimmable Light",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 106,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "tunable-bulb",
|
||||
"deviceName": "Temperature Light",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 107,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "outlet",
|
||||
"deviceName": "Outlet",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 108,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "switch",
|
||||
"deviceName": "Wall Switch",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 109,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "dimmable-switch",
|
||||
"deviceName": "Dimmer Switch",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 110,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceCid": "smarttowerfan",
|
||||
"deviceName": "SmartTowerFan",
|
||||
"deviceImg": "",
|
||||
"defaultImg": "",
|
||||
"uuid": "00000000-1111-2222-3333-444444444444",
|
||||
"configModule": "configModule",
|
||||
"connectionType": "wifi",
|
||||
"deviceRegion": "US",
|
||||
"code": 0,
|
||||
"msg": null,
|
||||
"firmUpdateInfos": [
|
||||
{
|
||||
"currentVersion": "1.0.0",
|
||||
"latestVersion": "1.0.1",
|
||||
"latestFirmId": 111,
|
||||
"releaseNotes": "Various bug fixes and performance improvements",
|
||||
"pluginName": "mainFw",
|
||||
"priority": 0,
|
||||
"upgradeTimeoutInSec": 180,
|
||||
"isMainFw": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"macIDFwInfoList": null,
|
||||
"configModelFwInfoList": null
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -64,7 +64,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -101,7 +101,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -138,7 +138,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -175,7 +175,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -212,7 +212,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -277,7 +277,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -539,7 +539,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -642,7 +642,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -679,7 +679,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -716,7 +716,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -753,7 +753,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
'get_timer': 'Method',
|
||||
'is_on': 'Method',
|
||||
'last_response': 'Method',
|
||||
'latest_firm_version': 'Method',
|
||||
'latest_firm_version': '1.0.1',
|
||||
'mac_id': 'Method',
|
||||
'manager': 'Method',
|
||||
'method_calls': list([
|
||||
@@ -385,13 +385,40 @@
|
||||
}),
|
||||
'unit_of_measurement': None,
|
||||
}),
|
||||
dict({
|
||||
'device_class': None,
|
||||
'disabled': False,
|
||||
'disabled_by': None,
|
||||
'domain': 'update',
|
||||
'entity_category': 'diagnostic',
|
||||
'entity_id': 'update.test_fan_firmware',
|
||||
'icon': None,
|
||||
'name': None,
|
||||
'original_device_class': 'firmware',
|
||||
'original_icon': None,
|
||||
'original_name': 'Firmware',
|
||||
'state': dict({
|
||||
'attributes': dict({
|
||||
'device_class': 'firmware',
|
||||
'entity_picture': 'https://brands.home-assistant.io/_/vesync/icon.png',
|
||||
'friendly_name': 'Test Fan Firmware',
|
||||
'supported_features': 0,
|
||||
}),
|
||||
'entity_id': 'update.test_fan_firmware',
|
||||
'last_changed': str,
|
||||
'last_reported': str,
|
||||
'last_updated': str,
|
||||
'state': 'unavailable',
|
||||
}),
|
||||
'unit_of_measurement': None,
|
||||
}),
|
||||
]),
|
||||
'name': 'Test Fan',
|
||||
'name_by_user': None,
|
||||
}),
|
||||
'is_on': 'Method',
|
||||
'last_response': 'Method',
|
||||
'latest_firm_version': 'Method',
|
||||
'latest_firm_version': '1.0.1',
|
||||
'mac_id': 'Method',
|
||||
'manager': 'Method',
|
||||
'manual_mode': 'Method',
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -127,7 +127,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -226,7 +226,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -327,7 +327,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -428,7 +428,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -465,7 +465,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -502,7 +502,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -576,7 +576,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -613,7 +613,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -650,7 +650,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -754,7 +754,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -791,7 +791,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -64,7 +64,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -101,7 +101,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -138,7 +138,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -175,7 +175,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -212,7 +212,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -249,7 +249,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -453,7 +453,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -555,7 +555,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -592,7 +592,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -629,7 +629,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -666,7 +666,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -64,7 +64,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -101,7 +101,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -138,7 +138,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -175,7 +175,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -266,7 +266,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -359,7 +359,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -433,7 +433,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -470,7 +470,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -507,7 +507,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -544,7 +544,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -660,7 +660,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -160,7 +160,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -247,7 +247,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -431,7 +431,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -615,7 +615,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -652,7 +652,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -689,7 +689,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -865,7 +865,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -953,7 +953,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -1314,7 +1314,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -1351,7 +1351,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -1388,7 +1388,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -156,7 +156,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -285,7 +285,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -414,7 +414,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -543,7 +543,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -580,7 +580,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -617,7 +617,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -783,7 +783,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -866,7 +866,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -950,7 +950,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -1033,7 +1033,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
@@ -1070,7 +1070,7 @@
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'sw_version': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': None,
|
||||
}),
|
||||
])
|
||||
|
||||
1239
tests/components/vesync/snapshots/test_update.ambr
Normal file
1239
tests/components/vesync/snapshots/test_update.ambr
Normal file
File diff suppressed because it is too large
Load Diff
@@ -110,6 +110,9 @@ async def test_async_get_device_diagnostics__single_fan(
|
||||
"home_assistant.entities.7.state.last_changed": (str,),
|
||||
"home_assistant.entities.7.state.last_reported": (str,),
|
||||
"home_assistant.entities.7.state.last_updated": (str,),
|
||||
"home_assistant.entities.8.state.last_updated": (str,),
|
||||
"home_assistant.entities.8.state.last_changed": (str,),
|
||||
"home_assistant.entities.8.state.last_reported": (str,),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -51,6 +51,7 @@ async def test_async_setup_entry__no_devices(
|
||||
Platform.SELECT,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
Platform.UPDATE,
|
||||
]
|
||||
|
||||
assert manager.login.call_count == 1
|
||||
@@ -79,6 +80,7 @@ async def test_async_setup_entry__loads_fans(
|
||||
Platform.SELECT,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
Platform.UPDATE,
|
||||
]
|
||||
assert manager.login.call_count == 1
|
||||
assert hass.data[DOMAIN][VS_MANAGER] == manager
|
||||
|
||||
51
tests/components/vesync/test_update.py
Normal file
51
tests/components/vesync/test_update.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Tests for the update module."""
|
||||
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.update import DOMAIN as UPDATE_DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from .common import ALL_DEVICE_NAMES, mock_devices_response
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_name", ALL_DEVICE_NAMES)
|
||||
async def test_update_state(
|
||||
hass: HomeAssistant,
|
||||
snapshot: SnapshotAssertion,
|
||||
config_entry: MockConfigEntry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
device_name: str,
|
||||
) -> None:
|
||||
"""Test the resulting setup state is as expected for the platform."""
|
||||
|
||||
# Configure the API devices call for device_name
|
||||
mock_devices_response(aioclient_mock, device_name)
|
||||
|
||||
# setup platform - only including the named device
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Check device registry
|
||||
devices = dr.async_entries_for_config_entry(device_registry, config_entry.entry_id)
|
||||
assert devices == snapshot(name="devices")
|
||||
|
||||
# Check entity registry
|
||||
entities = [
|
||||
entity
|
||||
for entity in er.async_entries_for_config_entry(
|
||||
entity_registry, config_entry.entry_id
|
||||
)
|
||||
if entity.domain == UPDATE_DOMAIN
|
||||
]
|
||||
assert entities == snapshot(name="entities")
|
||||
|
||||
# Check states
|
||||
for entity in entities:
|
||||
assert hass.states.get(entity.entity_id) == snapshot(name=entity.entity_id)
|
||||
Reference in New Issue
Block a user