I have a small app that does almost what you want. It is tied to a switch, which could be a virtual switch toggled by your button. I don’t know how your button switch works.
The app saves the current mode (so this will work in more than one mode), then runs a Hello Home phrase (which can change the mode). The next time you toggle the switch, it restores the old mode, and runs a second Hello Home phrase.
It’s super simple, and could easily be changed to fit your button switch.
definition(
name: "Movie Time",
namespace: "",
author: "Bruce Ravenel",
description: "This app changes the mode and runs to phrases",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact@2x.png"
)
preferences {
section("When this switch is turned on..."){
input "switch1", "capability.switch", title: "Which?", required: true, multiple: false
}
section("Run this phrase...") {
input "phrase1", "enum", title: "Which phrase?", required: false, options: phrases
}
section("When done run this phrase...") {
input "phrase2", "enum", title: "Which phrase?", required: false, options: phrases
}
}
def installed() {
subscribe(switch1, "switch.on", switchOnHandler)
subscribe(switch1, "switch.off", switchOffHandler)
state.currentMode = location.mode
}
def updated() {
unsubscribe()
subscribe(switch1, "switch.on", switchOnHandler)
subscribe(switch1, "switch.off", switchOffHandler)
state.currentMode = location.mode
}
def switchOnHandler(evt) {
state.currentMode = location.mode
if(phrase1) location.helloHome.execute(phrase1)
}
def switchOffHandler(evt) {
setLocationMode(state.currentMode)
if(phrase2) location.helloHome.execute(phrase2)
}