-
-
Notifications
You must be signed in to change notification settings - Fork 708
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
working example for executeCommandLine in ECMA scripts #1414
Conversation
✔️ Thanks for your pull request to the openHAB documentation! The result can be previewed at the URL below (this comment and the preview will be updated if you add more commits). 🔨 Explore the source changes: 0612791 🔍 Inspect the deploy logs: https://app.netlify.com/sites/openhab-docs-preview/deploys/5ff1b2f5e74bf00008e6b64a 😎 Browse the preview: https://deploy-preview-1414--openhab-docs-preview.netlify.app |
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.
I would not add this to the docs.
Why is sendHttpGetRequest
working (is it), while this method is not?
ALL actions should imho be treated the very same way. We should hence rather find a solution for openhab/openhab-core#2056 and THEN document it here, if necessary.
I think sendHttpGetRequest is not working neither with ECMA Script. The problem with this article is a more common one, because nearly all main articles have "Rules DSL" in mind as a base. We have some issue around here which is exactly adressed to this. So we should aim for a mid-term/long-term doc solution here instead of fixing single articles. |
@Confectrician I referred to the http action, because this is explicitly mentioned for JS here. I assume that it hence at least worked that way in the past. And calling |
I had no time to test it in deep to be honest. I have no real knowledge of what is really possible or even best practice myself. |
I already opened an issue for this problem, but thought it's more a documentation problem: As a non Java-speaking person it's extremely hard to find the right libraries/classes to add, so if the ECMA rules would automatically provide these functions already referenced, it would be very helpful in the migration from 2.5 to 3.x |
Closing here for now. |
@Confectrician As openhab/openhab-core#2056 has been closed without a fix, should we consider reopening this PR or has the documentation evolved too much by now? |
@@ -87,6 +87,11 @@ executeCommandLine("path/to/my/script.sh", itemState1, itemState2); | |||
// When you need the output in your further rule processing | |||
var ScriptResponse = executeCommandLine(Duration.ofSeconds(60), "path/to/my/script.sh", itemState1, itemState2); | |||
``` | |||
When using ECMA rules, you need to make the Java functions available like in this exampe: |
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.
typo: exampe
I would go for reopening, but the branch was deleted already so we have to introduce the changes on our own in a new pr |
See issue #1855. Much of what is discussed in this PR is being reworked by me and @florian-h05 under that issue. We are reworking the entire structure of Rules documentation so they are no longer Rules DSL, or any language specific. Our overall approach is to first present the generic rules concepts (triggers, actions, conditions) and those things that are the same across all the languages (e.g. the types of triggers). Then it's the responsibility of each rules engine to provide reference documentation on how to syntactically implement the rules concepts in that language. As part of this we plan on also reworking the Actions page as well using the same overall approach because Actions really are a rules thing and, at least from the end user's perspective, not something that exists on their own. So if you all can be patient, we might fix this as part of that work as a matter of course. If it's important to get this fix out fast, then I'd recommend including not just ECMAScript 5.1 but also Blockly in the examples. There are already examples documented as part of the JS Scripting reference guide. The rest of the automation add-on's readmes are pretty anemic so I've no idea about them. |
For me it is not that urgent. I will close my PR and leave the branch there, if we get to an urgent point before the rules docs are refactored. |
The executeCommandLine command doesn't work in ECMA scripts as described.
I added an additional, working example to make it easier for beginners to understand what to do in this case.