Comparison Dropdown - Feature Request

Would it be possible to include "between" ( i.e greater than equal to some number AND less than some number ) in addition to just "increased", decreased" "changed", "<=", ">=", "!=" etc in the "Comparison" dropdowns in triggers specially.
That would be very helpful..
just as one example I could identify how many light bulbs are on.. or if garage door motor is working or if just the light is on etc based on power meter.

You didn't really say, but from your description, I assume you are talking about Rule Machine. I can't speak to whether your particular request will be implemented, but there are a couple ways you can already do what you are asking. A very basic example would look something like ths:

Trigger: Power *changed*

Actions to run:

IF (Power between 10 W and 20 W) THEN
  (do things)

If you only want to trigger the first time power goes above or below a certain value, then you could use a required expression instead (and, in fact, even with a trigger as you describe, this is still how you would have to do that -- any event matching the trigger counts as a trigger otherwise).

actually i was using "Stays that way for x minutes" feature..
I already have a rule.. but this enhancement woul make the rule so much cleaner and simpler

Now I'm confused--"stays" and (the hypothetical) "between" would not be the same, but if you already have something that works, then what is the particular use for "between"? Again, I can't speak to this particular request, but such wishes are granted less often when there is already way to do it (either of the ways I mentioned would work) and no clear use case is presented. Just something to consider. :smiley:

1 Like

To elaborate on my example..
I have power meter connected to my garage door..

the garage door outlet has the garage door motor and the garage door light. the motor uses about 300+ watts, while the bulb uses about 70 watts... since the bulb and garage door only have toggle switches.. I want to do the toggle when the power meter is somewhere between 65 and 75 watts for 5 minutes.. so then I want it to press the toggle button and the light will turn off.. if the light is off ( i.e. power being used is more than a few watts.. then if the toggle is clicked then it will turn on the bulb and will stay on... which I dont want..
There is another way that I have implemented the same is by using the required expression... to have more than 65 watts, and trigger level having less than 75 for 5 minutes..
a little convoluted.. than a simple trigger with "between" comparator

anyways.. in the "Comparison" it has most of the comparators for numbers, except the "between".. so felt like an omission..

It's not an omission. All comparisons in RM are between two things. What you suggest is between three things, and that really means two separate comparisons.

What you're describing is tantamount to having a Trigger Expression. This is sort of analogous to, actually very similar to, Wait for Expression. It's the same logic except for what happens after the evaluation of the Expression. It wouldn't be impossible to implement. I'm rather reluctant to do so given how large and complex Rule 5.1 has become. But, since most of the code to do it already exists in the app, I will look at it. It may not come to pass.


I have looked at this.

Doing a Trigger Expression is out of the question for a number of reasons.

However, taking your suggestion directly of a range comparison may be doable. It would have a relatively small code impact. So I will be looking at this possibility. Groovy has an "in" operator, that can test if a value is in a range, like this:

if(x in [65..75]) ...

The effort to allow this arises not so much from the operator, as from getting the second value of the range in the UI. I will explore this idea...


Great, Thank you very much

Next release.