How to allow user to select from a list of values


(Rusty) #1

I’m trying to write a device handler that has a single attribute, and allows the mobile app user to select from an enumerated list of values, like “Item 1”, “Item 2”, “Item 3” to assign to that attribute. It would akin to a select drop down on a web form.

I understand the controlTile() would be used to offer up functionality to the user. However, controlTile() seems to only offer 2 control type options – a color picker and a range slider – neither of which resemble a select box.

What other ways might one accomplish such a functionality for a device?


(Allan) #2

You can set a user preference that has a list. Her is a enhanced contact sensor I wrote for Konnected that has it as a option, maybe this is what you are looking for:


(Rusty) #3

That is good info thank you… I’d like the user to be able to operate the control using the described method of selection from a list. So having them go to the settings every time they want to operate the device might not make sense.

However, I think I’ve got a new perspective on this after looking over numerous other deviceHandlers in Github. Rather than looking at it as a single tile that offers a list of selections, I’ve set it up more like “radio buttons”, where there are numerous individual tiles, and each button repesents one of the options. The code in the device handler handles making sure only one of the buttons is selected at a time. It seems like this is the way SmartThings envisions this type of control happening.