openHAB Rules using Java
This automation package aims to enable Java development of openHAB Rules. The addon will allow the user to create custom openHAB rules in one or several .java-files. The Java Rules will need to define triggers in order for the rules engine to know how and when to execute them.
The triggers are very similar to the triggers in Rules DSL but expressed using java annotations. In order to execute rules based on items defined in openHAB either in .items-files or the GUI. The addon needs to know about these items and this is realized by the Rule Engine by generatinga .java and a .class file for each item in the system. The class files are then packaged in a .jar-file which the user can use as a dependency when doing Rules Development.
For the addon to be able to pick up rules, they first need to be compiled by the rules engine. The source .java rules-files are placed in a specific rules folder and will be automatically compiled and loaded into openHAB when the rules engine is started. The syntax for rules as well as the design and thinking behind the addon is to provide something that is similar to Rules DSL but more powerful, flexible and customizable.
Bugs
Any bug you find is good to report. Preferred way of reporting bugs is to create an issue on github: Issues Ā· seaside1/jrule Ā· GitHub
Contribute
Create a Pull Request on github: Pull requests Ā· seaside1/jrule Ā· GitHub
Changelog
BETA21
- Fixed MDC ātagā rule by querdenker2k PR fix MDC tag 'rule' by querdenker2k Ā· Pull Request #198 Ā· seaside1/jrule Ā· GitHub
- Allow byte for http request by querdenker2k PR allow byte[] for http requests by querdenker2k Ā· Pull Request #196 Ā· seaside1/jrule Ā· GitHub
- Dynamic rule builder by rsopp PR Dynamic rule builder by rsopp Ā· Pull Request #195 Ā· seaside1/jrule Ā· GitHub
- Added more methods (Dynamic rules) by seaside1 PR Added more methods by seaside1 Ā· Pull Request #193 Ā· seaside1/jrule Ā· GitHub
BETA20
- Quantity item should extend number item by querdenker2k PR quantity item should extend number item by querdenker2k Ā· Pull Request #189 Ā· seaside1/jrule Ā· GitHub
- InvocationTargetException the get stacktrace has changed by querdenker2k PR for InvocationTargetException the get stacktrace has changed from getā¦ by querdenker2k Ā· Pull Request #188 Ā· seaside1/jrule Ā· GitHub
- Add option to add metadata by querdenker2k PR add option to add metadata by querdenker2k Ā· Pull Request #187 Ā· seaside1/jrule Ā· GitHub
- Do not use logprefix when empty by querdenker2k PR Do not use logprefix when empty by querdenker2k Ā· Pull Request #185 Ā· seaside1/jrule Ā· GitHub
- MethodNotFound fix for primitive action parameters by querdenker2k PR MethodNotFound fix for primitive action parameters by querdenker2k Ā· Pull Request #184 Ā· seaside1/jrule Ā· GitHub
Version BETA19
- Dynamic Rules by seaside1 PR #177
- Add persist by querdenker2k PR #174
- Updated Readme.md by seime PR #173
- handle quantity types for item-change-conditions by querdenker2k PR #172
Version BETA18
- Refactored timers and added method for checking for timer lock by seaside1 PR #171
- Added the ability to configure the name of the package in jrule.conf by kuimovvg PR #170
- Add previousState and a test by querdenker2k PR #168
Version BETA17
- Fix for thing actions without @ActionInput by seimePR #143
- Store jar file as build artifact by seimePR #144
- Merge test packages by seimePR #145
- Only consider methods declared in rule class, not inherited methods by seimePR #147
- Reduce loglevel to debug by seimePR #148
- Send updates/commands to group items itself, not just members by seimePR #150
- Reduce flawky builds by querdenker2k PR #151
- Notify for rule runs by querdenker2k PR #152
- Update to openhab 4.0.0 by sealside1 PR #153
- Add reschedule by querdenker2k PR #155
- Fix Timer:isRunning by querdenker2k PR #157
- Print useful exception trace while InvocationTargetException by querdenker2k PR #160
- Removed OS dependent configurations by sfdumas PR #164
Version BETA16
- Enrich memberOf with options to just listen on items or groups by querdenker2k PR #95
- Add http action by querdenker2k PR #97
- Fixed typo by thwint PR #98
- Log exception stacktrace by querdenker2k PR #99
- Enhance and cleanup the internal timers by querdenker2k PR #100
- Improve trigger channelname conversion and error reporting by seimePR #103
- Add previousCondition to JRuleWhenItemChange by querdenker2k PR #104
- Let transform throw a runtime exception by querdenker2k PR #106
- ForNameOptional, UnspecifiedGroupItem, QuantityItem by querdenker2k PR #107
- Fix NPE with watchingForItem while not completely initialized by querdenker2k PR #110
- Fixed contact item issue by seaside1 PR #114
- Add tests for historicState NPE, add toString for values by querdenker2k PR #118
- Fix merge (transform exception) by querdenker2k PR #119
- Add metadata and tags getters for items by querdenker2k PR #121
- Add delayed execution, remove unused JRuleOr by querdenker2k PR #122
- Remove illegal characters from generated channel name by seimePR #124
- Reduce loglevel for non-annotated java methods in rule classes by seimePR #125
- Fix member of by querdenker2k PR #126
- Make Item constants constant by querdenker2k PR #128
- Exclude lambdas while scanning methods by querdenker2k PR #129
- Exclude persistence verifications by querdenker2k PR #130
- Memberitems type specific by querdenker2k PR #131
- Fix repeating timers by querdenker2k PR #133
- Let JRuleItemEvent contain JRuleItem by querdenker2k PR #134
- Restructure documentation by seimePR #135
- Fixed group item class generation by gerriegPR #138
- Remove direct item registry update causing new events to be produced by seimePR #140
- Spelling fixed rdrxr PR #141
Version BETA15
- BREAKING: All JRuleWhen has to be change to corresponding JRuleWhenItemChanged (as an example, look at JRule Examples documentation)
- JRule When refactoring by querdenker2k PR #61
- Thing Channel triggers by seime PR #62
- Generate Actions by querdenker2k PR #63
- Add option to get groupMembers as Items by querdenker2k PR #65
- Memberof Trigger by querdenker2k PR #66
- Fix buffer being read twice and breaking classloading by seime PR #67
- Fix missing precondition support for timer rules by seime PR #68
- Fix timer trigger by querdenker2k PR #70
- Initial tests for JRuleWhenItemChange triggers by seime PR #73
- Threadlocal logging - some improvements by seime PR #79
- Junit test for duplicate rule invocations by seime PR #75
- Add docker integration test by querdenker2k PR #77
- Include old thing status in event by seime PR #80
- Use thread safe list instead of arraylist by seime PR #81
- Defer to parent classloader if file not found by seime PR #83
- Fix inheritance in actions by querdenker2k PR #87
- Fix mqtt for tests by querdenker2k PR #91
- Fix ConcurrentModificationException in test by querdenker2k PR #92
- Added typing for thing channel triggers, ie JRuleWhen(channel = binding_thing.triggerChannel) instead of typing the channel id string
Version BETA14
- Thing support in rules by seime pr #59
-BREAKING: jrule-items.jar has been renamed to jrule-generated.jar - Added missing sendCommand for StopMove commands by seime pr #57
- Fixed parsing of double value for Quantity type by seime pr #56
- Added generic action handler by querdenker2k pr #55 see exampe #34
- Refactoring of event for channel plus cleanup by querdenker2k pr #52
- Refactoring of persistance functions and item handling with exceptions by querdenker2k pr #51
- Added item id and fixes for generated items by LumnitzF pr #50
- Added MDC Logging tags to be used with elastic search (logstash,kibana and similar) by querdenker2k pr #49
- Fixed parsing of double values in rule conditions by seime pr #48
- Fixed parsing of UNDEF by seime pr #45
Version BETA13
- Fixed a bug with naming of JRuleItems.java
- Fixed issues with post and sendCommand to groups
Version BETA12
- Major refactoring by seime #42
- Replaces the templating mechanism with Freemarker, mainly to allow more advanced constructs such as loops - and to avoid all the repetitive code in the template files
- Generates a new file Items.java which looks a bit like public class Items { public static MySwitchItem SwitchItem = JRuleItemRegistry.get(āMySwitchItemā, MySwitchItem.class); public static MyStringItem StringItem = JRuleItemRegistry.get(āMyStringItemā, MyStringItem.class); }
- Adds a skeleton support for LocationItem (which was missing)
- Adds a new field LABEL (item label)
- Adds a few convenience methods such as getLabel() and getName()
- Adds more typing of Group items
Version BETA11
- Wrap TransformationException in JRuleExecutionException by seime #39
- Add equivalent postUpdate logging as sendCommand by seime #38
- Fix group sendCommand for UpDown by seime #36
- Added eq and neq to channel event by gerrieg #35
- Added support for ZonedDateTime in DateTimeItem by gerrieg #34
- Fixed issued with undef item for state
- Added mocked eventbus for testing rules with junit
Version BETA10
- Optimized items by gerrieg #33
- Syntax change: event.getValue(), event.getValuesAsDouble() etc replaced with event.getState().getValue() and event.getState().getValueAsDouble()
- Syntax change JRuleSwitchItem.sendCommand(myItem, ON) replaced with JRuleSwitchItem.forName(myItem).sendCommand(ON)
Version BETA9
- Fixed bug with item generation and forName overloading
Version BETA8
- Added forName for items see example 27 Added forName and refactored ItemClass Generation Ā· seaside1/jrule@0952ae4 Ā· GitHub
- Added itemName and OldState by gerrieg #31
Version BETA7
- Fixed item for Number:Quantity, you can now send a quantity type in the command see example 26
- Added precondition see example 24 and 25 by seime: #30
- Added possibility to use subdirs and packages for rules by seime: #30
Version BETA6
- Added seprate thread executors supplied by seime: #23
- Added Windows Support by LumnitzF #24
- Added cancellation of repeating timers by seime: #26
- Null check on timers with futures by seime #29
- Update to Openhab 3.3.0
- Fixed rescheduling of timers by seime: #28
- Added check for repeating timers by seime: #27
- Fixed repeated timer executing directly by seime: 25
- Added transformation sevice example 23 by seime: #20
- Improved compiler error logging by seime: #12
- Added UP/Down support for group items by seime: #13
- Quantity Type support by seime: #14
- Configurable item-prefix by weberjn #16
- Improve exception handling by No3x #19
- Made thread executors configurable, default disabled
- Possible to build jrule standalone #24 or together with Openhab-addons
- Cleaned up repostiory from binary files. Remove and old clones of jrule and clone a fresh repo
Version BETA5
- Addes support for adding rules in jar-files, as an alternative.
Version BETA4
- Added config for character to be used when generating items files
Version BETA3
- Major refactoring of logging
Version BETA2
- Fixed color item
- Added annotation for setting logger on a rule see example 21 and 22
- Optional to override getLogName on class
- Contact item update
- Rollershutter item support added
- UpDown, Increase Decrease support added to various items
- OnOff and Percent commands added to ColorItem
Version BETA1
- Added color item see example 20
- Moved org.openhab.automation.jrule.rules.JRuleOnOffvalue, JRulePlayPause etc to org.openhab.automation.jrule.rules.value
Version ALPHA12
- Fix some language typos, some refactor of java classes, improved initialization of singletons due to concurrency aspects
Version ALPHA11
- Added check for working dir via system properties
Version ALPHA10
- Added LatUpdate via JRulePersistenceExtentions see example 19
Version ALPHA9
- Added cron expressions for rules see example 18
- Bug fix by @roth for reloading channel triggers
Version ALPHA8
- Channel triggers provided by @roth see example 17
Version ALPHA7
- Fixed bug with group member value was null for non StringType types
Version ALPHA6
- Added group functionality getMember will return who triggered a change for a group
Version ALPHA5
- Removed dependencies on slf4japi and eclipse annotations
- Added logInfo logDebug (to wrap slf4j and remove dep)
- Fixed compilation of rules to be more robust with internal dependencies
Version ALPHA4
- Refactored completable futures
- Added 5 seconds of delay for initialization of the rule engine to avoid multiple reloads
- Added support for play & pause for player item
- Added commandLineExecute
Version ALPHA3
- Fixed issue when reloading rules if they are changed with monitored items
- Fixed classpath issue when executing rules using 3rd party libraries
Version ALPHA2
- Added possibility to include 3rd party libraries when developing rules
Version ALPHA1
- Refactored internal jar dependencies and jar-generation
- Added eq comparator for number triggers in rules