diff --git a/esphome/components/sds011/sds011.h b/esphome/components/sds011/sds011.h index 3be74e66d10..d65299c6350 100644 --- a/esphome/components/sds011/sds011.h +++ b/esphome/components/sds011/sds011.h @@ -21,8 +21,6 @@ class SDS011Component : public Component, public uart::UARTDevice { void dump_config() override; void loop() override; - void set_update_interval(uint32_t val) { /* ignore */ - } void set_update_interval_min(uint8_t update_interval_min); void set_working_state(bool working_state); diff --git a/esphome/components/sds011/sensor.py b/esphome/components/sds011/sensor.py index ae1cc58a950..76abc70bb70 100644 --- a/esphome/components/sds011/sensor.py +++ b/esphome/components/sds011/sensor.py @@ -64,12 +64,15 @@ CONFIG_SCHEMA = cv.All( async def to_code(config): + # Pop update_interval before register_component so it doesn't generate + # a set_update_interval call — sds011 handles this via set_update_interval_min + update_interval = config.pop(CONF_UPDATE_INTERVAL, None) var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) await uart.register_uart_device(var, config) - if CONF_UPDATE_INTERVAL in config: - cg.add(var.set_update_interval_min(config[CONF_UPDATE_INTERVAL])) + if update_interval is not None: + cg.add(var.set_update_interval_min(update_interval)) cg.add(var.set_rx_mode_only(config[CONF_RX_ONLY])) if CONF_PM_2_5 in config: diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index bfe9beb2723..a9e93f9131e 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -508,7 +508,6 @@ void PollingComponent::stop_poller() { } uint32_t PollingComponent::get_update_interval() const { return this->update_interval_; } -void PollingComponent::set_update_interval(uint32_t update_interval) { this->update_interval_ = update_interval; } void __attribute__((noinline, cold)) WarnIfComponentBlockingGuard::warn_blocking(Component *component, uint32_t blocking_time) { diff --git a/esphome/core/component.h b/esphome/core/component.h index 557ba09bbc9..02598b53ff5 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -548,12 +548,10 @@ class PollingComponent : public Component { explicit PollingComponent(uint32_t update_interval); /** Manually set the update interval in ms for this polling object. - * - * Override this if you want to do some validation for the update interval. * * @param update_interval The update interval in ms. */ - virtual void set_update_interval(uint32_t update_interval); + void set_update_interval(uint32_t update_interval) { this->update_interval_ = update_interval; } // ========== OVERRIDE METHODS ========== // (You'll only need this when creating your own custom sensor)