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

Allow comparison operators in rules definition #4503

Open
Boby71 opened this issue Dec 17, 2024 · 8 comments
Open

Allow comparison operators in rules definition #4503

Boby71 opened this issue Dec 17, 2024 · 8 comments
Labels
enhancement An enhancement or new feature of the Core

Comments

@Boby71
Copy link

Boby71 commented Dec 17, 2024

Currently, it's only possible to check an item state being EQUAL to a given value, like in this example:
image
In this example, the value needs to be EQUAL zero so that the rule fires.

I'd like to suggest to introduce the opportunity of a comparison operator to add flexibility in the rule creation.
Means: It shoud be possible to use <, >, <> and = as additional parameter.
Example: When the combination is like "<" and 5 then the rule should fire every time when the item state is lower than 5.

Thank you!

@Boby71 Boby71 added the enhancement An enhancement or new feature of the Core label Dec 17, 2024
@Boby71 Boby71 changed the title Allow comparing operators in rules Allow comparinson operators in rules definition Dec 17, 2024
@Boby71 Boby71 changed the title Allow comparinson operators in rules definition Allow comparison operators in rules definition Dec 17, 2024
@rkoshak
Copy link

rkoshak commented Dec 17, 2024

This is what the Rule Condition is for.

Example: When the combination is like "<" and 5 then the rule should fire every time when the item state is lower than 5.

image

You have the option to test the state of Items (not just the triggering Item), time periods, ephemeris, or even write your own script. All comparisons are UoM aware.

@florian-h05
Copy link
Contributor

I absolutely agree with Rich, this is what conditions are for.

@jimtng
Copy link
Contributor

jimtng commented Dec 28, 2024

Maybe in the UI, we can add a hint to use rule conditions for more complex comparisons?

@florian-h05
Copy link
Contributor

Depending on where this hint should be placed we would need to update some definitions in core, but I like the idea 👍

@rkoshak
Copy link

rkoshak commented Dec 30, 2024

It could be as simple as adding to the description under Previous State and State something along the lines of:

"For anything other than exact matches, add a rule condition." We can word smith it a bit but I don't know that we need anything more complicated than that. I don't know where that's defined though.

While we are at it, does it make sense to add some more details to the main rule page?

When
Events that cause this rule to trigger

Then
Actions to take when this rule runs

But only if
Conditions that must be true for the actions of this rule to run

Adding these shouldn't mess with the size and layout of the rule page too much and I think it makes it much more clear what the three parts of the rule do. I'm often surprised at how many people simply don't know what conditions are or that they even exist. And we have a precident of including a description under most fields everywhere else in MianUI.

Again, I'm not loving the wording but something to tell the user what the three sections of the rule do before they click through could help the new user in a hurry figure out what to do.

florian-h05 added a commit to florian-h05/openhab-core that referenced this issue Dec 31, 2024
florian-h05 added a commit to florian-h05/openhab-core that referenced this issue Dec 31, 2024
@florian-h05
Copy link
Contributor

@rkoshak See #4530.

@holgerfriedrich
Copy link
Member

Merged, but will take some time until it makes it into all the translations....

@florian-h05
Copy link
Contributor

Sure 👍

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

No branches or pull requests

5 participants