diff --git a/esphome/components/light/addressable_light_effect.h b/esphome/components/light/addressable_light_effect.h index 7c66358f2d..53206160c6 100644 --- a/esphome/components/light/addressable_light_effect.h +++ b/esphome/components/light/addressable_light_effect.h @@ -143,6 +143,7 @@ class AddressableScanEffect : public AddressableLightEffect { public: explicit AddressableScanEffect(const std::string &name) : AddressableLightEffect(name) {} void set_move_interval(uint32_t move_interval) { this->move_interval_ = move_interval; } + void set_scan_length(uint32_t scan_length) { this->scan_length_ = scan_length; } void apply(AddressableLight &it, const ESPColor ¤t_color) override { it.all() = ESPColor::BLACK; @@ -168,7 +169,7 @@ class AddressableScanEffect : public AddressableLightEffect { protected: uint32_t move_interval_{}; - uint32_t scan_length_{10}; + uint32_t scan_length_{1}; uint32_t last_move_{0}; int at_led_{0}; bool direction_{true}; diff --git a/esphome/components/light/effects.py b/esphome/components/light/effects.py index a78165fb8a..62e1a87fc9 100644 --- a/esphome/components/light/effects.py +++ b/esphome/components/light/effects.py @@ -16,6 +16,7 @@ from .types import LambdaLightEffect, RandomLightEffect, StrobeLightEffect, \ CONF_ADD_LED_INTERVAL = 'add_led_interval' CONF_REVERSE = 'reverse' CONF_MOVE_INTERVAL = 'move_interval' +CONF_SCAN_LENGTH = 'scan_length' CONF_TWINKLE_PROBABILITY = 'twinkle_probability' CONF_PROGRESS_INTERVAL = 'progress_interval' CONF_SPARK_PROBABILITY = 'spark_probability' @@ -179,10 +180,12 @@ def addressable_color_wipe_effect_to_code(config, effect_id): @register_effect('addressable_scan', AddressableScanEffect, "Scan", { cv.Optional(CONF_MOVE_INTERVAL, default='0.1s'): cv.positive_time_period_milliseconds, + cv.Optional(CONF_SCAN_LENGTH, default=1): cv.All(cv.uint32_t, cv.Range(min=1)) }) def addressable_scan_effect_to_code(config, effect_id): var = cg.new_Pvariable(effect_id, config[CONF_NAME]) cg.add(var.set_move_interval(config[CONF_MOVE_INTERVAL])) + cg.add(var.set_scan_length(config[CONF_SCAN_LENGTH])) yield var