Install discovery requirements if used (#29795)

* Install discovery requirements if used

* Update loader.py

* Fix types
This commit is contained in:
Paulus Schoutsen 2019-12-10 09:24:49 +01:00 committed by Pascal Vizeli
parent 0ed6a434f8
commit 27244e29c4
6 changed files with 108 additions and 25 deletions

View file

@ -3,6 +3,8 @@ import pathlib
import re
from typing import Dict, Set
from homeassistant.requirements import DISCOVERY_INTEGRATIONS
from .model import Integration
@ -49,7 +51,6 @@ ALLOWED_USED_COMPONENTS = {
"system_log",
"person",
# Discovery
"ssdp",
"discovery",
# Other
"mjpeg", # base class, has no reqs or component to load.
@ -93,6 +94,13 @@ def validate_dependencies(integration: Integration):
referenced -= set(integration.manifest["dependencies"])
referenced -= set(integration.manifest.get("after_dependencies", []))
# Discovery requirements are ok if referenced in manifest
for check_domain, to_check in DISCOVERY_INTEGRATIONS.items():
if check_domain in referenced and any(
check in integration.manifest for check in to_check
):
referenced.remove(check_domain)
if referenced:
for domain in sorted(referenced):
if (