when trying to retrieve unique system identifier of the mode it throw this error:
3:34:28 PM: error groovy.lang.MissingMethodException: No signature of method: java.lang.String.getId() is applicable for argument types: () values: []
Possible solutions: getAt(groovy.lang.EmptyRange), getAt(java.util.Collection), getAt(java.util.Collection), getAt(groovy.lang.EmptyRange), getAt(groovy.lang.Range), getAt(java.lang.String)
according to doc here that should be an available property for mode:
I have it working fine in a smartapp method using it like this:
def updated() {
log.debug "Updated with settings: ${settings}"
def curMode = location.currentMode.getId()
log.debug "The current Mode ID is: ${curMode}"
}
6:09:41 PM: debug The current Mode ID is: dac2e714-3898-4ee9-b6ce-832eef3594aa
Which matches the mode UUID I can find in my Hub modes definitions in the IDE page.
For the mode name:
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribeToEvents()
def curMode = location.currentMode.getName()
log.debug "The current Mode name is: ${curMode}"
}
6:09:41 PM: debug The current Mode name is: Home
yes, getId() seems to work fine on location.currentMode. however, when trying the same on an input it seems to consistently fail when trying something this:
trying to figure out how to get the id for an user selected mode .
thank you for the link, but i am trying to do something a little different for the app i am working on.
EDIT: should note i was mistakenly using location.mode instead of location.currentMode in the test. fixing that fixes the issue for getId() on current mode as @Philippe_Portes pointed out. however, getId() on an user selected mode from settings still does not seem to work.
Hooo… take care, I believe an input delivers a string. That’s not enough to make it a mode so basically, if you apply the getId() to the result of input, you are asking what is the getID of a string and that cannot work.
You might refer to this documentation example that compares modes like strings in my understanding. http://docs.smartthings.com/en/latest/smartapp-developers-guide/modes.html, the example at the end.
yeah just finding that out. was thinking like device input which delivers a device object, mode would also deliver a mode object. unfortunately that doesnt seem to be the case.
Preferences section (Inputs and Tiles) are parsed contents with very basic features so either you end-up with strings or with proprietary attributes which makes it very basic in term of usage. Nothing fancy to expect there.
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
7
I don’t believe that location.mode has an Id. AFAIK it only returns a string.