From 8c0436cc7e9344c41754820509fcb7e687673fc7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 13 Apr 2026 12:25:38 -1000 Subject: [PATCH] [adc] Move require_adc_oneshot_iram to config validation The esp32 to_code runs at PLATFORM priority (1000) before component to_code at COMPONENT priority (0), so the flag was set too late. Move to config validation to ensure it is set before esp32 processes sdkconfig options. --- esphome/components/adc/sensor.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/esphome/components/adc/sensor.py b/esphome/components/adc/sensor.py index bbd1a280620..2e5c9c07301 100644 --- a/esphome/components/adc/sensor.py +++ b/esphome/components/adc/sensor.py @@ -69,6 +69,13 @@ def validate_config(config): return config +def _require_adc_iram(config): + """Register ADC oneshot IRAM requirement during config validation.""" + if CORE.is_esp32: + require_adc_oneshot_iram() + return config + + ADCSensor = adc_ns.class_( "ADCSensor", sensor.Sensor, cg.PollingComponent, voltage_sampler.VoltageSampler ) @@ -99,6 +106,7 @@ CONFIG_SCHEMA = cv.All( ) .extend(cv.polling_component_schema("60s")), validate_config, + _require_adc_iram, ) CONF_ADC_CHANNEL_ID = "adc_channel_id" @@ -124,7 +132,6 @@ async def to_code(config): if CORE.is_esp32: # Re-enable ESP-IDF's ADC driver (excluded by default to save compile time) include_builtin_idf_component("esp_adc") - require_adc_oneshot_iram() if attenuation := config.get(CONF_ATTENUATION): if attenuation == "auto":