[OBSOLETE] One button on switch to run two different hello home actions?

So, I have a Smartenit 3 Button switch, which I love. I would really like to assign a button to execute two things:

If in X mode(s), execute Y Hello Home Action
If in Y mode, execute X Hello Home Action

Basically, this would be a Movie Mode / Home Mode button. Press once to place in Movie mode, press again when the movie is done to exit movie mode and enter regular home mode again.

Anyone have any suggestions?

@obycode - This is why I would really love to see individual button support for this switch controller and the Minimote. Your iOS app could so easily handle this with just two entries…without even breaking a sweat. I would have the whole thing setup in less than a minute and a half…and NO CODING!!! :smile:

1 Like

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.

        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() {
    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) {
    if(phrase2) location.helloHome.execute(phrase2)

Does this switch use the standard “Button Controller” SmartApp?

If so, you can just install two instances of the SmartApp, one that only runs in Mode X and one that only runs in Mode Y, and have each instance assign the desired Hello Home Phrase to the same button.

Regardless, additionally, it really would be a great idea to write a new Device Type for all Button Controllers that create child Button Device Instances, one for each physical Button (each of these could / should have Capability Momentary, I think and/or Capability Button … not sure the difference in intention of these two).

1 Like

@bravenel - I completely forgot about the virtual switch option. Might be easier to implement and I can do it with @obycode’s iOS app right now!

@tgauchat - yep, uses the button controller smart app. Although the app thinks it has a lot more buttons. But, I don’t think that app has any “intelligence” to know the device type and buttons available.

Right… I recommend that Device Handlers for multi-button controllers have a static Attribute called “buttonQty” (or “numButtons” is currently the Attribute name in the Enerwave 7-Button handler).

This way any multi-button SmartApps like Button Controller or ButtonsAsPIN will know.