-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
Thing page: Support invoking Thing actions & Viewing their output #2818
Conversation
…utput Refs openhab/openhab-core#4392. Closes openhab#2817. This adds a new section "Actions" to the Thing tab of the Thing page, which provides a button for each UI-supported Thing action. Clicking on that button will open a popup, where action input can be configured and action output can be viewed. Currently, action output is displayed pretty for the `result`, `qrPairingCode` and `manualPairingCode` keys of the response object. In addition to that, the raw output can be viewed. Signed-off-by: Florian Hotze <dev@florianhotze.com>
@digitaldan WDYT? |
#2388 Bundle Size — 10.84MiB (+0.04%).cd8abd9(current) vs 85c3c31 main#2386(baseline) Warning Bundle contains 2 duplicate packages – View duplicate packages Bundle metrics
|
Current #2388 |
Baseline #2386 |
|
---|---|---|
Initial JS | 1.9MiB |
1.9MiB |
Initial CSS | 577.21KiB |
577.21KiB |
Cache Invalidation | 23.61% |
22.77% |
Chunks | 226 |
226 |
Assets | 249 |
249 |
Modules | 2923 (+0.1% ) |
2920 |
Duplicate Modules | 149 |
149 |
Duplicate Code | 1.8% |
1.8% |
Packages | 96 |
96 |
Duplicate Packages | 2 |
2 |
Bundle size by type 1 change
1 regression
Current #2388 |
Baseline #2386 |
|
---|---|---|
JS | 9.06MiB (+0.05% ) |
9.05MiB |
CSS | 864.03KiB |
864.03KiB |
Fonts | 526.1KiB |
526.1KiB |
Media | 295.6KiB |
295.6KiB |
IMG | 140.74KiB |
140.74KiB |
HTML | 1.38KiB |
1.38KiB |
Other | 871B |
871B |
Bundle analysis report Branch florian-h05:thing-actions Project dashboard
Generated by RelativeCI Documentation Report issue
I assume you display the action output label. |
Sounds good 👍 |
Do not forget to consider actions without any input. I am bluffled, you did that so fast! |
I will have to check again all existing thing actions with output(s) to check that output "name" is properly defined. |
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.
No notes.
If it's good for everybody, it's good for me.
Those are considered as well as actions without any output — in both cases a specific message is displayed instead of the inputs or output.
The only thing missing at the moment is to render the outputs based on the output definition provided by the API — currently the pretty output rendering is hard-coded, but the raw output can be seen. |
Signed-off-by: Florian Hotze <dev@florianhotze.com>
The output rendering now renders all keys of the response object and takes the labels from the output definition. @digitaldan For the matter binding, you can either define: @ActionOutputs({ @ActionOutput(name = "qrPairingCode", label = "QR Pairing Code", type = "qrCode"), @ActionOutput(name = "manualPairingCode", label = "Manual Pairing Code", type = "java.lang.String") }) or @ActionOutputs({ @ActionOutput(name = "qrCode", label = "QR Pairing Code", type = "java.lang.String"), @ActionOutput(name = "manualPairingCode", label = "Manual Pairing Code", type = "java.lang.String") }) |
Signed-off-by: Florian Hotze <dev@florianhotze.com>
5239dbc
to
cd8abd9
Compare
FYI it seems the ActionsOutput annotation is used wrong in many bindings given the core implementation of annotation parsing, I have created a doc PR to fix that: openhab/openhab-docs#2388 |
We will have to check and fix all existing thing actions returning something. Do we really need the @ActionsOutputs annotation when there is only one @ActionsOutput annotation? |
I find 0 trace of ActionOutputs in our code base. |
If I understand the current docs, the annotation is only to be added if you return a Map<String,Object>. My correction to the docs is, that if you return a Map<…>, you need to annotate with ActionInputs for core to recognise the annotation — see the linked core code in my doc PR. |
@lolodomo But let us continue this discussion in openhab/openhab-docs#2388 as this is not related to the UI. |
@digitaldan I think I will merge this PR so you can use it in the latest snapshot, from my testing it works fine. Please refer to #2818 (comment) for the required annotation for the Thing action. |
Refs openhab/openhab-core#4392.
Closes #2817.
This adds a new section "Actions" to the Thing tab of the Thing page, which provides a button for each UI-supported Thing action.
Clicking on that button will open a popup, where action input can be configured and action output can be viewed.
All keys of the action output response object from REST are rendered as list Items, the labels are taken from the action output definitions and fallback to the key.
If the key is
qrCode
or its output type is defined asqrCode
, its value is rendered as QR code.For actions without inputs or without outputs, messages are shown indicating that there is no such.
This PR marks the cold related to the old config actions as deprecated, my wish is to get rid of those config actions and have Thing actions used instead.