Oh yes, that’s exactly the same “issue” I have.
Added BETA8 Build:
- Added forName for items see example 27 Added forName and refactored ItemClass Generation · seaside1/jrule@0952ae4 · GitHub
- Added itemName and OldState by gerrieg Added itemName and old state to JRuleEvent by gerrieg · Pull Request #31 · seaside1/jrule · GitHub
- Optimized items by gerrieg https://github.com/seaside1/jrule/pull/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)
I’ve got several
Contact items which are sometimes out of reach. In this case, JRule throws an
IllegalArgumentException when trying to access the state:
var ct = JRuleItemRegistry.get("GN_CT_DOOR", JRuleContactItem.class) ct.getState();
This is the Exception:
2022-05-14 11:40:12.269 [ERROR] [on.jrule.internal.engine.JRuleEngine] - [UpdateDisplayHall] Error message: No enum constant org.openhab.core.library.types.OpenClosedType.NULL 2022-05-14 11:40:12.273 [ERROR] [on.jrule.internal.engine.JRuleEngine] - [UpdateDisplayHall] Error Stacktrace: java.lang.IllegalArgumentException: No enum constant org.openhab.core.library.types.OpenClosedType.NULL at java.base/java.lang.Enum.valueOf(Enum.java:240) at org.openhab.core.library.types.OpenClosedType.valueOf(OpenClosedType.java:1) at org.openhab.automation.jrule.internal.handler.JRuleEventHandler.getOpenClosedValueFromState(JRuleEventHandler.java:276) at org.openhab.automation.jrule.internal.handler.JRuleEventHandler.getOpenClosedValue(JRuleEventHandler.java:241) at org.openhab.automation.jrule.items.JRuleContactItem.getState(JRuleContactItem.java:37) at org.openhab.automation.jrule.rules.user.DisplayHallRule.lambda$updateDisplayHall$0(DisplayHallRule.java:90) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.openhab.automation.jrule.rules.user.DisplayHallRule.updateDisplayHall(DisplayHallRule.java:83)
It would be nicer to get
UNDEF in this case.
trying to use
transform leads to an Exception
final var dayInfo = transform("MAP(DayOfWeek_de.map):%s", dayOfWeek.name());
2022-05-14 13:01:08.253 [INFO ] [rule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Error on line 54 in file:///etc/openhab/automation/jrule/rules/org/openhab/automation/jrule/rules/user/DateRule.java: cannot access org.openhab.core.transform.TransformationException class file for org.openhab.core.transform.TransformationException not found
I have created a fix for this. Have not tested it yet. Will build a new version soon.
See Fixed issued with undef item for state · seaside1/jrule@6827940 · GitHub
This is fixed by seime: See: Wrap TransformationException in JRuleExecutionException by seime · Pull Request #39 · seaside1/jrule · GitHub
This engine and the support/dedication it gets is awesome.
I’ve reimplemented my 250+ items/50+ rules openHAB 2.5 system with JRule on openHAB 3.2 within 6 hours. Some rules are really complex, but it was really easy to do a 1:1 migration from JSR223 groovy/jython and xtext rules.
Thanks to static typing, I could realize a long-postponed “rename items for more consistency” project without any problems.
Using IntelliJ and gradle instead of VSCode or the openHAB UI for editing really helps a lot.
For me, this is by far the best rule engine available in openHAB since openHAB 1.8.
It is fantastic to see that several people are contributing to the project.
Built a BETA11
- Wrap TransformationException in JRuleExecutionException by seime Wrap TransformationException in JRuleExecutionException by seime · Pull Request #39 · seaside1/jrule · GitHub
- Add equivalent postUpdate logging as sendCommand by seime Add equivalent postUpdate logging as sendCommand by seime · Pull Request #38 · seaside1/jrule · GitHub
- Fix group sendCommand for UpDown by seime Fix group sendCommand for UpDown by seime · Pull Request #36 · seaside1/jrule · GitHub
- Added eq and neq to channel event by gerrieg Added eq and neq to channel event by gerrieg · Pull Request #35 · seaside1/jrule · GitHub
- Added support for ZonedDateTime in DateTimeItem by gerrieg Added support for ZonedDateTime in DateTimeItem by gerrieg · Pull Request #34 · seaside1/jrule · GitHub
- Fixed issued with undef item for state
- Added mocked eventbus for testing rules with junit
I have added a template project for building and deploying rules using maven.
In that example project there is also code for testing your rules with a fake eventbus.
see: GitHub - seaside1/jrule-user: JRule User Demo and Test Project