mirror of
https://github.com/esphome/esphome.git
synced 2025-09-22 21:22:22 +01:00
Add min_version to esphome config (#3866)
This commit is contained in:
@@ -15,6 +15,7 @@ from esphome.const import (
|
||||
CONF_FRAMEWORK,
|
||||
CONF_INCLUDES,
|
||||
CONF_LIBRARIES,
|
||||
CONF_MIN_VERSION,
|
||||
CONF_NAME,
|
||||
CONF_ON_BOOT,
|
||||
CONF_ON_LOOP,
|
||||
@@ -30,6 +31,7 @@ from esphome.const import (
|
||||
KEY_CORE,
|
||||
TARGET_PLATFORMS,
|
||||
PLATFORM_ESP8266,
|
||||
__version__ as ESPHOME_VERSION,
|
||||
)
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
from esphome.helpers import copy_file_if_changed, walk_files
|
||||
@@ -96,6 +98,16 @@ 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
|
||||
|
||||
|
||||
CONF_ESP8266_RESTORE_FROM_FLASH = "esp8266_restore_from_flash"
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
@@ -136,6 +148,9 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.Required(CONF_VERSION): cv.string_strict,
|
||||
}
|
||||
),
|
||||
cv.Optional(CONF_MIN_VERSION, default=ESPHOME_VERSION): cv.All(
|
||||
cv.version_number, validate_version
|
||||
),
|
||||
}
|
||||
),
|
||||
validate_hostname,
|
||||
|
Reference in New Issue
Block a user