-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
[Feature Request] Add the option to add/create rule based on Template to JSRule or Rule Builder #363
Comments
JSRule and Rule Builder work different to UI-based rules wrt to their structure and rule templates are a UI-only feature. It is possible to create something like JSRule Templates, e.g. by writing a function that creates the rule (I do this really much, e.g. https://github.com/florian-h05/openhab-js-tools/blob/f5e48a2ec0325df920c4ba15dfd1a3d77973220b/src/thingsx/health.js#L129, but instantiating UI-rule templates from script languages is not possible I think and would be high effort to get it working. I think this feature request is a "Won't fix" and I will therefore close this, sorry. |
It's sad that this is marked as |
I think it is easier to rewrite this template to a rule generator function in that case — as long as one is proficient enough with writing code. |
To implement this, one would need to check how rule templates are handled in detail, if it is UI-only or if openHAB core does the work of applying the template (i.e. add triggers, actions, conditions of the template to the rule). If is done in core, it should be easier to do that from scripts. |
According to below file it's added to the persistent storage: And it seems it's also stored inside the Rule itself: And there's also a constructor for it: So with a quick search it seems it's all done inside the |
Could it be as simple as allowing it to be passed here? |
Probably yes - we need to check if it is working and if lifecycle is properly handled. But this should be an easy test. |
Yeah I was thinking about manually editing the source code by manually loading it inside Openhab (through the manual install option) and seeing what it does - probably won't be today - think weekend on it's earliest |
I don't think it will be as easy as we hoped - file-based/unmanaged rules created through scripts are managed by the |
Could be easier than you think - seeing the following line: |
So something as follows is needed to pass it through I think: I added the check if |
Rather fix this line in rules.js. |
It would be great if one could instantiate a rule template from a script in the
automations/js
folder - this way one can create the necessary items/groups etc and instantiate the rule template from one place - so when the script is removed, all gets cleaned up. (At least this is my understanding howautomation/js
is used.Your Environment
The text was updated successfully, but these errors were encountered: