Add digital loggers as a Belkin supported brand (#72515)
This commit is contained in:
parent
a8a033681f
commit
5c5fd746fd
4 changed files with 41 additions and 3 deletions
|
@ -14,5 +14,8 @@
|
||||||
},
|
},
|
||||||
"codeowners": ["@esev"],
|
"codeowners": ["@esev"],
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["pywemo"]
|
"loggers": ["pywemo"],
|
||||||
|
"supported_brands": {
|
||||||
|
"digital_loggers": "Digital Loggers"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ from pywemo.subscribe import EVENT_TYPE_LONG_PRESS
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
ATTR_CONFIGURATION_URL,
|
||||||
|
ATTR_IDENTIFIERS,
|
||||||
CONF_DEVICE_ID,
|
CONF_DEVICE_ID,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PARAMS,
|
CONF_PARAMS,
|
||||||
|
@ -42,7 +44,7 @@ class DeviceCoordinator(DataUpdateCoordinator):
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.wemo = wemo
|
self.wemo = wemo
|
||||||
self.device_id = device_id
|
self.device_id = device_id
|
||||||
self.device_info = _device_info(wemo)
|
self.device_info = _create_device_info(wemo)
|
||||||
self.supports_long_press = wemo.supports_long_press()
|
self.supports_long_press = wemo.supports_long_press()
|
||||||
self.update_lock = asyncio.Lock()
|
self.update_lock = asyncio.Lock()
|
||||||
|
|
||||||
|
@ -124,6 +126,15 @@ class DeviceCoordinator(DataUpdateCoordinator):
|
||||||
raise UpdateFailed("WeMo update failed") from err
|
raise UpdateFailed("WeMo update failed") from err
|
||||||
|
|
||||||
|
|
||||||
|
def _create_device_info(wemo: WeMoDevice) -> DeviceInfo:
|
||||||
|
"""Create device information. Modify if special device."""
|
||||||
|
_dev_info = _device_info(wemo)
|
||||||
|
if wemo.model_name == "DLI emulated Belkin Socket":
|
||||||
|
_dev_info[ATTR_CONFIGURATION_URL] = f"http://{wemo.host}"
|
||||||
|
_dev_info[ATTR_IDENTIFIERS] = {(DOMAIN, wemo.serialnumber[:-1])}
|
||||||
|
return _dev_info
|
||||||
|
|
||||||
|
|
||||||
def _device_info(wemo: WeMoDevice) -> DeviceInfo:
|
def _device_info(wemo: WeMoDevice) -> DeviceInfo:
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
connections={(CONNECTION_UPNP, wemo.udn)},
|
connections={(CONNECTION_UPNP, wemo.udn)},
|
||||||
|
@ -144,7 +155,7 @@ async def async_register_device(
|
||||||
|
|
||||||
device_registry = async_get_device_registry(hass)
|
device_registry = async_get_device_registry(hass)
|
||||||
entry = device_registry.async_get_or_create(
|
entry = device_registry.async_get_or_create(
|
||||||
config_entry_id=config_entry.entry_id, **_device_info(wemo)
|
config_entry_id=config_entry.entry_id, **_create_device_info(wemo)
|
||||||
)
|
)
|
||||||
|
|
||||||
device = DeviceCoordinator(hass, wemo, entry.id)
|
device = DeviceCoordinator(hass, wemo, entry.id)
|
||||||
|
|
|
@ -97,6 +97,15 @@ def pywemo_device_fixture(pywemo_registry, pywemo_model):
|
||||||
yield pywemo_device
|
yield pywemo_device
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name="pywemo_dli_device")
|
||||||
|
def pywemo_dli_device_fixture(pywemo_registry, pywemo_model):
|
||||||
|
"""Fixture for Digital Loggers emulated instances."""
|
||||||
|
with create_pywemo_device(pywemo_registry, pywemo_model) as pywemo_dli_device:
|
||||||
|
pywemo_dli_device.model_name = "DLI emulated Belkin Socket"
|
||||||
|
pywemo_dli_device.serialnumber = "1234567891"
|
||||||
|
yield pywemo_dli_device
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="wemo_entity_suffix")
|
@pytest.fixture(name="wemo_entity_suffix")
|
||||||
def wemo_entity_suffix_fixture():
|
def wemo_entity_suffix_fixture():
|
||||||
"""Fixture to select a specific entity for wemo_entity."""
|
"""Fixture to select a specific entity for wemo_entity."""
|
||||||
|
@ -129,3 +138,9 @@ async def async_create_wemo_entity(hass, pywemo_device, wemo_entity_suffix):
|
||||||
async def async_wemo_entity_fixture(hass, pywemo_device, wemo_entity_suffix):
|
async def async_wemo_entity_fixture(hass, pywemo_device, wemo_entity_suffix):
|
||||||
"""Fixture for a Wemo entity in hass."""
|
"""Fixture for a Wemo entity in hass."""
|
||||||
return await async_create_wemo_entity(hass, pywemo_device, wemo_entity_suffix)
|
return await async_create_wemo_entity(hass, pywemo_device, wemo_entity_suffix)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name="wemo_dli_entity")
|
||||||
|
async def async_wemo_dli_entity_fixture(hass, pywemo_dli_device, wemo_entity_suffix):
|
||||||
|
"""Fixture for a Wemo entity in hass."""
|
||||||
|
return await async_create_wemo_entity(hass, pywemo_dli_device, wemo_entity_suffix)
|
||||||
|
|
|
@ -168,6 +168,15 @@ async def test_device_info(hass, wemo_entity):
|
||||||
assert device_entries[0].sw_version == MOCK_FIRMWARE_VERSION
|
assert device_entries[0].sw_version == MOCK_FIRMWARE_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
async def test_dli_device_info(hass, wemo_dli_entity):
|
||||||
|
"""Verify the DeviceInfo data for Digital Loggers emulated wemo device."""
|
||||||
|
dr = device_registry.async_get(hass)
|
||||||
|
device_entries = list(dr.devices.values())
|
||||||
|
|
||||||
|
assert device_entries[0].configuration_url == "http://127.0.0.1"
|
||||||
|
assert device_entries[0].identifiers == {(DOMAIN, "123456789")}
|
||||||
|
|
||||||
|
|
||||||
class TestInsight:
|
class TestInsight:
|
||||||
"""Tests specific to the WeMo Insight device."""
|
"""Tests specific to the WeMo Insight device."""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue