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
You will likely have to refactor your rules to use these new way of accessing items.
See example 30 in the documentation on github.
Thanks for this great software. I’m using jrule from almost the very beginning and I have no regrets.
Imho it is the future of openhab.
The thing is that I’m now trying to get a remote log of some critical decisions to be taken by some of my rules (they deal with battery charging, heating and other “dangerous tuning”)…
I have an information system in python that collects PV estimations, actuals and uses a keras model to get a prediction of the electricity consumption. All this feeds a strategy engine that determines whether the battery should be charged or not (when there is no sun), decides if water should be heated or not and the setpoint of the thermostats to minimize energy expenditure and keep battery life.
The thing is that I would need a way to notify me remotely and even ask for my confirmation before changing some critical parameters from the inverter, the heat pump of the thermostats…
I found no way to use telegram messages as available in other rule engines and I’m considering integrating directly a telegram bot into the engine.
My concern is that if Telegram is going to be supported (it may be already supported and I didn’t notice), or you have any other suggestions for such a kind of “chat” for confirmation.
Great to hear! But don’t only thank me, several people are contributing and if you go over to github you can see that we are closing in on PR #100 and most recent code is done by a couple of individuals putting a lot of effort into this.
I’ll build a new release soon (a day or two). There are some recent PR that will make your life easier regarding this. I think Telegram is a good choice (although I don’t use myself for my sytem).
With this new PR you will be able to use actions from JRule by using a generated class instead of a script action. This will make it clear what methods are exposed, and it will be easier to get the interaction right. You could try it out by downloading and building the project with maven (or wait a day or two for an official release).
See github example Example 34
I my openHAB system I have a similar function, I log in chat with a bot some events, so I can see what’s going on. I use slack, but I think telegram would work just as good.
I’ve just built a BETA15 release containing a lot of changes. This update will break your rules and you will have to refactor all your JRuleWhen annotations. Look at the examples and documentations on github (link in the first post).
BETA15
BREAKING: All JRuleWhen has to be change to corresponding JRuleWhenItemChanged (as an example, look at JRule Examples documentation)
I just upgraded from BETA-10 to BETA-15. I removed all rules due to the JRuleWhen refactoring and found some generated thing classes do not compile due to illegal constant names. Example:
public static final String 1_BUTTON = "homematic:HmIP-WGC:ccu:<SERIAL>:1#BUTTON";
I’ve got ~15 affected things, all of them are Homematic (IP and non-IP) devices.
Log Messages say illegal underscore and <identifier> expected.
Java does not allow field names starting with numbers.
In addition, there are the following entries in the log:
2022-12-08 16:47:12.116 [INFO ] [rule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Error on line -1 in : unknown enum constant org.eclipse.jdt.annotation.DefaultLocation.PARAMETER
reason: class file for org.eclipse.jdt.annotation.DefaultLocation not found
2022-12-08 16:47:12.118 [INFO ] [rule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Error on line -1 in : unknown enum constant org.eclipse.jdt.annotation.DefaultLocation.RETURN_TYPE
2022-12-08 16:47:12.120 [INFO ] [rule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Error on line -1 in : unknown enum constant org.eclipse.jdt.annotation.DefaultLocation.FIELD
2022-12-08 16:47:12.123 [INFO ] [rule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Error on line -1 in : unknown enum constant org.eclipse.jdt.annotation.DefaultLocation.TYPE_ARGUMENT
Is this an inherited error? Or do I need a different openHAB version? I am currently using 3.3.0.
Is there a way to fix these problems or a way to go back to an older version (BETA-14)?
I can confirm they are inherited. I deactivated the problematic things and everything works fine… now I have to wait for BETA-16
Thanks for the fast response!
I might need to move this to a new thread so please tell me if I do.
I installed the Beta15 version of JRule and I think I followed most of what I need to do but VSCode is not recognizing jrule.items.
I installed JRule add-on. It built the .java files for each item. I have my OpenHAB config folder shared via Samba. In VSCode I opened the OpenHAB config folder. I have the Microsoft Extension Pack for Java installed and when I open one of the .java files for one of the items I created it doesn’t recognize the import for org.openhab.automation.jrule.items.
I have experience with Java but this is my first time writing Java in VSCode. I’m trying to keep it all in VSCode so I can edit items, things, and all that in the same environment as my rules. If that’s not possible let me know, or if I’m just missing something simple let me know.
Hi there,
is there a way to suppress the following warnings in openhab log
[on.jrule.internal.engine.JRuleEngine] - [JRuleEngine] Skipping method abc on class XyzRule since JRuleName annotation is missing
I guess this is intended as a hint to possibly forgotten annotations but it really disturbs when rules are structured with superclasses and a bunch of private/protected methods. I would suggest excluding at least private and protected methods. Or even introducing a JRuleNotARuleMethod annotation.
New release with big changes. The documentation is updated, so please take a look at that to be able to migrate the rules. The examples are updated as well.
just started looking into JRule a few days ago and this seems to be the perfect solution for what I was searching for.
As I need to create rules dynamically (when parsing a custom JSON file containing the whole configuration of my home), I am curious when dynamic rules will be available? I have seen that there already exists a pull request for this in your repository on GitHub.
You can always build the jar from the PR and use that.
I’ll merge the dynamic rules once it is reviewed. The dynamic rules are quite basic still, so might not contain everything you need.