From 26048d18ef3a674847d9b14b6f396b57949b7279 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 9 May 2024 13:08:30 +1000 Subject: [PATCH 1/4] [core] Ensure that a generated ID name is distinct from its type. (#6706) --- esphome/core/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 58ae23e139..f25891965a 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -340,6 +340,8 @@ class ID: if self.id is None: base = str(self.type).replace("::", "_").lower() + if base == self.type: + base = base + "_id" name = "".join(c for c in base if c.isalnum() or c == "_") used = set(registered_ids) | set(RESERVED_IDS) | CORE.loaded_integrations self.id = ensure_unique_string(name, used) From 819bb9f8bc82603e370a3e94bfdb47fbb1bdb9f2 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 9 May 2024 13:14:31 +1000 Subject: [PATCH 2/4] [color] Fix crash when hex color parses as int, improve error reporting. (#6707) --- esphome/components/color/__init__.py | 40 +++++++++++++++++++++------- tests/components/color/common.yaml | 9 +++++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/esphome/components/color/__init__.py b/esphome/components/color/__init__.py index 4a55beef38..609d416a0b 100644 --- a/esphome/components/color/__init__.py +++ b/esphome/components/color/__init__.py @@ -14,15 +14,41 @@ CONF_HEX = "hex" def hex_color(value): + if isinstance(value, int): + value = str(value) + if not isinstance(value, str): + raise cv.Invalid("Invalid value for hex color") if len(value) != 6: - raise cv.Invalid("Color must have six digits") + raise cv.Invalid("Hex color must have six digits") try: - return (int(value[0:2], 16), int(value[2:4], 16), int(value[4:6], 16)) + return int(value[0:2], 16), int(value[2:4], 16), int(value[4:6], 16) except ValueError as exc: raise cv.Invalid("Color must be hexadecimal") from exc -CONFIG_SCHEMA = cv.Any( +components = { + CONF_RED, + CONF_RED_INT, + CONF_GREEN, + CONF_GREEN_INT, + CONF_BLUE, + CONF_BLUE_INT, + CONF_WHITE, + CONF_WHITE_INT, +} + + +def validate_color(config): + has_components = set(config) & components + has_hex = CONF_HEX in config + if has_hex and has_components: + raise cv.Invalid("Hex color value may not be combined with component values") + if not has_hex and not has_components: + raise cv.Invalid("Must provide at least one color option") + return config + + +CONFIG_SCHEMA = cv.All( cv.Schema( { cv.Required(CONF_ID): cv.declare_id(ColorStruct), @@ -34,14 +60,10 @@ CONFIG_SCHEMA = cv.Any( cv.Exclusive(CONF_BLUE_INT, "blue"): cv.uint8_t, cv.Exclusive(CONF_WHITE, "white"): cv.percentage, cv.Exclusive(CONF_WHITE_INT, "white"): cv.uint8_t, + cv.Optional(CONF_HEX): hex_color, } ).extend(cv.COMPONENT_SCHEMA), - cv.Schema( - { - cv.Required(CONF_ID): cv.declare_id(ColorStruct), - cv.Required(CONF_HEX): hex_color, - } - ).extend(cv.COMPONENT_SCHEMA), + validate_color, ) diff --git a/tests/components/color/common.yaml b/tests/components/color/common.yaml index 7aa308bb63..88524e6a5f 100644 --- a/tests/components/color/common.yaml +++ b/tests/components/color/common.yaml @@ -9,3 +9,12 @@ color: blue: 100% - id: kbx_green hex: "3DEC55" + - id: kbx_green_1 + hex: 3DEC55 + - id: cps_red + hex: 800000 + - id: cps_green + hex: 008000 + - id: cps_blue + hex: 000080 + From bd776baf8dfddac65590162f10375604a60e3a07 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 9 May 2024 21:25:48 +1200 Subject: [PATCH 3/4] [github] Fix digest artifact name (#6710) --- .github/workflows/release.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5002f041e1..03ed523e1d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -132,10 +132,16 @@ jobs: suffix: lint version: ${{ needs.init.outputs.tag }} + - name: Sanitize platform name + id: sanitize + run: | + echo "${{ matrix.platform }}" | sed 's|/|-|g' > /tmp/platform + echo name=$(cat /tmp/platform) >> $GITHUB_OUTPUT + - name: Upload digests uses: actions/upload-artifact@v4.3.3 with: - name: digests-${{ matrix.platform }} + name: digests-${{ steps.sanitize.outputs.name }} path: /tmp/digests retention-days: 1 From 8ae8cd1168bcdac80bb4de76255c6b2894179e07 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 9 May 2024 21:55:34 +1200 Subject: [PATCH 4/4] Bump version to 2024.5.0b3 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 46fc5fc20b..6e00c1bbe1 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2024.5.0b2" +__version__ = "2024.5.0b3" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = (