From 327b366660eb0ddc0e335ddef805026fbd0721ec Mon Sep 17 00:00:00 2001 From: Ross Tyler Date: Thu, 9 Oct 2025 09:50:38 -0700 Subject: [PATCH] remove ESP-IDF guard around ethernet interface __init__.py new interface config is already guarded by config[CONF_TYPE] in SPI_ETHERNET_TYPES in (only) such cases, _validate will provide a default if one not in config _final_validate will use this to check for collision with spi component to_code will generate #define USE_ETHERNET_SPI --- esphome/components/ethernet/__init__.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/esphome/components/ethernet/__init__.py b/esphome/components/ethernet/__init__.py index 4a2bc3d957..b64ada90e3 100644 --- a/esphome/components/ethernet/__init__.py +++ b/esphome/components/ethernet/__init__.py @@ -352,18 +352,16 @@ async def to_code(config): cg.add(var.set_clock_speed(config[CONF_CLOCK_SPEED])) cg.add_define("USE_ETHERNET_SPI") - if CORE.using_esp_idf: - if CONF_INTERFACE in config: - spi_host_device_t = cg.global_ns.enum("spi_host_device_t") - map = { - "spi2": spi_host_device_t.SPI2_HOST, - "spi3": spi_host_device_t.SPI3_HOST, - } - cg.add(var.set_interface(map[config[CONF_INTERFACE]])) - add_idf_sdkconfig_option("CONFIG_ETH_USE_SPI_ETHERNET", True) - add_idf_sdkconfig_option( - f"CONFIG_ETH_SPI_ETHERNET_{config[CONF_TYPE]}", True - ) + + if CONF_INTERFACE in config: + spi_host_device_t = cg.global_ns.enum("spi_host_device_t") + map = { + "spi2": spi_host_device_t.SPI2_HOST, + "spi3": spi_host_device_t.SPI3_HOST, + } + cg.add(var.set_interface(map[config[CONF_INTERFACE]])) + add_idf_sdkconfig_option("CONFIG_ETH_USE_SPI_ETHERNET", True) + add_idf_sdkconfig_option(f"CONFIG_ETH_SPI_ETHERNET_{config[CONF_TYPE]}", True) elif config[CONF_TYPE] == "OPENETH": cg.add_define("USE_ETHERNET_OPENETH") add_idf_sdkconfig_option("CONFIG_ETH_USE_OPENETH", True)