[Solved] JSON array? loop it in rule; rapid fire rule: concurrency?

So there are a few options available to you.

  1. If you have control over the sensor, can you filter the messages there? It’s always best when you can move the debounce closer to the device itself.

  2. Do you have to process every message? If not you can lock the rule and throw away any messages that come in while the Rule is locked. There is only a problem when you queue the rules up with the lock.

  3. Take this as a reason/opportunity to explore OH 3 or at least the NGRE in 2.5 and programming rules in Jython or JavaScript. This rule engine: 1. does not have the same problem with running out of rules threads so locking isn’t dangerous and 2. actually locks the rule for you making it so only one instance of the rule can run at a time, queueing up the triggers in a FIFIO, which is essentially what you want.

  4. There is now a Debounce Profile I think, but it’s only available on OH 3.

If you were to move to Jython rules, you could download https://github.com/rkoshak/openhab-rules-tools/tree/main/debounce and add debounce metadata to your Items that you want to debounce. If you are willing to wait a few weeks, there will be a JavaScript version posted there as I’m currently working on that.

But even if you stick with Rules DSL, if you apply Design Pattern: Associated Items you only need one rule, one Group, and careful naming of your Items.

Sometimes it’s even right! Not always though. :smiley:

Anyway, this is a problem that has been solved for you but taking advantage of it requires updating.

2 Likes