From 3317eaebc70f68171950a84ac79affa95fc65e1c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 13 Apr 2026 12:26:35 -1000 Subject: [PATCH] [ledc] Move require_ledc_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. FINAL_VALIDATE_SCHEMA also runs too late for this purpose. Move to CONFIG_SCHEMA validation to ensure it is set before esp32 processes sdkconfig options. --- esphome/components/ledc/output.py | 33 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/esphome/components/ledc/output.py b/esphome/components/ledc/output.py index 332a9c6258..48e72d4c38 100644 --- a/esphome/components/ledc/output.py +++ b/esphome/components/ledc/output.py @@ -42,28 +42,29 @@ ledc_ns = cg.esphome_ns.namespace("ledc") LEDCOutput = ledc_ns.class_("LEDCOutput", output.FloatOutput, cg.Component) SetFrequencyAction = ledc_ns.class_("SetFrequencyAction", automation.Action) -CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( - { - cv.Required(CONF_ID): cv.declare_id(LEDCOutput), - cv.Required(CONF_PIN): pins.internal_gpio_output_pin_schema, - cv.Optional(CONF_FREQUENCY, default="1kHz"): cv.All( - cv.frequency, cv.float_range(min=0, min_included=False) - ), - cv.Optional(CONF_CHANNEL): cv.int_range(min=0, max=15), - cv.Optional(CONF_PHASE_ANGLE): cv.All( - cv.angle, cv.float_range(min=0.0, max=360.0) - ), - } -).extend(cv.COMPONENT_SCHEMA) - -def _require_ledc_iram(config): +def _require_ledc_iram_validator(config): """Register LEDC IRAM requirement during config validation.""" require_ledc_iram() return config -FINAL_VALIDATE_SCHEMA = _require_ledc_iram +CONFIG_SCHEMA = cv.All( + output.FLOAT_OUTPUT_SCHEMA.extend( + { + cv.Required(CONF_ID): cv.declare_id(LEDCOutput), + cv.Required(CONF_PIN): pins.internal_gpio_output_pin_schema, + cv.Optional(CONF_FREQUENCY, default="1kHz"): cv.All( + cv.frequency, cv.float_range(min=0, min_included=False) + ), + cv.Optional(CONF_CHANNEL): cv.int_range(min=0, max=15), + cv.Optional(CONF_PHASE_ANGLE): cv.All( + cv.angle, cv.float_range(min=0.0, max=360.0) + ), + } + ).extend(cv.COMPONENT_SCHEMA), + _require_ledc_iram_validator, +) async def to_code(config):