There is a similar option for Things. Though until relatively recently there was a bug when duplicating Things related to the Channel UIDs. I think that fix was backported to 4.3 but I’m not certain.
Indeed there is. Since I’m still in 3.4 I didn’t know that. Anyway, still my suggestion applies to Items. I will definitely have to consider upgrading to 4.x I’m just kind of scared on the amount of time that will take me!
By most accounts the upgrade between OH 3 and OH 4 was the easiest upgrade process yet. With the development of the upgradeTool, if you are using managed rules many/most of the breaking changes get fixed for you as part of the upgrade. Compared to previous major versions, the number of user facing breaking changes was way lower as well. Many were able to upgrade without changing a thing.
It is possible to create duplicates of both Items and Things.
My suggestion would be an additional trigger on the rule. I got a few rules that are triggered by one or more items. No issue here, but sometimes the rule is triggered very often and theres no need to run it again. So an extra trigger “but not more than once every X seconds” would be nice.
I’m not sure this is appropriate for the rule triggers. That’s the sort of thing rule conditions are for and can handle right now with a script condition. Triggers define the event that could cause the rule to run but conditions specify the conditions under which the rule is allowed to run when triggered.
It would be nice if there were a built in condition though instead of needing to resort to a script.
In the mean time, in JS such a condition would be something like:
The first line checks a timestamp stored in the cache to see if ten seconds has passed since the timestamp was recorded.
The second line stores a new timestamp if ten seconds or more have passed.
The last line is what gets returned by the rule condition. Only when rval is true will the rule’s actions run.
You’re right that would be a better name for it since it is a ‘limiting’ condition. Although I don’t use it, maybe the “inverted” option could be a trigger. Like “at least once every X seconds”. So the rule will run periodically even if none of the triggering items changes.
Yes, I got some code like yours in the rule right now. You can make a rule do anything but this would make it easier and more visible in de configuration. And make this kind of behavior available for non-programmers.
Yeah, but if I configure a CRON trigger and item triggers it will do both independently. So run every 5 minutes and whenever an item changes. So in practice it will run more often than every 5 minutes. But doing this would be the workaround to come close to this behavior. In fact, writing this response I remember I got one rule like this
Again, you can have a condition just like the above. Just check to see what triggered the rule and if it’s an item trigger return true. If it’s a cron trigger check the timestamp and only return true if it’s been long enough.
With that any time it’s triggered by an item the actions will run. Any other trigger will only run the actions of its been 10 seconds or more since the last item trigger.
Rate-limits the executions to a minimum interval, regardless of the interval between triggers. Waits until the end of the period before executing, ignores any leading triggers.
Rate-limits the executions to a minimum interval. Immediately executes the first trigger, then ignores subsequent triggers for the period.
Note there are two versions of these, one for convenient use in file-based rules as a special type of rule condition, and another which can be used in a UI based rules, as per the example above.
This will be the equivalent of jruby’s only_every.
Implementing debounce_for is trickier because it involves delaying the execution of the rule. I can think of two ways of implementing it, but not ideal, so I’m still thinking about it.
I would expect to keep DSL rules as well.
It is the only rule engine I use since OH2.
I have no idea what to replace it with nor did I find any guide on how to get away from DSL.
blockly has made some improvements. It is now quite capable, if you don’t mind block coding.
jsscripting has become the most popular scripting language of choice for openhab, due to its earlier entrance in openhab, and people’s familiarity of C-like syntax.
jython helper lbrary was abandoned. It was never a part of openhab’s official repo to start.
Jruby has entered the scene and it is now as mature as the jsscripting option, and its helper library is also officially a part of openhab, just like jsscripting and blockly.
a new but not yet stable, Python3 option is being worked on.
groovy has always been an option but it lacks a helper library
java is also another option if you prefer coding in Java
there’s also HabApp - a 3rd party solution for using Python3 interacting with openhab via rest api