openhab-core: [automation] Binding actions cannot be configured by UIs
This is a follow-up issue of https://github.com/eclipse-archived/smarthome/issues/6602 as no solution has been implemented yet and we need to track it for OH3 release.
While implementing and testing my port of the Pushover add-on (https://github.com/openhab/openhab-addons/pull/8586) I again stumbled upon this missing feature. Currently it is not possible to configure inputs for Binding actions based on ThingActions. The annotated inputs are not visible in UIs.

@RuleAction(label = "@text/sendHTMLMessageActionLabel", description = "@text/sendHTMLMessageActionDescription")
public @ActionOutput(name = "sent", label = "@text/sendMessageActionOutputLabel", description = "@text/sendMessageActionOutputDescription", type = "java.lang.Boolean") Boolean sendHtmlMessage(
@ActionInput(name = "message", label = "@text/sendMessageActionInputMessageLabel", description = "@text/sendMessageActionInputMessageDescription", type = "java.lang.String", required = true) String message,
@ActionInput(name = "title", label = "@text/sendMessageActionInputTitleLabel", description = "@text/sendMessageActionInputTitleDescription", type = "java.lang.String") @Nullable String title) {
logger.trace("ThingAction 'sendHtmlMessage' called with value(s): message='{}', title='{}'", message, title);
return send(getDefaultPushoverMessageBuilder(message).withHtmlFormatting(), title);
}
Internal automation actions like say or playSound define next to the inputs a list of configuration descriptions matching their inputs.
Conclusions of https://github.com/eclipse-archived/smarthome/issues/6602 are:
- No short term solution to add support for input in the UIs. Proposal is to hide all ThingActions.
- The is uncertainty about when to use inputs and when to use configuration descriptions (e.g. currently all existing core actions for NGRE defined them twice, an input and a related configuration).
Question is how to proceed? Should we hide all ThingActions in the near future? Or would it be an option to introduce a way to add configuration descriptions to ThingActions (e.g. by adding a new annotation for it)?
A previous private discussion between @kaikreuzer , @ghys , @openhab-5iver and myself resulted in the following brainstorming:
-
Displaying inputs along with config parameters should be doable to configure an action instance in a rule.
-
Apparently inputs have a type which is referenced in the API as a Java type (like java.lang.String or org.eclipse.smarthome.core.types.Command or org.eclipse.smarthome.core.events.Event), that’s a little bit different to the config parameters whose type is “TEXT” etc. Supporting anything other than primitive types in the UI could be tricky.
-
Given a module type like:

and a rule like:

I’m not sure how inputs are to be configured here, I suppose in the simplest case it’s something like below, with what the user configured in input boxes. But what if you want to use an output from another module?
"inputs": {
"topic": "some/topic",
"value": "somevalue"
}
- It is also IMO not exactly clear which inputs are to be presented to the user and which are “technical” (for example “event” in GenericEventCondition or “input” in CompareCondition).
- The ItemCommandAction module type has both a “command” input and a “command” config parameter described as “the default command to be sent if none is passed as an input value” - this would be confusing for users if both were displayed.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 55 (49 by maintainers)
Commits related to this issue
- Enhance API GET /actions/{thingUID} to return input params as config params Related to #1745 Signed-off-by: Laurent Garnier <lg.hc@free.fr> — committed to lolodomo/openhab-core by lolodomo 2 years ago
- Enhance actions REST API API GET /actions/{thingUID} now returns the input parameters also as a list of configuration description parameters. It is provided only when all input parameters have a type... — committed to lolodomo/openhab-core by lolodomo 2 years ago
- Enhance actions REST API API GET /actions/{thingUID} now returns the input parameters also as a list of configuration description parameters. It is provided only when all input parameters have a type... — committed to lolodomo/openhab-core by lolodomo 2 years ago
- Enhance ThingActions UI support Fixes #1745 Return config description parameters for the ActionInputs of ThingActions for the REST GET /action/{thingUID} and REST GET /module-types endpoints. The co... — committed to lolodomo/openhab-core by lolodomo 2 years ago
- Enhance ThingActions UI support (#4392) * Enhance ThingActions UI support Fixes #1745 Return config description parameters for the ActionInputs of ThingActions for the REST GET /action/{thingUI... — committed to fabgio/openhab-core by lolodomo 2 years ago
I am counting 21 existing thing actions that cannot be run properly due to an unsupported output type:
QuantityType<?>+ 1ZonedDateTimeMap<Instant, BigDecimal>+ 1BigDecimalQuantityType<?>List<String>QuantityType<?>+ 2InstantWeatherResponseActionQueryResultThey should fail here: https://github.com/openhab/openhab-core/blob/main/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/AnnotationActionHandler.java#L119
@jlaur: as you are concerned with energidataservice, does it mean that these actions can be used inside a rule but not through the REST API ?
Here are the types found in existing thing action inputs that will be supported by UI:
QuantityType<Temperature>QuantityType<Power>QuantityType<Energy>QuantityType<Time>And those that will not be supported:
List<String>List<Duration>List<QuantityType<Power>>Map<String, @Nullable Object>It is now done. String value is also accepted for numbers. LocalDate / LocalTime / LocalDateTime / ZonedDateTime types can now also be used by providing a string value respecting the appropriate format. I will document that. I will probably support few additional types to cover most of those currently used in existing thing actions.
Tested, you’re right. In case a parameter is not provided, null is passed as parameter to the method.
So, regarding invokation oif the action through the REST API, it works well for the following parameter types: boolean, Boolean, double, Double, String. Of course, for boolean and double, if you do not provide any value or if you provide null as value, there is an expected exception as null is considered. It fails for parameter of types int, Integer, long, Long, …
I have an idea how to fix that.
In fact we can keep the existing API and just enrich ThingActionDTO.