-
-
Notifications
You must be signed in to change notification settings - Fork 695
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 Documentation of Transform Values - specifically Script Transformations #2348
Conversation
Transformation as given `JS(|"String has " + input.length + " characters")` gives following error in OpenHAB 4.2.1 log: Configuration error for channel '...' java.lang.IllegalArgumentException: The transformation pattern must consist of the type and the pattern separated by a colon Using format `JS:|"String has " + input.length + " characters"` the transformation works as expected. Signed-off-by: Christoph <[email protected]>
✅ 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).Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
This isn't necessarily an error. There are two syntaxes when it comes to transformations. When using it in sitemaps / labels, you'd use the parentheses, i.e. Perhaps instead of changing it, it could be clarified further about the difference in the syntaxes and when it can be applied. If there's already such a document, perhaps a simple link to it would suffice? |
I'm new to OpenHAB, if |
I've just read the documentation and it is actually mentioned here including examples where it uses the Then on point number 3:
So for example, in MQTT Binding documentation, it gives you the syntax for invoking transformations: Admittedly having two syntaxes isn't ideal and I too have got them confused in the past. How should we make it even clearer to avoid confusion for new users? |
Sorry if I'm mixing up topics. Funny, I have read that usage you mentioned several times but I have also read that general advice not to use textual configuration so I kind of ignored the usage in textual configuration and went on searching for the correct syntax in the web UI. ;) |
@florian-h05 can you confirm that this is correct for jsscripting? |
@jimtng said everything that has to be said. The changes in this PR aren't correct, the examples are for Item state transformations (to be used in the label part of .items files or the state description metadata). From my POV the docs in openhab-docs are complete and correct. I have just checked the linked MQTT docs and the channel add dialog for MQTT things, and there is docs for the MQTT-specific syntax both in the README and the UI: |
Additional JS examples inside these docs are fine, but I am not sure if we want to link to the MQTT docs there - having links from the docs repo content to addons repo content is now always a good idea. The JS Scripting readme also includes a section about Item state transformations: https://next.openhab.org/addons/automation/jsscripting/#js-transformation |
If you think the docs are fine, I apologize for the inconvenience of my PR. For me it took quite some time to get it sorted, that I can simply use |
@vchrizz out of curiosity, why did you need |
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/binding-transformations/157861/1 |
Although this is currently only applicable to the |
From my POV the docs in the docs repo are fine, and if Jims work is adopted by all bindings offering transformations, this will reduce overall complexity.
In that case I think we should improve HTTP docs and a script example inside the MQTT docs would be nice as well. @vchrizz Thanks for your PR — even if it doesn‘t get merged, it put our attention on this topic, which is great! |
After http binding I'll work on MQTT binding. I'll add that in a separate PR later on if I remember! |
I was following some tutorial (which seems to be outdated or incorrect or...), that had me creating some things/channels/items that led to log-messages like |
Ref https://community.openhab.org/t/syntax-for-binding-transformations/157861?u=florian-h05 for progress of the binding transformation changes. |
With all related PRs (see linked community post) merged now, I think we can close this PR. |
Thank you! |
Transformations given as example for JavaScript
JS(|"String has " + input.length + " characters")
result in following error in OpenHAB 4.2.1 log:Configuration error for channel 'mqtt:topic:...' java.lang.IllegalArgumentException: The transformation pattern must consist of the type and the pattern separated by a colon
Using format
JS:|"String has " + input.length + " characters"
the transformation works as expected.