Weirdness with Enum Type Preferences Inputs

Hey, everybody. I have a driver with a preference defined like this:

input name: "receiverZones", type: "enum", title: "Zones", required: true, multiple: true, options: ["Main_Zone","Zone_B","Zone_2","Zone_3","Zone_4"]

If I iterate through the selected preferences like this:

settings.receiverZones.each { log.debug it }

Then I'm getting some weirdness. When multiple options are selected it is behaving as expected and I would get the multiple options. When only one option is selected instead of the iterator iterating once it is instead iterating each character in the String of the single option.

Based on this behavior I'm guessing that the UI is passing a data structure in when there are multiple selected but passing just the String value when there is one preference selected. This should probably be fixed so that when an input is defined with "multiple: true" a data structure is always passed (map or array or whatever the container in this case is. I didn't check).

Can anybody else confirm this behavior?

1 Like

Are you running the latest version of the hub firmware?

I think this was a bug that was fixed in a specific version.

I use this all the time and it always returns a list for me. I'm running the latest version.

I'm on version 2.0.4.118. No update is available.

Oh. That is the latest.

Just realized you said driver. I use it in apps. Maybe there is a difference in the driver then. This I can't confirm. I haven't done this is a driver yet.

One more thing I should add; when I have multiple saved when the page refreshes after post it often does not load the values correctly into the input and the end user can't tell what is selected. I'm not sure if this is related but might as well get fixed at the same time. Probably in the same bit of code.

Tagging @chuck.schwer

Maybe this: Selecting with multiple:true in driver not supported?

3 Likes

Sort of... except that it seems to be implemented. It works but with the caveats I mentioned. I would have guessed that if it wasn't implemented it would have failed fairly completely.