Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XOR ArithmeticGroupFunction #4385

Closed
fabianvo opened this issue Sep 19, 2024 · 4 comments · Fixed by #4386
Closed

Add XOR ArithmeticGroupFunction #4385

fabianvo opened this issue Sep 19, 2024 · 4 comments · Fixed by #4386
Labels
enhancement An enhancement or new feature of the Core

Comments

@fabianvo
Copy link
Contributor

It would be nice to be able to XOR (not just AND, OR, NAND, NOR) states.

@fabianvo fabianvo added the enhancement An enhancement or new feature of the Core label Sep 19, 2024
fabianvo pushed a commit to fabianvo/openhab-core that referenced this issue Sep 19, 2024
@jimtng
Copy link
Contributor

jimtng commented Sep 20, 2024

I'm curious to learn the use case for this.

@fabianvo
Copy link
Contributor Author

It is somewhat exotic, but could be used for systems with redundancy. For example 2 or more submerged pumps, but only one may be active at any given time. You can then use XOR to at least be notified of multiple devices running concurrently, if there is no automatic fallback on failures.

Or a mechanism to have automatic and manual heating/cooling and only allowing one input method, but not both at the same time.

In general, XOR is a basic logic operation and currently not available. For my use case, the "1 of n" variant is sufficient, but there are 2 ways of implementing it. The other would be to have the result be true, if an odd number of inputs is true.

@MaKnepper-JUNG
Copy link

Albrecht JUNG strongly supports this

@jimtng
Copy link
Contributor

jimtng commented Sep 25, 2024

Can you show a concrete example (items, rules, or sitemap/ UI) of how exactly you're going to use it?

Even if you were to have an "XOR" group function, it seems that you'd still need a rule to process it anyway? Implementing this functionality in a rule is trivial.

e.g. in JRuby

# For 1-of-n
changed(MyGroup.members) { |event| event.group.update(event.group.members.count(&:on?) == 1) }

# For odd
changed(MyGroup.members) { |event| event.group.update(event.group.members.count(&:on?).odd?) }

given the items:

Group:Switch MyGroup

If it were to be added as a group function, both variants would need to be supported
XOR(ON,OFF) for "1 of n" variant (probably more useful than the other variant?) vs ODD(ON,OFF) ?

Then eventually someone would say they need XNOR.

fabianvo pushed a commit to fabianvo/openhab-core that referenced this issue Sep 25, 2024
kaikreuzer pushed a commit that referenced this issue Sep 26, 2024
* #4385 add XOR ArithmeticGroupFunction (1 of n)

Signed-off-by: Fabian Vollmann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants