Add support for USB discovery (#54904)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
11c6a33594
commit
dc74a52f58
22 changed files with 718 additions and 0 deletions
|
@ -26,6 +26,7 @@ from awesomeversion import (
|
|||
from homeassistant.generated.dhcp import DHCP
|
||||
from homeassistant.generated.mqtt import MQTT
|
||||
from homeassistant.generated.ssdp import SSDP
|
||||
from homeassistant.generated.usb import USB
|
||||
from homeassistant.generated.zeroconf import HOMEKIT, ZEROCONF
|
||||
from homeassistant.util.async_ import gather_with_concurrency
|
||||
|
||||
|
@ -81,6 +82,7 @@ class Manifest(TypedDict, total=False):
|
|||
ssdp: list[dict[str, str]]
|
||||
zeroconf: list[str | dict[str, str]]
|
||||
dhcp: list[dict[str, str]]
|
||||
usb: list[dict[str, str]]
|
||||
homekit: dict[str, list[str]]
|
||||
is_built_in: bool
|
||||
version: str
|
||||
|
@ -219,6 +221,20 @@ async def async_get_dhcp(hass: HomeAssistant) -> list[dict[str, str]]:
|
|||
return dhcp
|
||||
|
||||
|
||||
async def async_get_usb(hass: HomeAssistant) -> list[dict[str, str]]:
|
||||
"""Return cached list of usb types."""
|
||||
usb: list[dict[str, str]] = USB.copy()
|
||||
|
||||
integrations = await async_get_custom_components(hass)
|
||||
for integration in integrations.values():
|
||||
if not integration.usb:
|
||||
continue
|
||||
for entry in integration.usb:
|
||||
usb.append({"domain": integration.domain, **entry})
|
||||
|
||||
return usb
|
||||
|
||||
|
||||
async def async_get_homekit(hass: HomeAssistant) -> dict[str, str]:
|
||||
"""Return cached list of homekit models."""
|
||||
|
||||
|
@ -423,6 +439,11 @@ class Integration:
|
|||
"""Return Integration dhcp entries."""
|
||||
return self.manifest.get("dhcp")
|
||||
|
||||
@property
|
||||
def usb(self) -> list[dict[str, str]] | None:
|
||||
"""Return Integration usb entries."""
|
||||
return self.manifest.get("usb")
|
||||
|
||||
@property
|
||||
def homekit(self) -> dict[str, list[str]] | None:
|
||||
"""Return Integration homekit entries."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue