-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Fix system started DSL rules #3725
Conversation
Signed-off-by: Jan N. Klug <github@klug.nrw>
Signed-off-by: Jan N. Klug <github@klug.nrw>
I don't have a good setup to test this (and no time), since I neither use file-based rules nor scripts. It should be tested that
|
After a bundle update and a OH server restart; the warning has disappeared but now the rule is run twice, apparently the second just after the first:
|
I have no idea why that happens, maybe a check for the start-level is missing. Can you post a file that shows this behavior? In my tests the rues run exactly once. Unfortunately I can't work on that today. |
This file will actually do (adding some logging to it). I get this result at startup:
So indeed the rule is executed twice and the first time happens quite a time before the rule engine is officially started. |
I tried again with the last change in the PR but same result, that is rule run twice. |
Additionally, fix nullable error and warning in Eclipse IDE Signed-off-by: Kai Kreuzer <kai@openhab.org>
return s.lines().map(line -> (line.startsWith(indentation) ? line.substring(indentation.length()) : line)) | ||
.collect(Collectors.joining("\n")); | ||
} | ||
|
||
private @Nullable Trigger mapTrigger(EventTrigger t) { | ||
if (t instanceof SystemOnStartupTrigger) { | ||
Configuration cfg = new Configuration(); | ||
cfg.put("startlevel", 20); | ||
cfg.put("startlevel", 40); |
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.
This change fixes the issue for me. I have no idea, why I have ever set it to 20 in the first place.
According to the documentation at https://www.openhab.org/docs/configuration/rules-dsl.html#system-based-triggers, "startlevels less than 40 are not available as triggers". Setting it to 40 will only execute them once during startup.
@lolodomo I just pushed a commit that fixes the issue for me. Would you be able to test this as well, please? |
I do it now... |
Thanks for your nightshift. |
Kai, it looks like the rule is run twice but now the second time occurs very late at startup when everything is loaded.
|
I assume your rule has a simple "System started" trigger and nothing else? |
But I believe it was already happening in the past that this rule was run a second time very late at startup. |
Yes
|
I can try quickly with snapshot 3544 to confirm that the rule was already run a second time very late. |
Which is still very weird - I never had startup rules being triggered twice. |
Yeah, would be great. |
I can confirm that the behaviour with snapshot 3544 is the same as the current with this PR. If your tests are positive, I believe we can go with that. |
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.
Ok, thanks for testing - then this at least is nothing newly introduced by this PR.
I hereby approved the changes done by @J-N-K and leave it to him to merge the PR if he approves my changes as well.
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.
LGTM
Fixes #3723
@lolodomo can you test if that resolves your issues? On my system it seems to work fine.