From e15429b0f5e737f3b35a7d279d83303eea14b823 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 9 Oct 2025 13:38:34 -1000 Subject: [PATCH 1/5] [opentherm][ci][tests] Remove redundant ESP32 Arduino tests and simplify conditionals (#11149) --- esphome/components/opentherm/opentherm.cpp | 10 +++++----- esphome/components/opentherm/opentherm.h | 6 +++--- tests/components/opentherm/test.esp32-ard.yaml | 1 - tests/components/opentherm/test.esp32-c3-ard.yaml | 1 - 4 files changed, 8 insertions(+), 10 deletions(-) delete mode 100644 tests/components/opentherm/test.esp32-ard.yaml delete mode 100644 tests/components/opentherm/test.esp32-c3-ard.yaml diff --git a/esphome/components/opentherm/opentherm.cpp b/esphome/components/opentherm/opentherm.cpp index b2751470b2..d59b9584d1 100644 --- a/esphome/components/opentherm/opentherm.cpp +++ b/esphome/components/opentherm/opentherm.cpp @@ -7,7 +7,7 @@ #include "opentherm.h" #include "esphome/core/helpers.h" -#if defined(ESP32) || defined(USE_ESP_IDF) +#ifdef USE_ESP32 #include "driver/timer.h" #include "esp_err.h" #endif @@ -31,7 +31,7 @@ OpenTherm *OpenTherm::instance = nullptr; OpenTherm::OpenTherm(InternalGPIOPin *in_pin, InternalGPIOPin *out_pin, int32_t device_timeout) : in_pin_(in_pin), out_pin_(out_pin), -#if defined(ESP32) || defined(USE_ESP_IDF) +#ifdef USE_ESP32 timer_group_(TIMER_GROUP_0), timer_idx_(TIMER_0), #endif @@ -57,7 +57,7 @@ bool OpenTherm::initialize() { this->out_pin_->setup(); this->out_pin_->digital_write(true); -#if defined(ESP32) || defined(USE_ESP_IDF) +#ifdef USE_ESP32 return this->init_esp32_timer_(); #else return true; @@ -238,7 +238,7 @@ void IRAM_ATTR OpenTherm::write_bit_(uint8_t high, uint8_t clock) { } } -#if defined(ESP32) || defined(USE_ESP_IDF) +#ifdef USE_ESP32 bool OpenTherm::init_esp32_timer_() { // Search for a free timer. Maybe unstable, we'll see. @@ -365,7 +365,7 @@ void IRAM_ATTR OpenTherm::stop_timer_() { } } -#endif // END ESP32 +#endif // USE_ESP32 #ifdef ESP8266 // 5 kHz timer_ diff --git a/esphome/components/opentherm/opentherm.h b/esphome/components/opentherm/opentherm.h index a5822cdfe1..3996481760 100644 --- a/esphome/components/opentherm/opentherm.h +++ b/esphome/components/opentherm/opentherm.h @@ -12,7 +12,7 @@ #include "esphome/core/helpers.h" #include "esphome/core/log.h" -#if defined(ESP32) || defined(USE_ESP_IDF) +#ifdef USE_ESP32 #include "driver/timer.h" #endif @@ -356,7 +356,7 @@ class OpenTherm { ISRInternalGPIOPin isr_in_pin_; ISRInternalGPIOPin isr_out_pin_; -#if defined(ESP32) || defined(USE_ESP_IDF) +#ifdef USE_ESP32 timer_group_t timer_group_; timer_idx_t timer_idx_; #endif @@ -370,7 +370,7 @@ class OpenTherm { int32_t timeout_counter_; // <0 no timeout int32_t device_timeout_; -#if defined(ESP32) || defined(USE_ESP_IDF) +#ifdef USE_ESP32 esp_err_t timer_error_ = ESP_OK; TimerErrorType timer_error_type_ = TimerErrorType::NO_TIMER_ERROR; diff --git a/tests/components/opentherm/test.esp32-ard.yaml b/tests/components/opentherm/test.esp32-ard.yaml deleted file mode 100644 index dade44d145..0000000000 --- a/tests/components/opentherm/test.esp32-ard.yaml +++ /dev/null @@ -1 +0,0 @@ -<<: !include common.yaml diff --git a/tests/components/opentherm/test.esp32-c3-ard.yaml b/tests/components/opentherm/test.esp32-c3-ard.yaml deleted file mode 100644 index dade44d145..0000000000 --- a/tests/components/opentherm/test.esp32-c3-ard.yaml +++ /dev/null @@ -1 +0,0 @@ -<<: !include common.yaml From 590cae13c0905294251a847213c6d5534b91941e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 9 Oct 2025 13:41:50 -1000 Subject: [PATCH 2/5] [ci][tests] Remove redundant ESP32-C3 Arduino tests for non-variant-specific components (#11152) --- tests/components/http_request/test.esp32-c3-ard.yaml | 4 ---- tests/components/nextion/test.esp32-c3-ard.yaml | 10 ---------- tests/components/ota/test.esp32-c3-ard.yaml | 1 - tests/components/web_server/test.esp32-c3-ard.yaml | 1 - 4 files changed, 16 deletions(-) delete mode 100644 tests/components/http_request/test.esp32-c3-ard.yaml delete mode 100644 tests/components/nextion/test.esp32-c3-ard.yaml delete mode 100644 tests/components/ota/test.esp32-c3-ard.yaml delete mode 100644 tests/components/web_server/test.esp32-c3-ard.yaml diff --git a/tests/components/http_request/test.esp32-c3-ard.yaml b/tests/components/http_request/test.esp32-c3-ard.yaml deleted file mode 100644 index c1937b5a10..0000000000 --- a/tests/components/http_request/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,4 +0,0 @@ -substitutions: - verify_ssl: "false" - -<<: !include common.yaml diff --git a/tests/components/nextion/test.esp32-c3-ard.yaml b/tests/components/nextion/test.esp32-c3-ard.yaml deleted file mode 100644 index 5135c7e4f4..0000000000 --- a/tests/components/nextion/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,10 +0,0 @@ -substitutions: - tx_pin: GPIO4 - rx_pin: GPIO5 - -packages: - base: !include common.yaml - -display: - - id: !extend main_lcd - tft_url: http://esphome.io/default35.tft diff --git a/tests/components/ota/test.esp32-c3-ard.yaml b/tests/components/ota/test.esp32-c3-ard.yaml deleted file mode 100644 index dade44d145..0000000000 --- a/tests/components/ota/test.esp32-c3-ard.yaml +++ /dev/null @@ -1 +0,0 @@ -<<: !include common.yaml diff --git a/tests/components/web_server/test.esp32-c3-ard.yaml b/tests/components/web_server/test.esp32-c3-ard.yaml deleted file mode 100644 index 7e6658e20e..0000000000 --- a/tests/components/web_server/test.esp32-c3-ard.yaml +++ /dev/null @@ -1 +0,0 @@ -<<: !include common_v2.yaml From 52219c4dccb03a51d97172b73c92ff3255baf9aa Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 9 Oct 2025 13:45:59 -1000 Subject: [PATCH 3/5] [datetime][ci][tests] Replace test.all.yaml with minimal platform cover (#11151) --- .../components/datetime/{test.all.yaml => test.bk72xx-ard.yaml} | 0 tests/components/datetime/test.esp32-idf.yaml | 1 + tests/components/datetime/test.esp8266-ard.yaml | 1 + tests/components/datetime/test.ln882x-ard.yaml | 1 + tests/components/datetime/test.rp2040-ard.yaml | 1 + 5 files changed, 4 insertions(+) rename tests/components/datetime/{test.all.yaml => test.bk72xx-ard.yaml} (100%) create mode 100644 tests/components/datetime/test.esp32-idf.yaml create mode 100644 tests/components/datetime/test.esp8266-ard.yaml create mode 100644 tests/components/datetime/test.ln882x-ard.yaml create mode 100644 tests/components/datetime/test.rp2040-ard.yaml diff --git a/tests/components/datetime/test.all.yaml b/tests/components/datetime/test.bk72xx-ard.yaml similarity index 100% rename from tests/components/datetime/test.all.yaml rename to tests/components/datetime/test.bk72xx-ard.yaml diff --git a/tests/components/datetime/test.esp32-idf.yaml b/tests/components/datetime/test.esp32-idf.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/datetime/test.esp32-idf.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/datetime/test.esp8266-ard.yaml b/tests/components/datetime/test.esp8266-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/datetime/test.esp8266-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/datetime/test.ln882x-ard.yaml b/tests/components/datetime/test.ln882x-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/datetime/test.ln882x-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/datetime/test.rp2040-ard.yaml b/tests/components/datetime/test.rp2040-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/datetime/test.rp2040-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml From be51093a7e1fae9376aab7c5ce398ba419b07d73 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 9 Oct 2025 17:02:18 -1000 Subject: [PATCH 4/5] [ci][tests] Remove all redundant ESP32-C3 Arduino tests (#11154) --- .../ac_dimmer/test.esp32-c3-ard.yaml | 5 ----- .../captive_portal/test.esp32-c3-ard.yaml | 1 - tests/components/dsmr/test.esp32-c3-ard.yaml | 6 ------ .../esp32_ble/test.esp32-c3-ard.yaml | 1 - .../heatpumpir/test.esp32-c3-ard.yaml | 4 ---- tests/components/i2c/test.esp32-c3-ard.yaml | 5 ----- tests/components/midea/test.esp32-c3-ard.yaml | 6 ------ .../neopixelbus/test.esp32-c3-ard.yaml | 19 ------------------- .../speaker/audio_dac.esp32-c3-ard.yaml | 9 --------- .../components/speaker/test.esp32-c3-ard.yaml | 9 --------- tests/components/spi/test.esp32-c3-ard.yaml | 6 ------ tests/components/wled/test.esp32-c3-ard.yaml | 16 ---------------- 12 files changed, 87 deletions(-) delete mode 100644 tests/components/ac_dimmer/test.esp32-c3-ard.yaml delete mode 100644 tests/components/captive_portal/test.esp32-c3-ard.yaml delete mode 100644 tests/components/dsmr/test.esp32-c3-ard.yaml delete mode 100644 tests/components/esp32_ble/test.esp32-c3-ard.yaml delete mode 100644 tests/components/heatpumpir/test.esp32-c3-ard.yaml delete mode 100644 tests/components/i2c/test.esp32-c3-ard.yaml delete mode 100644 tests/components/midea/test.esp32-c3-ard.yaml delete mode 100644 tests/components/neopixelbus/test.esp32-c3-ard.yaml delete mode 100644 tests/components/speaker/audio_dac.esp32-c3-ard.yaml delete mode 100644 tests/components/speaker/test.esp32-c3-ard.yaml delete mode 100644 tests/components/spi/test.esp32-c3-ard.yaml delete mode 100644 tests/components/wled/test.esp32-c3-ard.yaml diff --git a/tests/components/ac_dimmer/test.esp32-c3-ard.yaml b/tests/components/ac_dimmer/test.esp32-c3-ard.yaml deleted file mode 100644 index 5d2d42b713..0000000000 --- a/tests/components/ac_dimmer/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,5 +0,0 @@ -substitutions: - gate_pin: GPIO5 - zero_cross_pin: GPIO4 - -<<: !include common.yaml diff --git a/tests/components/captive_portal/test.esp32-c3-ard.yaml b/tests/components/captive_portal/test.esp32-c3-ard.yaml deleted file mode 100644 index dade44d145..0000000000 --- a/tests/components/captive_portal/test.esp32-c3-ard.yaml +++ /dev/null @@ -1 +0,0 @@ -<<: !include common.yaml diff --git a/tests/components/dsmr/test.esp32-c3-ard.yaml b/tests/components/dsmr/test.esp32-c3-ard.yaml deleted file mode 100644 index 72998506ac..0000000000 --- a/tests/components/dsmr/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,6 +0,0 @@ -substitutions: - tx_pin: GPIO4 - rx_pin: GPIO5 - request_pin: GPIO6 - -<<: !include common.yaml diff --git a/tests/components/esp32_ble/test.esp32-c3-ard.yaml b/tests/components/esp32_ble/test.esp32-c3-ard.yaml deleted file mode 100644 index dade44d145..0000000000 --- a/tests/components/esp32_ble/test.esp32-c3-ard.yaml +++ /dev/null @@ -1 +0,0 @@ -<<: !include common.yaml diff --git a/tests/components/heatpumpir/test.esp32-c3-ard.yaml b/tests/components/heatpumpir/test.esp32-c3-ard.yaml deleted file mode 100644 index 7b012aa64c..0000000000 --- a/tests/components/heatpumpir/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,4 +0,0 @@ -substitutions: - pin: GPIO2 - -<<: !include common.yaml diff --git a/tests/components/i2c/test.esp32-c3-ard.yaml b/tests/components/i2c/test.esp32-c3-ard.yaml deleted file mode 100644 index ee2c29ca4e..0000000000 --- a/tests/components/i2c/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,5 +0,0 @@ -substitutions: - scl_pin: GPIO5 - sda_pin: GPIO4 - -<<: !include common.yaml diff --git a/tests/components/midea/test.esp32-c3-ard.yaml b/tests/components/midea/test.esp32-c3-ard.yaml deleted file mode 100644 index a879df3ca4..0000000000 --- a/tests/components/midea/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,6 +0,0 @@ -substitutions: - tx_pin: GPIO4 - rx_pin: GPIO5 - pin: GPIO2 - -<<: !include common.yaml diff --git a/tests/components/neopixelbus/test.esp32-c3-ard.yaml b/tests/components/neopixelbus/test.esp32-c3-ard.yaml deleted file mode 100644 index f2b53ab1e9..0000000000 --- a/tests/components/neopixelbus/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,19 +0,0 @@ -light: - - platform: neopixelbus - id: addr3 - name: Neopixelbus Light - gamma_correct: 2.8 - color_correct: [0.0, 0.0, 0.0, 0.0] - default_transition_length: 10s - effects: - - addressable_flicker: - name: Flicker Effect With Custom Values - update_interval: 16ms - intensity: 5% - type: GRBW - variant: SK6812 - method: - type: esp32_rmt - channel: 0 - num_leds: 5 - pin: 4 diff --git a/tests/components/speaker/audio_dac.esp32-c3-ard.yaml b/tests/components/speaker/audio_dac.esp32-c3-ard.yaml deleted file mode 100644 index 1004d2143e..0000000000 --- a/tests/components/speaker/audio_dac.esp32-c3-ard.yaml +++ /dev/null @@ -1,9 +0,0 @@ -substitutions: - scl_pin: GPIO5 - sda_pin: GPIO4 - i2s_bclk_pin: GPIO7 - i2s_lrclk_pin: GPIO6 - i2s_mclk_pin: GPIO9 - i2s_dout_pin: GPIO8 - -<<: !include common-audio_dac.yaml diff --git a/tests/components/speaker/test.esp32-c3-ard.yaml b/tests/components/speaker/test.esp32-c3-ard.yaml deleted file mode 100644 index ddcf051fab..0000000000 --- a/tests/components/speaker/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,9 +0,0 @@ -substitutions: - scl_pin: GPIO5 - sda_pin: GPIO4 - i2s_bclk_pin: GPIO7 - i2s_lrclk_pin: GPIO6 - i2s_mclk_pin: GPIO9 - i2s_dout_pin: GPIO8 - -<<: !include common.yaml diff --git a/tests/components/spi/test.esp32-c3-ard.yaml b/tests/components/spi/test.esp32-c3-ard.yaml deleted file mode 100644 index bfa12b1755..0000000000 --- a/tests/components/spi/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,6 +0,0 @@ -substitutions: - clk_pin: GPIO6 - mosi_pin: GPIO7 - miso_pin: GPIO5 - -<<: !include common.yaml diff --git a/tests/components/wled/test.esp32-c3-ard.yaml b/tests/components/wled/test.esp32-c3-ard.yaml deleted file mode 100644 index 156b31181e..0000000000 --- a/tests/components/wled/test.esp32-c3-ard.yaml +++ /dev/null @@ -1,16 +0,0 @@ -wifi: - ssid: MySSID - password: password1 - -wled: - -light: - - platform: esp32_rmt_led_strip - id: led_matrix_32x8 - default_transition_length: 500ms - chipset: ws2812 - rgb_order: GRB - num_leds: 256 - pin: 2 - effects: - - wled: From cdc87a44456fc813a4f195410b125ea86723245d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 9 Oct 2025 22:46:45 -1000 Subject: [PATCH 5/5] [mdns] Restore mdns_txt_record() public API for external components --- esphome/components/mdns/__init__.py | 83 +++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/esphome/components/mdns/__init__.py b/esphome/components/mdns/__init__.py index 6e148092fe..25c004ac5d 100644 --- a/esphome/components/mdns/__init__.py +++ b/esphome/components/mdns/__init__.py @@ -11,7 +11,7 @@ from esphome.const import ( CONF_SERVICES, PlatformFramework, ) -from esphome.core import CORE, coroutine_with_priority +from esphome.core import CORE, Lambda, coroutine_with_priority from esphome.coroutine import CoroPriority CODEOWNERS = ["@esphome/core"] @@ -58,9 +58,64 @@ CONFIG_SCHEMA = cv.All( ) +def mdns_txt_record(key: str, value: str) -> cg.RawExpression: + """Create a mDNS TXT record. + + Public API for external components. Do not remove. + + Args: + key: The TXT record key + value: The TXT record value (static string only) + + Returns: + A RawExpression representing a MDNSTXTRecord struct + """ + return cg.RawExpression( + f"{{MDNS_STR({cg.safe_exp(key)}), MDNS_STR({cg.safe_exp(value)})}}" + ) + + +async def _mdns_txt_record_templated( + mdns_comp: cg.Pvariable, key: str, value: Lambda | str +) -> cg.RawExpression: + """Create a mDNS TXT record with support for templated values. + + Internal helper function. + + Args: + mdns_comp: The MDNSComponent instance (from cg.get_variable()) + key: The TXT record key + value: The TXT record value (can be a static string or a lambda template) + + Returns: + A RawExpression representing a MDNSTXTRecord struct + """ + if not cg.is_template(value): + # It's a static string - use directly in flash, no need to store in vector + return mdns_txt_record(key, value) + # It's a lambda - evaluate and store using helper + templated_value = await cg.templatable(value, [], cg.std_string) + safe_key = cg.safe_exp(key) + dynamic_call = f"{mdns_comp}->add_dynamic_txt_value(({templated_value})())" + return cg.RawExpression(f"{{MDNS_STR({safe_key}), MDNS_STR({dynamic_call})}}") + + def mdns_service( service: str, proto: str, port: int, txt_records: list[dict[str, str]] -): +) -> cg.StructInitializer: + """Create a mDNS service. + + Public API for external components. Do not remove. + + Args: + service: Service name (e.g., "_http") + proto: Protocol (e.g., "_tcp" or "_udp") + port: Port number + txt_records: List of MDNSTXTRecord expressions + + Returns: + A StructInitializer representing a MDNSService struct + """ return cg.StructInitializer( MDNSService, ("service_type", cg.RawExpression(f"MDNS_STR({cg.safe_exp(service)})")), @@ -120,26 +175,10 @@ async def to_code(config): await cg.register_component(var, config) for service in config[CONF_SERVICES]: - # Build the txt records list for the service - txt_records = [] - for txt_key, txt_value in service[CONF_TXT].items(): - if cg.is_template(txt_value): - # It's a lambda - evaluate and store using helper - templated_value = await cg.templatable(txt_value, [], cg.std_string) - safe_key = cg.safe_exp(txt_key) - dynamic_call = f"{var}->add_dynamic_txt_value(({templated_value})())" - txt_records.append( - cg.RawExpression( - f"{{MDNS_STR({safe_key}), MDNS_STR({dynamic_call})}}" - ) - ) - else: - # It's a static string - use directly in flash, no need to store in vector - txt_records.append( - cg.RawExpression( - f"{{MDNS_STR({cg.safe_exp(txt_key)}), MDNS_STR({cg.safe_exp(txt_value)})}}" - ) - ) + txt_records = [ + await _mdns_txt_record_templated(var, txt_key, txt_value) + for txt_key, txt_value in service[CONF_TXT].items() + ] exp = mdns_service( service[CONF_SERVICE],