mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 16:37:52 +01:00
Fix repeat.count = 0 case (#5364)
* Only play first action if count is non-zero * Add test to yaml * Update test5.yaml
This commit is contained in:
parent
2fd6942de4
commit
d9523a0cbf
@ -249,7 +249,11 @@ template<typename... Ts> class RepeatAction : public Action<Ts...> {
|
||||
void play_complex(Ts... x) override {
|
||||
this->num_running_++;
|
||||
this->var_ = std::make_tuple(x...);
|
||||
this->then_.play(0, x...);
|
||||
if (this->count_.value(x...) > 0) {
|
||||
this->then_.play(0, x...);
|
||||
} else {
|
||||
this->play_next_tuple_(this->var_);
|
||||
}
|
||||
}
|
||||
|
||||
void play(Ts... x) override { /* ignore - see play_complex */
|
||||
|
@ -563,6 +563,13 @@ script:
|
||||
then:
|
||||
- logger.log: looping!
|
||||
|
||||
- id: zero_repeat_test
|
||||
then:
|
||||
- repeat:
|
||||
count: !lambda "return 0;"
|
||||
then:
|
||||
- logger.log: shouldn't see mee!
|
||||
|
||||
switch:
|
||||
- platform: modbus_controller
|
||||
modbus_controller_id: modbus_controller_test
|
||||
|
Loading…
Reference in New Issue
Block a user