-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jrule when refactoring #61
Conversation
And one more thing to Testing: |
# Conflicts: # src/main/java/org/openhab/automation/jrule/internal/engine/JRuleEngine.java # src/main/java/org/openhab/automation/jrule/internal/engine/JRuleExecutionContext.java # src/main/java/org/openhab/automation/jrule/rules/JRuleWhenItemChange.java # src/main/java/org/openhab/automation/jrule/rules/event/JRuleItemEvent.java
@querdenker2k Can you resolve the conflicts? I'm planning to review pr59 first and then start looking into this one. |
Not the full README is updated, just this parts which i added to my automated test-project. |
It's done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets say there are 2 or more types of triggers on a single method, ie
JRuleWhenItemChange and JRuleWhenChannelTrigger, and there is an event parameter on the rule method.
How can we handle that? If the metod parameter is a JRuleItemEvent, will it blow up when the channel triggers?
Another thing is to determine which Maybe we should add an ID to each trigger and pass that to the rule method? |
No, the method parameter must be ever the abstract class and at runtime you get the correct concrete instance of it. You have to cast. |
You mean multiple on the same method or on different for the same trigger? |
…n JRuleWhenItemReceivedCommand annotation
Great work @querdenker2k! Here are some findings that I think we should address:
I pushed a few commits also. |
@seaside1 Whats needed here to merge before other MR are coming (Merging this is ever manually because the change is too big) |
There are some conflicts, could you rebase? |
there are no conflicts? |
Can't rebase and merge from the tool (github). But manually no conflict when I rebase. I can merge it. Some things to be added to the doc (just for my reference
I'll see if I find more when I test it. @seime Have you tested it out with your rules? |
JRuleContactTrigger need to be updated with Open / Close values |
I think all the JRuleCommonTrigger could be removed, right? Looks like they are deprecated. |
Rename @JRuleWhenItemReceivedUpdate to field to "update" to be more inline with JRuleWhenItemReceivedCommand "command" |
Yes I think so. Since you will have to refactor all your JRuleWhen we might as well remove all those triggers. |
I would suggest renaming to "state" |
i renamed it to "state" because in OH core its named "state" as well. |
…e JRuleXXXEvent as method parameters
@seaside1 all findings fixed/done |
I've been running this branch for a few days now, and seems to work quite well. Two things I have noticed:
Both can be mitigated as mentioned here: #61 (comment) If we're to drop JRuleWhen-support I truly think we need a section in the changelog that deals with the necessary steps to migrate. I think I half a day migrating my rules and correcting the mistakes. Overall a great step in the right direction IMHO, thanks again @querdenker2k When this branch is merged I'll try to create a JUnit setup in this repo. |
First point: Event parameters is fixed 3 hours ago, tested with this rule
But what to do if somebody casts to a wrong type? Everybody has to check if event could be of multiple types. @seime I already created a test project with some tests. Just in case if you would like to do it the same way to not to do everything again. Or will promote this as a first approach. #https://github.com/querdenker2k/openhab-jrule-test |
I agree with Seime it's very good PR and it make the rules a lot cleaner, so good work! :) @JRuleName("testTImeTrigger")
@JRuleWhenTimeTrigger(hours = 6)
public synchronized void testTimeTrigger(JRuleEvent event) {
logInfo("Time Trigger triggered");
} Does this work on your systems? |
Never the less, I'll merge it now and we can report bugs if we find stuff. |
Could this be related to #28 ? If you are running on a fast computer, it might be able to reschedule the timer within the same ms causing it to trigger again. |
Don't think so. I don't get this with the pre JruleWhen refactoring. I do have a relatively fast device that I run openHAB on. |
my test with a cron with every 5 seconds does not have a problem. |
Found this in my log;
|
This is handled (or even not) by openhab. But the problem must exist already before. We could handle UNDEF before trying to parse it with QuantityType. |
|
Has to wait for: #52
Refactors the JRuleWhen Annotations into separate Annotations and did a little bit refactoring.
@seaside1 @seime But you can still have a look please.