mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 23:18:10 +01:00
Add optional minimum esphome version to microWakeWord manifest (#6240)
This commit is contained in:
parent
29ec40db5f
commit
6eb3c65445
3 changed files with 16 additions and 11 deletions
|
@ -103,6 +103,7 @@ KEY_AUTHOR = "author"
|
|||
KEY_WEBSITE = "website"
|
||||
KEY_VERSION = "version"
|
||||
KEY_MICRO = "micro"
|
||||
KEY_MINIMUM_ESPHOME_VERSION = "minimum_esphome_version"
|
||||
|
||||
MANIFEST_SCHEMA_V1 = cv.Schema(
|
||||
{
|
||||
|
@ -116,6 +117,9 @@ MANIFEST_SCHEMA_V1 = cv.Schema(
|
|||
{
|
||||
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
|
||||
),
|
||||
}
|
||||
),
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ from esphome.const import (
|
|||
TYPE_GIT,
|
||||
TYPE_LOCAL,
|
||||
VALID_SUBSTITUTIONS_CHARACTERS,
|
||||
__version__ as ESPHOME_VERSION,
|
||||
)
|
||||
from esphome.core import (
|
||||
CORE,
|
||||
|
@ -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
|
||||
|
|
|
@ -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"]),
|
||||
|
@ -164,7 +154,7 @@ CONFIG_SCHEMA = cv.All(
|
|||
}
|
||||
),
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue