1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-15 15:18:16 +00:00
This commit is contained in:
Tomasz Duda 2025-01-12 23:50:04 +01:00
parent 9593350596
commit 8158659787

View File

@ -194,10 +194,7 @@ PRELOAD_CONFIG_SCHEMA = cv.Schema(
def _is_target_platform(name): def _is_target_platform(name):
try: try:
from esphome.loader import get_component from esphome.loader import get_component
if get_component(name, True).is_target_platform:
# some components cannot be loaded without platform
component = get_component(name, True)
if component.is_target_platform:
return True return True
except KeyError: except KeyError:
pass pass
@ -206,15 +203,12 @@ def _is_target_platform(name):
def _supported_target_platforms(): def _supported_target_platforms():
target_platforms = [] target_platforms = []
root = Path(__file__).parent.parent root = Path(__file__).parents[1]
components_dir = root / "components" for path in (root / "components").iterdir():
for path in components_dir.iterdir():
if not path.is_dir(): if not path.is_dir():
continue continue
if not (path / "__init__.py").is_file(): if not (path / "__init__.py").is_file():
continue continue
name = path.name name = path.name
if _is_target_platform(name): if _is_target_platform(name):
target_platforms += [name] target_platforms += [name]