Add broken link and missing device lists to insteon configuration panel (#119715)
* Add broken link and missing device lists * Fix incorrect import * Add tests * Bump pyinsteon * Typing
This commit is contained in:
parent
90f691fa2c
commit
7433d2eca9
9 changed files with 245 additions and 23 deletions
|
@ -471,3 +471,18 @@ def get_usb_ports() -> dict[str, str]:
|
|||
async def async_get_usb_ports(hass: HomeAssistant) -> dict[str, str]:
|
||||
"""Return a dict of USB ports and their friendly names."""
|
||||
return await hass.async_add_executor_job(get_usb_ports)
|
||||
|
||||
|
||||
def compute_device_name(ha_device) -> str:
|
||||
"""Return the HA device name."""
|
||||
return ha_device.name_by_user if ha_device.name_by_user else ha_device.name
|
||||
|
||||
|
||||
async def async_device_name(dev_registry: dr.DeviceRegistry, address: Address) -> str:
|
||||
"""Get the Insteon device name from a device registry id."""
|
||||
ha_device = dev_registry.async_get_device(identifiers={(DOMAIN, str(address))})
|
||||
if not ha_device:
|
||||
if device := devices[address]:
|
||||
return f"{device.description} ({device.model})"
|
||||
return ""
|
||||
return compute_device_name(ha_device)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue