mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Fix XOR condition (#5567)
This commit is contained in:
parent
61b8004536
commit
8c2d9101d5
1 changed files with 3 additions and 3 deletions
|
@ -52,12 +52,12 @@ template<typename... Ts> class XorCondition : public Condition<Ts...> {
|
|||
public:
|
||||
explicit XorCondition(const std::vector<Condition<Ts...> *> &conditions) : conditions_(conditions) {}
|
||||
bool check(Ts... x) override {
|
||||
bool xor_state = false;
|
||||
size_t result = 0;
|
||||
for (auto *condition : this->conditions_) {
|
||||
xor_state = xor_state ^ condition->check(x...);
|
||||
result += condition->check(x...);
|
||||
}
|
||||
|
||||
return xor_state;
|
||||
return result == 1;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue