Set to "Previous Mode"?


(esung) #1

Hello
Is there a way for an action to set the mode to whatever ‘previous’ mode ST was in? If not yet, this could be a useful trick an action can take.
For example, my alarm goes off due to some trigger and changes mode to ‘alert’ but after checking everything is fine I want to set it back to normal by running an action ‘alarm off’ which should be able to set the mode back to whatever it was in before - home, night, away…


(Im Brian) #2

You can store values in the state variable and use that stored value to put the mode back when you’re done. Pseudo-code:

def newMode = 'alarm'
state.oldState = location.mode
setLocationMode(newMode)
// after some interval:
setLocationMode(state.oldState)

(esung) #3

Thanks @imbrian
As I get acquainted with scripting I’d look into it. I realize that you can expand ST’s functionality greatly by learning to code and I’m willing to do it.

I hope ‘previous mode’ becomes one of the options that user can choose when they set up action or apps, and that alone could benefit many users without ability or willingness to code.