Edit: Added some new libraries:
I’ve been busy coding a few initial submissions to the Helper Libraries Community Library. The follow is a list of PRs that are still awaiting review but it occurred to me that some users may be willing to download them and try them out, find bugs I’ve missed, and provide suggestions for improvement. So have at them and comment here and/or in the PR thread.
My over all approach for these is to provide reusable building blocks that implement common things that come up in Rules over and over again, freeing you to focus on what you want to accomplish.
This is a generic implementation of hysteresis that works with any of the openHAB State Types that are numbers. It will return a -1 indicating a given number is below a target-lowhyst, a 1 if the number is above target+highhyst or a 0 if the number is between the two values.
This one will become part of core.utils when/if it’s accepted and merged.
This is a generic implementation of Design Pattern: Gate Keeper. It’s a class that you instantiate and you call it with a command and how long to wait after the command is called before the next command is allowed. Repeated calls through the Gatekeeper will make sure the commands get spaced out as required.
A good example is to enforce a pause after calling
say to make sure it is done before allowing the next
say command to start executing.
A common task in Rules, especially generically written Rules, is to manage a dictionary of Timers keyed on an Item name. This let’s one, for example, have a reminder timer for each individual door managed by a single Rule. This Class centralizes all this logic providing a simple interface to check if a Timer exists, do something if it does and do something else if it doesn’t, reschudle and cancel the Timers. Look at the examples and tests for how to use it and ask if there are questions.
Generic Presence Detection
A reusable implementation of Generic Presence Detection expanded to suppport presence detection of individual people if desired.
A number of users want to put on their sitemaps or HABPanel the amount of time remaining on a Timer. This class implements just such a Timer. You pass it the function to call when the Timer expires, the time that the expire should expire, and the name of an Item that will get updated once a second with the amount of time remaining on the Timer until the Timer expires.
At times someone may want a certain task to run once in a certain time period (e.g. only send a given alert once a day). This module provides a class you can use to just try to call the task when ever and it will ignore any that take place too soon after the last event.
MQTT 2.5 M3 or Later Eventbus
Provides an implementation of the old MQTT 1/x Event Bus using Rules and the MQTT 2.5 M3 binding (earlier versions do not have a retained flag on the publishMQTT Action). It differs slightly from the original approach:
- Define which Items are published by Group membership
- Updates are published with the retained flag set to on, commands with the retained flag set to off.
- It implements an ONLINE/OFFLINE LWT topic, but this isn’t working yet pending an update to the binding.
This Rule implements a drop in replacement for the Expire1 binding. It is feature complete and handled the existing expire binding configs on your Items as is.
NOTE: I want to emphasize, these are reusable as is. They are not intended to be copy/paste and edited. Any configuration required will be done through configuration.py or through Items, though I don’t think any of the above require any configuration. Just import them and use them.