Initial implementation of ConfigOptionProvider interface #495
Initial implementation of ConfigOptionProvider interface #495
Conversation
73409b2
to
2278c69
Compare
Is this really what was discussed in the forum? I thought that the REST interface and the ConfigDescriptionRegistry must not be changed. As far as I remember the idea was to just request a regular config description and internally it adds the dynamic values from the ConfigOptionProvider. |
Yes - I referenced the discussion above and explained why we have to change the REST interface. The REST has to change unless you make a GET /thingtype/{thingUID}/config call - passing the thingUID into a thingtype API seems to me like a bad idea? Or do you think there's a better way? Regarding the Registry - Kai said he wanted to keep the same registry (ie not add another one) but if we don't change something, how can we add a ConfigOptionProvider? Can you suggest how better to change this? |
Sorry, next time I will read the forum first :). I will comment it later or tomorrow. Did you close it accidentally? |
Ooops - yes - I hate the placement of those buttons... Thanks. |
* the binding to ensure that multiple sources (eg static XML and dynamic binding data) do not contain overlapping | ||
* information. | ||
* | ||
* @param uri |
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.
javadoc parameter does not fit
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.
Agreed - this PR needs a tidy (and tests). It’s provided early for comment to see if it even fits the concept as I don’t want to waste time if it’s not something that’s going to be merged.
@dnobel, please also see and comment on https://www.eclipse.org/forums/index.php?t=msg&th=1066227&goto=1711802&#msg_1711802 before further reviewing this PR. |
Yes, I have read it. It seems as we all have a different understanding of the agreed solution. @maggu2810 Let´s wait with the detailed review until we finally agreed on the solution. Feel free to join the discussion. |
Where do you see the two of us differ? |
If you fully agree on my last forum entry, I think there is no difference any more. |
The second possibility is that if I fully agree on your last entry, I didn't read it carefully enough ;-) |
@cdjackson Will you update this PR according to the latest discussion at https://www.eclipse.org/forums/index.php?t=msg&th=1066227&goto=1712198&#msg_1712198? |
Hi Ksi |
b499f4c
to
9a9b36f
Compare
As presented on the forum... This now adds a ThingConfigDescriptionProvider. This is a proxy for things - it gets the config information from the thing-type, and if the thingHandler implements the ConfigOptionProvider interface, it will call the The following code shows an example implementation of the getParameterOptions method for zwave where we might want to add options for a certain subset of options (this is just an example implementation - the final will be more dynamic depending on the actual thing). A new REST resource (GET config-description/URI) is implemented to get the configuration.
Any comments appreciated... As per the last message on the forum, there is another implementation option which makes the ConfigOptionProvider a service, but I think this is simplest given that the ThingConfigDescriptionProvider knows all about things... |
ab91502
to
77f12b8
Compare
@@ -0,0 +1,118 @@ | |||
package org.eclipse.smarthome.io.rest.core.config; |
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.
pls add license header
Updated and also taken account of comments. |
I just realized that this PR also contains a ConfigDescription REST resource. I have implemented more or less the same thing in #517 . Sorry for that. My PR contains a ConfigDescriptionDTO, a mapper class and also takes the language into account, including Swagger annotations. Maybe we could remove the REST resource here. The REST resource in the other PR should smoothly work together with this one. But if you want, you can also copy my changes into this PR. |
I have no such detailed knowledge about that topic as @dnobel, @kaikreuzer and @cdjackson but for me this looks good. |
Please fix the "getConfigDescriptions" function of the "ThingConfigDescriptionProvider" class. See note last week: https://github.com/eclipse/smarthome/pull/495/files#r45886784 |
|
Why is this not needed? Could you point me to the discussion? +/**
+ * The {@link ConfigOptionProvider} can be implemented and registered as an <i>OSGi</i>
+ * service to provide {@link ConfigDescription}s options.
+ *
+ * @author Chris Jackson - Initial contribution
+ */
...
+public interface ConfigOptionProvider {
+ * @return the configuration options provided by this provider (not
+ * null, could be empty)
+ */
+ Collection<ParameterOption> getParameterOptions(URI uri, String param, Locale locale);
You defined the API / the interface, that this function must not return null, so the implementation must not return null. Perhaps I am missing some point... |
|
That is what I would like to say, return an empty list or collection, but do not return null.
Isn't the interface "ConfigOptionProvider" of package "org.eclipse.smarthome.config.core" created by this PR and documented with "Chris Jackson - Initial contribution" |
Maybe I’m missing something still, or we’re talking cross terms?
|
Curious, the diff now is fine (but the one javadoc of the parameter), as of time of writing the above message(s) my browser showed me a diff, that still contains the "return null;". |
So all if fine then? Green light from me as well, so I leave it to @maggu2810 to merge! |
Drink more coffee and stay awake :) |
I think the java doc line needs to be fixed, then I will merge it: https://github.com/eclipse/smarthome/pull/495/files#r46411332 Or is my browser out of date again? |
Signed-off-by: Chris Jackson <chris@cd-jackson.com> (+4 squashed commits) Squashed commits: [20b0989] Revert config description provider Signed-off-by: Chris Jackson <chris@cd-jackson.com> [dc1c53c] Updated PR - also fixes comments Signed-off-by: Chris Jackson <chris@cd-jackson.com> [77f12b8] Updated to support ThingConfigDescriptionProvider Signed-off-by: Chris Jackson <chris@cd-jackson.com> [2278c69] Initial implementation of ConfigOptionProvider interface Signed-off-by: Chris Jackson <chris@cd-jackson.com>
f32931b
to
93be952
Compare
@cdjackson Please add a comment to the PR if you add a new commit. Github does not send a notification if commits are added, a rebase or a squash is done... |
Initial implementation of ConfigOptionProvider interface
@cdjackson Thank you! |
I have locally many failing tests through this PR, most with an NPE like
Did any of you successfully run the tests locally? |
I will have a look at, didn't run a local build before merging. |
First try: Builds fine. Will try again. |
Let's wait for the result of https://hudson.eclipse.org/smarthome/job/SmartHomeDistribution-Nightly/665/ |
This is the same result that I had on my machine: https://hudson.eclipse.org/smarthome/job/SmartHomeDistribution-Nightly/666/testReport/ |
Ah, the line 55... if ("thing".equals(uri.getScheme()) == false) { The error that raises that NPE on my machine has been fixed by me, see #535 I will have a look at the call stack, but I think getConfigDescription must not be called with a null URI. The caller should check for null, not that function. But it is not defined for the interface. |
org.eclipse.smarthome.config.core.ConfigDescriptionRegistry.getConfigDescription(...) states, that the argument URI must not be null. org.eclipse.smarthome.core.thing.binding.ThingFactory.createThing(ThingFactory.java:114) calls getConfigDescription without checking for null... ConfigDescription thingConfigDescription = configDescriptionRegistry
.getConfigDescription(thingType.getConfigDescriptionURI()); |
"return value: could be null" used as an "argument that must not be null". I will create a PR |
Fix #648 |
As described here.
This PR allows a binding to provide custom options in a config description. This information is provided within the CD request through a
GET thing/{thingUID}/config
REST interface.Signed-off-by: Chris Jackson chris@cd-jackson.com