Is there a way to dynamically provide option values for dropdown

I’m trying to have in the UI a dropdown with possible selections.
The list of possible selections is not predefined, but instead coming at runtime.

Is there anyway a binding can provide something like that.
e.g. in the sitemap you can define a selection, where the options are coming from the mapping., similar, in the things-type.xml I can define the option values. However, in this case I would like to do it dynamically instead of statically so to show only the possible options that are currently available.

Yes. You need to provide a ConfigurationProvider and intercept the requests for the type. If you take a look in the ZWave source you’ll see what I do. In the ZWaveConfigProvider I add extra parameters to those defined in the XML…

Hi Chris,

I was trying this approach, indeed it works, but seems to be applying binding wide. Not thing specific.
In zwave binding, the options you create are always for a thingtype. Which indeed works as above.

However, as far as I could understand, the thing itself is not a part of the implemententation of the ConfigDescriptionProvider, ConfigOptionProvider.

Which works well for zwave, as zwave would only support 1 network.
In case zwave binding would serve 2 independent zwave networks besides each other, I think it would be impossible to make for example the associations work, as the 1 controller may have different set of nodes than the other.

So, I would like to have 1 thing type, but depending on the configuration of that specific thing, present different option in the dropdowns.
Do you see a way around this?

I just have a déjà-vu… This was discussed in length with Chris almost two years ago here:

I cannot remember the exact outcome and I don’t have the time to read through the 3 pages right now… But maybe you want to :slight_smile:

1 Like

Hi Marcel,
No- the options in ZWave are for the thing- not the thingType. If you check the configuration provider, you will find that I filter on thing, and then check the node number - maybe one day I will also need to check the network. This allows me to check the node, and add only options for the specific thing.

The code below checks for the thing -:

        if (uri == null) {
            return null;

        if ("thing".equals(uri.getScheme()) == false) {
            return null;

And then here I check the node -:

        // And make sure this is a node because we want to get the id off the end...
        if (!thingUID.getId().startsWith("node")) {
            return null;
        int nodeId = Integer.parseInt(thingUID.getId().substring(4));

I get the nodeID and use this to provide thing level options…