Value greather than 65 for 30 minues

Hey there,
I am using OpenHAB 3 as openhabian and want to set a specific rule.
The goal is to trigger an action when the humidity in the bath is more than 65 % for 30 min.
Is there an “easy” way to do this?

Depends what you consider as “easy” :wink:

It might work if you combine “hysteresis” and “timestamp-change / timestamp-update”. With that you can get the timestamp when the humidity was getting more than 65%. And with a rule you can check regularly (e.g. every minute) if 30 minutes have passed and then you can do your action.

Quick and dirty … The experts might have a more elegant approach
Cheers
thefechner

I thought about “easy to reuse”.
A script or something like this so that I can do several rules with this.
I don’t want to create lots of dummy devices and work around stuff to just make some simple rules :slight_smile:

That presupposes that what you are trying to accomplish actually are just “some simple rules.” Often things that naive users want to be simple are in fact no simple at all.

In order to really answer this we need more information.

  • What version of OH?
  • Which rules language and text rules or UI rules?
  • Why several rules? Can’t you handle this with one rule that handles lots of Items?

For the most part what you are asking for is a special case of Design Pattern: Motion Sensor Timer only instead of keeping a light on as long as there is motion you need to switch the comparison around and wait for there to be a given state for longer than 30 minutes.

The overall approach will be to create a timer for 30 minutes when the Item goes above a threshold.
If the Item goes below the threshold cancel the timer.
If a timer already exists exit the rule.
After the 30 minutes above the given threshold the timer will go off and do the action.

You will need to figure out how to define the time (30 minutes) and the threshold. You can use Item metadata to store that (if you are using any language other than Rules DSL), separate Items, or hard code it into the Rule. The advantage of using separate Items is you can then adjust them from your UI.

Again, if using the non Rules DSL languages you can put some/most of this into a library or implement it as a separate reusable rule. See openhab-rules-tools/debounce at main · rkoshak/openhab-rules-tools · GitHub for an example that implements denouncing a state from a raw Item to a proxy Item (i.e. the raw Item must be in a stable state for a defined amount of time before the state is passed to the proxy Item).

Hi,

just to mention another approach …

Build a rule which triggers/ fires every x minutes (maybe 5 minutes).
In the rule use the PersistenceExtension to check if the averageSince or minimumSince are above (or below) the desired item value.

Alexander

Thank you, that was exactly what I was looking for.
For some reason averageSince is not working for me but minimumSince did.