-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Enhance actions REST API #4392
base: main
Are you sure you want to change the base?
Enhance actions REST API #4392
Conversation
For the following action
The API now returns:
|
ThingActionDTO actionDTO = new ThingActionDTO(); | ||
actionDTO.actionUid = actionType.getUID(); | ||
actionDTO.description = actionType.getDescription(); | ||
actionDTO.label = actionType.getLabel(); | ||
actionDTO.inputs = actionType.getInputs(); | ||
actionDTO.inputsAsConfigParameters = inputParameters == null ? null |
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 rather name it:
actionDTO.inputsAsConfigParameters = inputParameters == null ? null | |
actionDTO.inputConfigDescriptions = inputParameters == null ? null |
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.
Ok if you prefer.
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.
Sorry for picking this naming topic up again, but would it make sense to use the singular?
inputConfigDescription?
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 rather suggest inputsConfigDescription. The plural will indicate we have a list of something.
Or maybe configDescriptionInputs ?
break; | ||
case "java.time.LocalDate": | ||
parameterType = ConfigDescriptionParameter.Type.TEXT; | ||
context = "date"; |
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.
There is AFAIK no date context in the UI, but would probably nice to add one.
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.
date is a documented context value:
Line 318 in 47284e5
* - date: A date string |
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.
Thanks for the link … if it is not in the UI I will add it.
That’s however nothing that matters for this PR, I was just noting that.
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 am curious to check if this is already used by any binding.
We could also check if this "context" is documented in our documentation and not only in Java doc.
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.
time as context value is used by 4 bindings:
$ find */src -name "*.xml" -exec grep -H "<context>" {} \; | grep ime
org.openhab.binding.astro/src/main/resources/OH-INF/config/config.xml: <context>time</context>
org.openhab.binding.astro/src/main/resources/OH-INF/config/config.xml: <context>time</context>
org.openhab.binding.gpio/src/main/resources/OH-INF/thing/pigpio-remote.xml: <context>time</context>
org.openhab.binding.gpio/src/main/resources/OH-INF/thing/pigpio-remote.xml: <context>time</context>
org.openhab.binding.lametrictime/src/main/resources/OH-INF/thing/device.xml: <context>password</context>
org.openhab.binding.robonect/src/main/resources/OH-INF/config/config.xml: <context>time</context>
org.openhab.transform.basicprofiles/src/main/resources/OH-INF/config/time-range-command.xml: <context>time</context>
org.openhab.transform.basicprofiles/src/main/resources/OH-INF/config/time-range-command.xml: <context>time</context>
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.
And datetime or date is apparently not yet used.
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.
So it would be important that you support date and datetime contexts mainly for thing actions.
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.
It is already properly documented:
https://www.openhab.org/docs/developer/addons/config-xml.html#supported-contexts
I have to check if formats mentioned in doc match the ISO formats because you will certainly use the documented formats when calling the action. So we have to support such string formats as input.
...ation.rest/src/main/java/org/openhab/core/automation/rest/internal/ThingActionsResource.java
Show resolved
Hide resolved
7bf450e
to
2ca7f24
Compare
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 than can be mapped to the type of a configuration description parameter. It will be used in particular by Main UI to expose actions. Also enhance the POST API (execute a thing action) in order to be more flexible regarding the type of each provided argument value and to map the value to the expected data type. Related to openhab#1745 Signed-off-by: Laurent Garnier <[email protected]>
2ca7f24
to
9e04605
Compare
@lolodomo The |
I don't understand, Thing actions can already be invoked from rules. ??? |
After reading #1745 completely, yes they could in theory - the problem is however the same we attempt to fix with this PR: The Thing action module types only contain the inputs like the |
@lolodomo Please do not force push from now on - I will start working on your PR as well and create a PR to your PR branch afterwards. |
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 than can be mapped to the type of a configuration description parameter.
It will be used in particular by Main UI to expose actions.
Also enhance the POST API (execute a thing action) in order to be more flexible regarding the type of each provided argument value and to map the value to the expected data type.
Related to #1745
Signed-off-by: Laurent Garnier [email protected]