Ignore different patch versions

Change the versioning control to major and minor only, ignoring differences on the patch version.

So components with different patch versions should be able to work with each other as soon the major and minor versions are the same.
This same logic was implemented on the blueprint before the 4.0 release.
This commit is contained in:
Edward Firmo
2023-09-22 10:54:48 +02:00
parent 6ad844a9d8
commit 1065fe0568

View File

@@ -8,7 +8,7 @@
substitutions: substitutions:
##### DON'T CHANGE THIS ##### ##### DON'T CHANGE THIS #####
version: "4.0" version: "4.0.1dev"
############################# #############################
##### WIFI SETUP ##### ##### WIFI SETUP #####
@@ -2202,15 +2202,37 @@ script:
then: then:
- wait_until: - wait_until:
condition: condition:
- lambda: !lambda 'return (id(version_tft) == "${version}");' - lambda: |-
- lambda: !lambda 'return (id(version_blueprint) == "${version}");' auto compareVersions = [](const char* version1, const char* version2) -> bool
{
int major1 = 0, minor1 = 0;
int major2 = 0, minor2 = 0;
sscanf(version1, "%d.%d", &major1, &minor1);
sscanf(version2, "%d.%d", &major2, &minor2);
return (major1 == major2) && (minor1 == minor2);
};
return (compareVersions("${version}", id(version_tft).c_str()) and compareVersions("${version}", id(version_blueprint).c_str()));
#- lambda: !lambda 'return (id(version_tft) == "${version}");'
#- lambda: !lambda 'return (id(version_blueprint) == "${version}");'
timeout: 60s timeout: 60s
- lambda: |- - lambda: |-
auto compareVersions = [](const char* version1, const char* version2) -> bool
{
int major1 = 0, minor1 = 0;
int major2 = 0, minor2 = 0;
sscanf(version1, "%d.%d", &major1, &minor1);
sscanf(version2, "%d.%d", &major2, &minor2);
return (major1 == major2) && (minor1 == minor2);
};
ESP_LOGD("script.check_versions", "ESPHome version: ${version}"); ESP_LOGD("script.check_versions", "ESPHome version: ${version}");
ESP_LOGD("script.check_versions", "TFT version: %s", id(version_tft).c_str()); ESP_LOGD("script.check_versions", "TFT version: %s", id(version_tft).c_str());
if (id(version_tft) != "${version}") ESP_LOGE("script.check_versions", "TFT version mismatch!"); if (not compareVersions("${version}", id(version_tft).c_str())) ESP_LOGE("script.check_versions", "TFT version mismatch!");
ESP_LOGD("script.check_versions", "Blueprint version: %s", id(version_blueprint).c_str()); ESP_LOGD("script.check_versions", "Blueprint version: %s", id(version_blueprint).c_str());
if (id(version_blueprint) != "${version}") ESP_LOGE("script.check_versions", "Blueprint version mismatch!"); if (not compareVersions("${version}", id(version_blueprint).c_str())) ESP_LOGE("script.check_versions", "Blueprint version mismatch!");
auto ha_event = new esphome::api::CustomAPIDevice(); auto ha_event = new esphome::api::CustomAPIDevice();
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{ {