From 1ffc209a44b9e8266af929442f5f4f8a7b596c01 Mon Sep 17 00:00:00 2001 From: Maurice Makaay Date: Mon, 19 Dec 2022 16:03:29 +0100 Subject: [PATCH] Add new version check to dev as well --- components/xiaomi_bslamp2/__init__.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/xiaomi_bslamp2/__init__.py b/components/xiaomi_bslamp2/__init__.py index 62e4ebf..ce40e5a 100644 --- a/components/xiaomi_bslamp2/__init__.py +++ b/components/xiaomi_bslamp2/__init__.py @@ -8,6 +8,8 @@ from esphome.const import ( CONF_LIGHT, CONF_RED, CONF_GREEN, CONF_BLUE, CONF_WHITE, CONF_I2C, CONF_ADDRESS, CONF_TRIGGER_PIN, CONF_ID ) +from esphome.util import parse_esphome_version +from voluptuous import Invalid CODEOWNERS = ["@mmakaay"] @@ -40,8 +42,19 @@ FRONT_PANEL_LED_OPTIONS = { "10": FrontPanelLEDs.LED_10, } + +def check_version_compatibility(config): + esphome_version = parse_esphome_version() + if esphome_version < (2022, 12, 0): + raise Invalid( + "This xiaomi_bslamp2 component requires at least ESPHome " + + "version 2022.12.0; Please upgrade ESPHome and try again." + ) + return config + + CONFIG_SCHEMA = cv.All( - cv.require_esphome_version(2022, 12, 0), + check_version_compatibility, cv.COMPONENT_SCHEMA.extend({ # RGBWW Light cv.Required(CONF_LIGHT): cv.Schema(