mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 11:47:30 +01:00
Fix XOR condition (#5567)
This commit is contained in:
parent
e99b8aaf96
commit
b9d72231b0
@ -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 New Issue
Block a user