mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 04:05:20 +01:00
Install discovery requirements if used (#29795)
* Install discovery requirements if used * Update loader.py * Fix types
This commit is contained in:
committed by
Pascal Vizeli
parent
0ed6a434f8
commit
27244e29c4
@@ -3,7 +3,7 @@ import asyncio
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Set
|
||||
from typing import Any, Dict, List, Optional, Set, Iterable
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
@@ -15,6 +15,10 @@ DATA_PKG_CACHE = "pkg_cache"
|
||||
CONSTRAINT_FILE = "package_constraints.txt"
|
||||
PROGRESS_FILE = ".pip_progress"
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
DISCOVERY_INTEGRATIONS: Dict[str, Iterable[str]] = {
|
||||
"ssdp": ("ssdp",),
|
||||
"zeroconf": ("zeroconf", "homekit"),
|
||||
}
|
||||
|
||||
|
||||
class RequirementsNotFound(HomeAssistantError):
|
||||
@@ -30,7 +34,7 @@ class RequirementsNotFound(HomeAssistantError):
|
||||
async def async_get_integration_with_requirements(
|
||||
hass: HomeAssistant, domain: str, done: Set[str] = None
|
||||
) -> Integration:
|
||||
"""Get an integration with installed requirements.
|
||||
"""Get an integration with all requirements installed, including the dependencies.
|
||||
|
||||
This can raise IntegrationNotFound if manifest or integration
|
||||
is invalid, RequirementNotFound if there was some type of
|
||||
@@ -53,10 +57,18 @@ async def async_get_integration_with_requirements(
|
||||
|
||||
deps_to_check = [
|
||||
dep
|
||||
for dep in integration.dependencies + (integration.after_dependencies or [])
|
||||
for dep in integration.dependencies + integration.after_dependencies
|
||||
if dep not in done
|
||||
]
|
||||
|
||||
for check_domain, to_check in DISCOVERY_INTEGRATIONS.items():
|
||||
if (
|
||||
check_domain not in done
|
||||
and check_domain not in deps_to_check
|
||||
and any(check in integration.manifest for check in to_check)
|
||||
):
|
||||
deps_to_check.append(check_domain)
|
||||
|
||||
if deps_to_check:
|
||||
await asyncio.gather(
|
||||
*[
|
||||
|
||||
Reference in New Issue
Block a user