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:
Péter Sárközi 2023-09-08 23:10:20 +02:00 committed by GitHub
parent 2fd6942de4
commit d9523a0cbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -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...);
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 */

View file

@ -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