Dynamic Drop down Lists

I am modifing a driver which uses a command with enum to have a drop down on the device page. I would like to modify the contents of that drop down at run time. Is there a way of doing that? The metadata section is
'''
command "InputSelect", [[name: "Choose Input", type: "ENUM", constraints: [
"Bluetooth",
"FM",
"Roku",
"TV"
]]]
'''
The current InputSelect code simply uses the current value selected in the drop down and then sends a value to the device, a stereo, based on that.

I am willing to have the real list pulled in updated() or in a refresh(), but would still need to know how to modify the contents of the drop down list.

Dynamic commands (and attributes and capabilities) are not available, so you'll have to try some other approach. One is just offering the full gamut of possibilities and somehow letting the user know that they should only choose certain ones, whether just in documentation or exposing the information elsewhere. One option for the latter is by providing something like a supportedInputs attribute with a JSON list of the possible options (an app that uses the device could then also know to read this and only present certain values; the device detail page isn't really ideal for day-to-day control, though it works).

If it makes sense to expose this as a preference instead of a command (keeping in mind that this won't be available to apps), you could also try that--you can dynamically change the options presented for inputs.

These are just a couple possibilities.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.