From f2caaf85c89f35fb65d136f38f558da62eb442fa Mon Sep 17 00:00:00 2001 From: Tomek Wasilczyk Date: Sun, 5 May 2024 20:19:13 -0700 Subject: [PATCH] External components: optional configurable path for git source (#6677) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/external_components/__init__.py | 11 ++++++++++- esphome/config_validation.py | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/esphome/components/external_components/__init__.py b/esphome/components/external_components/__init__.py index bbb703dc5..f4432a036 100644 --- a/esphome/components/external_components/__init__.py +++ b/esphome/components/external_components/__init__.py @@ -49,7 +49,16 @@ def _process_git_config(config: dict, refresh) -> str: password=config.get(CONF_PASSWORD), ) - if (repo_dir / "esphome" / "components").is_dir(): + if path := config.get(CONF_PATH): + if (repo_dir / path).is_dir(): + components_dir = repo_dir / path + else: + raise cv.Invalid( + "Could not find components folder for source. Please check the source contains a '" + + path + + "' folder" + ) + elif (repo_dir / "esphome" / "components").is_dir(): components_dir = repo_dir / "esphome" / "components" elif (repo_dir / "components").is_dir(): components_dir = repo_dir / "components" diff --git a/esphome/config_validation.py b/esphome/config_validation.py index 198b44f38..3554f0383 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -2124,6 +2124,7 @@ GIT_SCHEMA = Schema( Optional(CONF_REF): git_ref, Optional(CONF_USERNAME): string, Optional(CONF_PASSWORD): string, + Optional(CONF_PATH): string, } ) LOCAL_SCHEMA = Schema(