Input "enum" with options array

I have a dynamic page that I am reading the available home modes into an array (for analyzing) and then trying to use that array (and a variation of that array) in an enum input type. I am getting the home modes into the array fine, but when I launch the dynamic page in the app, I am getting “Error: There was an error, please try again”.

Initially I am wanting to read in all available home modes into an array. Once I have that working, I want to analyze that and create another array that has most, but not all of the listed home modes to produce an input with home modes, but excluding some. I think I can do this once I figure out what I am doing wrong with creating an array and enum input with the full home mode list.

Any ideas on what I can do to accomplish this?

def pageConfigMode(){
    def locationmodes = []
    location.modes.each(){
        locationmodes += it
    }
    log.debug "locationmodes=${locationmodes}"
    dynamicPage(name: "pageConfigMode", title: "Configure Modes", install: false, uninstall: false) {
        section("Mode Group 1"){
            input name: "modePhraseGroup1", type:"enum", title:"When mode changes to: ", options:locationmodes, required:false, multiple:true, refreshAfterSelection:true
        }
    }
//End pageConfigMode()
}

for multiples, try metadata instead

input name: "modePhraseGroup1", type:"enum", title:"When mode changes to: ", metadata:[values:locationmodes], required:false, multiple:true, refreshAfterSelection:true

Thanks for your reply.
I am getting the same error (“Error: There was an error, please try again”).

I tried with:

metadata:[values:locationmodes]
metadata:[values:{locationmodes}]
metadata:[values:[locationmodes]]
metadata:[values:(locationmodes)]

log.debug “locationmodes=${locationmodes}” – does return as an array with all of the home modes:
IDE Logging shows: locationmodes=[Away, Home, Night, Vacation, Auto-Away]

Works for me. Try deleting the whole smartapp and loading it back again.

I was happy to find this post because I was doing something similar and wanted an example. Unfortunately it didn’t work for me, but the code below did.

Since location.modes.each() returns a mode, .name method returns a string containing the name per the info here: https://graph.api.smartthings.com/ide/doc/mode .

def locationmodes = []    
    location.modes.each(){
        locationmodes += it.name
    }

Good info to know, thanks.
I ended up using:
input name: “modePhraseGroup1”, type:“mode”, title:"When mode changes to: ", required:false, multiple:true, refreshAfterSelection:false

That works if your want to select from the list of available modes. For my application I actually need the strings. Thanks.

yes “enum” option appears to be broken. ST’s done something recently.
I was using this with a device type, initially the sample code said to use type “enum” and the options were listed as

metadata:[values:[“Lowest”,“Lower”,“Low”,“Medium”,“High”]]

now the documentation states:

options:[“Lowest”,“Lower”,“Low”,“Medium”,“High”]

and BOTH no longer work with the device types.

Anyone have success with getting this to work? Funny part, I have a device which I had configured 6 months ago and I knew it worked. Today it doesnt :))

@Jim can you throw some light on this? I’m getting pretty lost trying to keep my apps upto date with ST updates.

1 Like

Known issue:

Can you point me to the location in the docs for this, so I can better understand the context? Thanks!

Its broken for me too. You can still update the value via graph

http://docs.smartthings.com/en/latest/smartapp-developers-guide/preferences-and-settings.html#input

enum uses options now. But it no longer works with device apps. I get an error “No available options” when I click on the enum input in a device app (this used to work fine till some time ago, albeit it used to be metadata: values: instead of options:)

1 Like

yes but that’s not a reliable way especially with enum’s since the graph doesn’t give you the options available and typing in an incorrect options can be disastrous.

Dude, it’s not an issue of documentation, enum is just plain broken for devices right now, and has been for almost three weeks… Booleans (which used to be evaluated as strings) are now booleans as well…

1 Like

bingo! the boolean was another thing that broke all my apps, I had recode them all as well.
So really am trying to figure out how long before enum get fixed! I can’t do anything with my devices that use enum.

nor can anyone else, jump on the thread i created for this, open a ticket and link to that thread. The ticket I opened was pretty much back burnered until others started joining in and noting the same issues.
Support does triage the number of complaints regarding a specific issue to adjust the priority Q.

2 Likes

It’s not about reliability – its the only known workaround right now.

Just wanted to mention, I think this is almost fixed now but not quite. If you only select one item in the enum, everything is fine. However if you select more than one, ST just saves the first item even though multiple: true.

1 Like

Hi All,

I am about ready to release my Denon AV Receiver device type. It works great, but like my Yamaha receiver you cannot select which inputs to use from the settings. This is because the “enum” option is still broken. It was partially fixed a few weeks ago, but does not allow “multiple” and “enum” at the same time.

Rather, it allows it, and the user can click through. The UI even displays the results correctly. However, on a “save”, all but the first result get discarded. Please fix this!

Kristopher

1 Like

Hi @copyninja, I just came across this forum.
It works for me, thank you!
Now I need to do the opposite : show only the modes which have NOT been selected and for now I can’t figure this out. Any idea? :slight_smile:

Thanks a lot