Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional minimum esphome version to microWakeWord manifest #6240

Merged
merged 2 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions esphome/components/micro_wake_word/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def _process_git_source(config):
KEY_WEBSITE = "website"
KEY_VERSION = "version"
KEY_MICRO = "micro"
KEY_MINIMUM_ESPHOME_VERSION = "minimum_esphome_version"

MANIFEST_SCHEMA_V1 = cv.Schema(
{
Expand All @@ -116,6 +117,9 @@ def _process_git_source(config):
{
cv.Required(CONF_PROBABILITY_CUTOFF): cv.float_,
cv.Required(CONF_SLIDING_WINDOW_AVERAGE_SIZE): cv.positive_int,
cv.Optional(KEY_MINIMUM_ESPHOME_VERSION): cv.All(
cv.version_number, cv.validate_esphome_version
),
}
),
}
Expand Down
11 changes: 11 additions & 0 deletions esphome/config_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
TYPE_GIT,
TYPE_LOCAL,
VALID_SUBSTITUTIONS_CHARACTERS,
__version__ as ESPHOME_VERSION,
)
from esphome.core import (
CORE,
Expand Down Expand Up @@ -1895,6 +1896,16 @@ def version_number(value):
raise Invalid("Not a valid version number") from e


def validate_esphome_version(value: str):
min_version = Version.parse(value)
current_version = Version.parse(ESPHOME_VERSION)
if current_version < min_version:
raise Invalid(
f"Your ESPHome version is too old. Please update to at least {min_version}"
)
return value


def platformio_version_constraint(value):
# for documentation on valid version constraints:
# https://docs.platformio.org/en/latest/core/userguide/platforms/cmd_install.html#cmd-platform-install
Expand Down
12 changes: 1 addition & 11 deletions esphome/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,6 @@ def valid_project_name(value: str):
return value


def validate_version(value: str):
min_version = cv.Version.parse(value)
current_version = cv.Version.parse(ESPHOME_VERSION)
if current_version < min_version:
raise cv.Invalid(
f"Your ESPHome version is too old. Please update to at least {min_version}"
)
return value


if "ESPHOME_DEFAULT_COMPILE_PROCESS_LIMIT" in os.environ:
_compile_process_limit_default = min(
int(os.environ["ESPHOME_DEFAULT_COMPILE_PROCESS_LIMIT"]),
Expand Down Expand Up @@ -164,7 +154,7 @@ def validate_version(value: str):
}
),
cv.Optional(CONF_MIN_VERSION, default=ESPHOME_VERSION): cv.All(
cv.version_number, validate_version
cv.version_number, cv.validate_esphome_version
),
cv.Optional(
CONF_COMPILE_PROCESS_LIMIT, default=_compile_process_limit_default
Expand Down