From 1824c8131e343b2601e290c5db06df12b2706b75 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 16 Dec 2022 19:46:56 +1300 Subject: [PATCH 1/3] Fix import_full_config for adoption configs (#4197) * Fix git raw url * Fix setting full config query param * Force dashboard import urls to have a branch or tag reference for full import --- .../components/dashboard_import/__init__.py | 29 ++++++++++++++----- esphome/git.py | 4 +-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/esphome/components/dashboard_import/__init__.py b/esphome/components/dashboard_import/__init__.py index 4742c77785..0eb65579f9 100644 --- a/esphome/components/dashboard_import/__init__.py +++ b/esphome/components/dashboard_import/__init__.py @@ -4,7 +4,7 @@ import requests import esphome.codegen as cg import esphome.config_validation as cv from esphome.components.packages import validate_source_shorthand -from esphome.const import CONF_WIFI +from esphome.const import CONF_WIFI, CONF_REF from esphome.wizard import wizard_file from esphome.yaml_util import dump from esphome import git @@ -21,19 +21,32 @@ CODEOWNERS = ["@esphome/core"] def validate_import_url(value): value = cv.string_strict(value) value = cv.Length(max=255)(value) - # ignore result, only check if it's a valid shorthand validate_source_shorthand(value) return value +def validate_full_url(config): + if not config[CONF_IMPORT_FULL_CONFIG]: + return config + source = validate_source_shorthand(config[CONF_PACKAGE_IMPORT_URL]) + if CONF_REF not in source: + raise cv.Invalid( + "Must specify a ref (branch or tag) to import from when importing full config" + ) + return config + + CONF_PACKAGE_IMPORT_URL = "package_import_url" CONF_IMPORT_FULL_CONFIG = "import_full_config" -CONFIG_SCHEMA = cv.Schema( - { - cv.Required(CONF_PACKAGE_IMPORT_URL): validate_import_url, - cv.Optional(CONF_IMPORT_FULL_CONFIG, default=False): cv.boolean, - } +CONFIG_SCHEMA = cv.All( + cv.Schema( + { + cv.Required(CONF_PACKAGE_IMPORT_URL): validate_import_url, + cv.Optional(CONF_IMPORT_FULL_CONFIG, default=False): cv.boolean, + } + ), + validate_full_url, ) WIFI_CONFIG = """ @@ -49,7 +62,7 @@ async def to_code(config): url = config[CONF_PACKAGE_IMPORT_URL] if config[CONF_IMPORT_FULL_CONFIG]: url += "?full_config" - cg.add(dashboard_import_ns.set_package_import_url(config[CONF_PACKAGE_IMPORT_URL])) + cg.add(dashboard_import_ns.set_package_import_url(url)) def import_config( diff --git a/esphome/git.py b/esphome/git.py index d3d5996fe3..130cd4f5e1 100644 --- a/esphome/git.py +++ b/esphome/git.py @@ -129,9 +129,9 @@ class GitFile: def raw_url(self) -> str: if self.ref is None: raise ValueError("URL has no ref") - if self.domain == "github": + if self.domain == "github.com": return f"https://raw.githubusercontent.com/{self.owner}/{self.repo}/{self.ref}/{self.filename}" - if self.domain == "gitlab": + if self.domain == "gitlab.com": return f"https://gitlab.com/{self.owner}/{self.repo}/-/raw/{self.ref}/{self.filename}" raise NotImplementedError(f"Git domain {self.domain} not supported") From 42454806561262cc212266fd104cc964f793bfa9 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 19 Dec 2022 11:40:01 -1000 Subject: [PATCH 2/3] Handle zero padding anywhere in the combined adv data (#4208) fixes https://github.com/esphome/issues/issues/3913 --- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp index fb377e2be2..b1d469025b 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp @@ -706,11 +706,7 @@ void ESPBTDevice::parse_adv_(const esp_ble_gap_cb_param_t::ble_scan_result_evt_p while (offset + 2 < len) { const uint8_t field_length = payload[offset++]; // First byte is length of adv record if (field_length == 0) { - if (offset < param.adv_data_len && param.scan_rsp_len > 0) { // Zero padded advertisement data - offset = param.adv_data_len; - continue; - } - break; + continue; // Possible zero padded advertisement data } // first byte of adv record is adv record type From de7f6c3f5f59362975cc44b379d83ab22f6312df Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 20 Dec 2022 10:49:36 +1300 Subject: [PATCH 3/3] Bump version to 2022.12.2 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 465c0a5d83..191af784d2 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2022.12.1" +__version__ = "2022.12.2" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"