Skip to content
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

"System reached start level XX" trigger for DSL rules #2658

Merged
merged 1 commit into from
Jan 17, 2022

Conversation

Flole998
Copy link
Member

This implements a way to trigger dsl-based rules on various start levels, like it is already possible with ui-based rules.

@cweitkamp cweitkamp added DSL rules Domain-Specific Language rules enhancement An enhancement or new feature of the Core labels Jan 1, 2022
@kaikreuzer
Copy link
Member

kaikreuzer commented Jan 1, 2022

What exactly is the intention here? The lowest start level that allows execution of rules is 40/50 when the "system started ones are triggered". Besides this, there are no higher start levels implemented so far, so I do not really see any use case here (yet)?
It might rather fool the users to think they could define rules for any start level and then wonder, why this isn't working?

@Flole998
Copy link
Member Author

Flole998 commented Jan 1, 2022

There are 4 reasons I did this (and you will probably only consider one or two of them a valid reason ;) ):

  1. To reduce the feature gap between UI and text based rules
  2. I had issues with rules executing while states haven't been restored yet and moving it to level 100 seems to resolve those cases
  3. There are cases where you have rules that are supposed to "initialize" some items and other rules to run after that. This is now possible by having initialization rules run in level 40 and rules depending on those in level 50 (or 100).
  4. Some rules may depend on the UI to be available because they trigger external scripts that fetch something from the UI. Then those can be moved to level 100. As far as I can see that should already be possible now, even though other levels

Anyways, I understand your concern about this being potentially confusing. To fix that I suggest adding a warning if a startup level < 40 is supplied that "Rules can not be executed until start level 40 is reached".

We would also have to change the documentation which is currently stating
"Startlevels (logically only if startlevel >= 40) are only available in UI-Rules, not in DSL-Rules with textual configuration."
to something like
"Startlevels less than 40 are not available as the rule engine needs to be ready first before it can run any rules." (not sure if "start level" or "startlevel")

We can also put this aside until other levels are implemented, but with proper documentation and even a warning in the logs it should do no harm to merge it now, even though the full use case will only be visible later.

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your explanation @Flole998!
Fine for me to add this so that DSL-rules have the same features as UI-rules.
Maybe then worth to pick up the implementation for higher start levels soon. ;-)

Could you be so kind to also provide a PR for the documentation?

@kaikreuzer kaikreuzer changed the title Implement new "System reached start level XX"-Trigger for DSL-rules "System reached start level XX" trigger for DSL rules Jan 17, 2022
@kaikreuzer kaikreuzer added this to the 3.3 milestone Jan 17, 2022
@kaikreuzer kaikreuzer merged commit b6bac8d into openhab:main Jan 17, 2022
@Flole998 Flole998 deleted the startleveltrigger branch January 18, 2022 15:24
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/non-deterministic-order-of-startup-rule-execution-and-thing-initialization/135755/3

splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DSL rules Domain-Specific Language rules enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants