I need to be able to trigger an action if a numerical state (e.g. temperature) drops below or raises above a certain value. I can’t seem to find how to do this in NGRE (PaperUI in 2.5M1). Is it currently possible? (Or is it likely to be so before 3.0?)
I understand that NGRE is still at an experimental level but I find that being able to edit them via a web interface and visualize them in an if-then format is kind of how I build them in my head.
I was thinking of using IFTTT as an alternative, but it’s not currently possible to publish new items.
With noclues as to what you have tried or thought about, maybe it’s just a question of approach.
The requirement can be restructured as -
At every temperature change , test to see if it as above/below some threshold.
Under “When…”, when I go to select a trigger type, there’s “an item state changes” and “an item state is updated”. However, both of those only seem to have options for binary states. Open/Closed, On/Off, Up/Down.
Entering a numerical comparison such as “>22” did not appear to have any effect.
The comparison operators do seem to exist under additional conditions but not as an initial trigger, which is what I’m looking for.
It could be that I’m missing something that’s there and going about this the wrong way, but it doesn’t feel quite as intuitive as some rules builders (or even other rules types within NGRE) can be.
Never worked with NGRE, however I think you can’t check for < or > on the trigger. As @rossko57 suggested let the rule trigger at every change and check if that change is going over the limit in the “then” section.
Based on a discussion on another thread, @5iver and I are going to try to move everyone to a new nomenclature which we hope will be more clear and more correct.
Rules DSL: the current default Rule engine
Manged Rules: Rules created through the UI or otherwise submitted through the REST API
Unmanaged Rules: Rules written in one of the scripted automation languages in text files (what we generally call JSR223 but we want to drop that term as well)
The NGRE runs both Manages and Unmanaged Rules. And that part is rock solid and not experimental. The problem is with the UI that is used to create Managed Rules. That part is still experimental at this point. Two problems I’m aware of include that System started triggers seem to be broken and the “Publish an MQTT message” “then…” action is broken. It’s been awhile since I’ve messed with it too much so there may be other things.
As has been stated, you cannot put comparisons like this in your When… clauses. You can only do equals type comparisons (e.g. MyItem changed to 22 which would trigger the Rule when the Item changes to exactly 22). For comparisons there is the “but only if…” clause which lets you define under what conditions the Rule is allowed to run when it get’s triggered.
Create the Rule
Create a new “When…” and use “an Item state changes” as the trigger
Create a new “But only if…”. Since you have two conditions you want to check you should choose “a given script evaluates to true”
(items["MyTemp"] > 22 || items["MyTemp"] < 20);
Another approach that might be useful for cases like this is the ability to enable and disable other Rules from a Rule. For example, you can have a Rule that trggers when the temp get’s above 22 that disables a Rule that runs the heater and reenables it when the temp drops below 20. That isn’t something that is useful in this specific case but it might help with related types of tasks.