From 9894bdc0f1ee40f33537d31e10ed63a1f2cc4a0d Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Mon, 6 Apr 2026 23:03:57 -0400 Subject: [PATCH 1/2] [multiple] Fix misc low-priority bugs (batch 3) (#15506) --- esphome/components/display_menu_base/__init__.py | 2 +- esphome/components/ens160_base/__init__.py | 1 - esphome/components/font/__init__.py | 2 +- esphome/components/shelly_dimmer/light.py | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/esphome/components/display_menu_base/__init__.py b/esphome/components/display_menu_base/__init__.py index c9a0c7ee93..9125c43f0c 100644 --- a/esphome/components/display_menu_base/__init__.py +++ b/esphome/components/display_menu_base/__init__.py @@ -119,7 +119,7 @@ DisplayMenuOnPrevTrigger = display_menu_base_ns.class_( def validate_format(format): - if re.search(r"^%([+-])*(\d+)*(\.\d+)*[fg]$", format) is None: + if re.search(r"^%[+-]*(\d+)?(\.\d+)?[fg]$", format) is None: raise cv.Invalid( f"{CONF_FORMAT}: has to specify a printf-like format string specifying exactly one f or g type conversion, '{format}' provided" ) diff --git a/esphome/components/ens160_base/__init__.py b/esphome/components/ens160_base/__init__.py index 3b6ad8a4ee..46c53c3b10 100644 --- a/esphome/components/ens160_base/__init__.py +++ b/esphome/components/ens160_base/__init__.py @@ -24,7 +24,6 @@ CODEOWNERS = ["@vincentscode", "@latonita"] ens160_ns = cg.esphome_ns.namespace("ens160_base") CONF_AQI = "aqi" -UNIT_INDEX = "index" CONFIG_SCHEMA_BASE = cv.Schema( { diff --git a/esphome/components/font/__init__.py b/esphome/components/font/__init__.py index c8813bf1bc..a1339a4bc1 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -238,7 +238,7 @@ def validate_font_config(config): return config -FONT_EXTENSIONS = (".ttf", ".woff", ".otf", "bdf", ".pcf") +FONT_EXTENSIONS = (".ttf", ".woff", ".otf", ".bdf", ".pcf") def validate_truetype_file(value): diff --git a/esphome/components/shelly_dimmer/light.py b/esphome/components/shelly_dimmer/light.py index c1e9cad358..1688f9d6a6 100644 --- a/esphome/components/shelly_dimmer/light.py +++ b/esphome/components/shelly_dimmer/light.py @@ -67,7 +67,7 @@ KNOWN_FIRMWARE = { def parse_firmware_version(value): - match = re.match(r"(\d+).(\d+)", value) + match = re.fullmatch(r"(\d+)\.(\d+)", value) if match is None: raise ValueError(f"Not a valid version number {value}") major = int(match[1]) @@ -129,7 +129,7 @@ def validate_firmware(value): def validate_sha256(value): value = cv.string(value) - if not value.isalnum() or not len(value) == 64: + if not re.fullmatch(r"[0-9a-fA-F]{64}", value): raise ValueError(f"Not a valid SHA256 hex string: {value}") return value From b6ef1a58fb0c92dcc93388ab816cc6cd76b879af Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Mon, 6 Apr 2026 23:17:35 -0400 Subject: [PATCH 2/2] [multiple] Fix validation ranges and error messages (#15508) --- esphome/components/bmp581_spi/sensor.py | 2 +- esphome/components/mcp23s08/__init__.py | 2 +- esphome/components/mcp23s17/__init__.py | 2 +- esphome/components/pcd8544/display.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/bmp581_spi/sensor.py b/esphome/components/bmp581_spi/sensor.py index 75f60b2460..db0d0cd529 100644 --- a/esphome/components/bmp581_spi/sensor.py +++ b/esphome/components/bmp581_spi/sensor.py @@ -31,7 +31,7 @@ BMP581SPIComponent = bmp581_ns.class_( def check_spi_mode(config): spi_mode = config.get(CONF_SPI_MODE) if spi_mode not in VALID_SPI_MODES: - raise cv.Invalid("BMP581 only supports SPI mode 3") + raise cv.Invalid("BMP581 only supports SPI mode 0 or mode 3") return config diff --git a/esphome/components/mcp23s08/__init__.py b/esphome/components/mcp23s08/__init__.py index 3d4e304f9b..312da79b75 100644 --- a/esphome/components/mcp23s08/__init__.py +++ b/esphome/components/mcp23s08/__init__.py @@ -18,7 +18,7 @@ CONFIG_SCHEMA = ( cv.Schema( { cv.Required(CONF_ID): cv.declare_id(mcp23S08), - cv.Optional(CONF_DEVICEADDRESS, default=0): cv.uint8_t, + cv.Optional(CONF_DEVICEADDRESS, default=0): cv.int_range(min=0, max=3), } ) .extend(mcp23xxx_base.MCP23XXX_CONFIG_SCHEMA) diff --git a/esphome/components/mcp23s17/__init__.py b/esphome/components/mcp23s17/__init__.py index ea8433af2e..599bfa0851 100644 --- a/esphome/components/mcp23s17/__init__.py +++ b/esphome/components/mcp23s17/__init__.py @@ -18,7 +18,7 @@ CONFIG_SCHEMA = ( cv.Schema( { cv.Required(CONF_ID): cv.declare_id(mcp23S17), - cv.Optional(CONF_DEVICEADDRESS, default=0): cv.uint8_t, + cv.Optional(CONF_DEVICEADDRESS, default=0): cv.int_range(min=0, max=7), } ) .extend(mcp23xxx_base.MCP23XXX_CONFIG_SCHEMA) diff --git a/esphome/components/pcd8544/display.py b/esphome/components/pcd8544/display.py index 9d993c2105..2f6dcc56ed 100644 --- a/esphome/components/pcd8544/display.py +++ b/esphome/components/pcd8544/display.py @@ -27,7 +27,7 @@ CONFIG_SCHEMA = cv.All( cv.Required(CONF_DC_PIN): pins.gpio_output_pin_schema, cv.Required(CONF_RESET_PIN): pins.gpio_output_pin_schema, cv.Required(CONF_CS_PIN): pins.gpio_output_pin_schema, # CE - cv.Optional(CONF_CONTRAST, default=0x7F): cv.int_, + cv.Optional(CONF_CONTRAST, default=0x7F): cv.int_range(min=0, max=127), } ) .extend(cv.polling_component_schema("1s"))