From d8e9688e9ebe7316d0e786d2630c1aaa60676524 Mon Sep 17 00:00:00 2001 From: Maurice Makaay Date: Mon, 19 Dec 2022 15:59:57 +0100 Subject: [PATCH] Add ESPHome version check, to require ESPHome 2022.12.0 or later --- CHANGELOG.md | 16 ++++++++-------- components/xiaomi_bslamp2/__init__.py | 15 ++++++++++++++- doc/release_plan.md | 10 +++++++--- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aa19ec..1ca1f67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,18 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 **Note**: This release requires ESPHome 2022.12.0 and Home Assistant 2021.8.0 or newer. -### Changed +### Fixed - Due to changes in the ESP-IDF framework, and ESPHome 2022.12.0 using the newer version - of the framework, flashing the lamp with ESPHome 2022.12.0 could result in a - failing device. It would not connect to WiFi anymore and serial logging showed a reboot - loop, crashing at the WiFi setup. + of the framework, upgrading the lamp from ESPHome version 2022.11.0 to 2022.12.0 could + result in a failing device. It would not connect to WiFi anymore and serial logging + showed a reboot loop, crashing at the WiFi setup. This release of the lamp firmware forces the use of the last known working version of the ESP-IDF framework. This is not a final solution, because I don't want to be - stuck to old versions for dependencies, but for now this change at least should fix - the issue for users that flash their lamps. + stuck to old versions for dependencies, but for now this change at least prevents + issues for users that flash their lamps. -**If you already flashed your lamp and it ended up bricked**, then check out this -information from the related GitHub issue report: +**If you already flashed your lamp and it ended up bricked, then no worries!** +Things can be fixed. Check out this information from the related GitHub issue report: [https://github.com/mmakaay/esphome-xiaomi_bslamp2/issues/104#issuecomment-1356182034](Fix recipe from issue #104) ## [2021.10.0] 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( diff --git a/doc/release_plan.md b/doc/release_plan.md index b707940..f1cc6f2 100644 --- a/doc/release_plan.md +++ b/doc/release_plan.md @@ -11,9 +11,13 @@ Make sure all notable changes are recorded in the changelog. The minimum ESPHome version requirement must be documented correctly in the following files: - * doc/installation.md (at the start of the file) - * README.md (at the start of the quick start guide) - * CHANGELOG.md (at the start of the log for the released version) + * `doc/installation.md` (at the start of the file) + * `README.md` (at the start of the quick start guide) + * `CHANGELOG.md` (at the start of the log for the released version) + * `components/xiaomi_bslamp2/__init__.py` in the function + `check_version_compatibility()`. This function can also be used + to check the maximum version of ESPHome that can be used. An example + of this use can be found in the `release/2021.10.0` branch. **Create version release branch**