"Press" SmartApp Icon?


(Steve S) #1

I would like to be able to activate a smartapp by pressing it. For example, “The Big Turn Off” - I want to be able to just hit a button on my phone and have it turn off all the lights. Is this possible?

Thanks!


(Im Brian) #2

Apps are able to have in-app buttons associated to an action. In your app, you can subscribe to an “app” to fire an event:

subscribe(app, someMethod)

I’m guessing you were wanting something you could just drop on your homescreen as a shortcut, though - in which case, there’s nothing I’m aware of currently. You could conceivably exploit the ST REST endpoint with just a normal webpage bookmark. That certainly wouldn’t be as they intended to use it, so I don’t know that I’d suggest it. …but it would probably work.
http://build.smartthings.com/blog/tutorial-creating-a-custom-rest-smartapp-endpoint/


(Ben Edwards) #3

I believe there is more of this that is possible on Android devices and it is something we have thought about for the future. Would love to hear more about your ideas for usage.


(Steve S) #4

Ben, I would love to have the ability to program a “macro” button that would do a set of things. I don’t necessarily want to have to switch modes to do it. Here are a few:

  • Hit one button in the app to turn off all of the lights in my house
  • Hit one button to Turn on the TV, dim the lights in the TV room to 50% and turn off the rest of the lights in the house.
  • Hit one button to Turn on/off all exterior lights on my house
  • Imagine I have a bunch of different christmas decorations plugged in to various outlets - turning them on/off, etc.

There’s lots of useful things like this. I have a programmable remote for my TV and audio receiver - I have programmed a macro button to turn on the tv, turn on the receiver, and select the “TV” input on the receiver.

It’s not desirable or even workable to tie these things to a mode.


(Chrisb) #5

@stevesell,

All the things you talk about here would easily be doable with just a standard press to activate app. You’d have to be in the SmartThings mobile app to do it, but still easily done.


(Emily Allen) #6

Steve, you also may want to check out the “Double Tap” SmartApp in the “Connections” category. You can double tap on one switch’s icons to turn on or off any number of other switches.


(Cory S) #7

That’s cool, I didn’t know double tap worked from the app switch as well as physical ones.


(Av8rdude) #8

@emilyallen The Double Tap app does not appear to work like you describe on android. I use the double tap app to control two rooms in my house. It works fine on the physical switches. But if you try to double tap an icon inside the app it only does the on/off feature? I can not double tap on-on or off-off with the app. Am I missing something?
Thanks
Scott


(Steve S) #9

@emilyallen - same here - Double Tap app does not work for me (iPhone 5). Just like @av8dude, when I double-tap the light I have told the app to work with, it just turns that light on/off. Maybe related - double-tap from a switch (GE/Jasco 45609) also not working for me. I now have 11 of the GE/Jasco switches and dimmers installed with two more to go - so I am keenly interested in this functionality.

Also, I would like to point out that the description in the Big Turn OFF app says “Turn your lights on or off when the SmartApp is tapped or activated” - which seems like is wring since there’s actually no way to tap or activate an app direction.

Kind of surprised that this (make a button/app I can “press to activate”) is missing… if “double tap” worked, that would be good until a press-to-activate kind of thing could be implemented.


(Emily Allen) #10

@stevesell I can take a look at the issues you’re having with Double Tap.

As far as Big Turn OFF (and Big Turn ON) go, the place you tap is in the right drawer nav under Explore SmartApps. Apps that can be activated by tapping have a “play” button with a circle around them next to the app name.


(Steve S) #11

@emilyallen - holy cow, that’s not very obvious! It takes two clicks/taps to get to the screen when I can tap to activate… If there are currently no plans to have apps which are tappable place an icon on the “home” screen, consider this a feature request.


(Emily Allen) #12

Steve, agreed that it’s not very intuitive, but wanted to let you know that the functionality is there if you want to use it.

There are many UX changes coming that should make your life easier. Stay tuned…


(Steve S) #13

Emily, great news! Eagerly awaiting the UX update!


(Steve S) #14

I just tried to write my own app that respond a virtual momentary switch, but it doesn’t work… can someone point me in right direction? It seems to install correctly, but never gets the “push” event from the virtual momentary switch.

/**
 *  The Big Off Switch
 *
 *  Author: steve
 *  Adapted from "the big switch" by SmartThings
 *
 *  Date: 2013-05-01
 */
preferences {
	section("When this switch is pushed") {
		input "master", "capability.momentary", title: "Where?"
	}
	section("Turn off all of these switches") {
		input "switches", "capability.switch", multiple: true, required: false
	}
}

def installed()
{
	subscribe(master, "momentary.push", offHandler)
}

def updated()
{
	unsubscribe()
	subscribe(master, "momentary.push", offHandler)
}

def offHandler(evt) {
	log.debug evt.value
    log.debug offSwitches()
	offSwitches()?.off()
}

private offSwitches() {
	log.debug "Got Here!"
    if(switches && offSwitches) { switches + offSwitches }
    else if(switches) { switches }
    else { offSwitches }
}

(Todd Wackford) #15

I’m on my phone so I can’t verify, but wasn’t the event called “pushed”? I think the function was push and the event was pushed.

Twack


(Steve S) #16

@twack - I’ll try that. How does one find that out? I looked at the “example” code for a Z-Wave momentary contact switch, but all I see is a “push” or an action in the simulator that says “momentary.push”

When I call the device’s supportedCommands method, I get [refresh, on, off, push] - so I tried subscribing to “push” and “momentary.push” - neither of which works. when, I press the virtual momentary switch, I see “push command sent to virtual off switch” in the bottom-of-the-screen log in the iPhone.

Any clues?


(Todd Wackford) #17

I assumed you were using the "momentary button tile. The code in that which shows the events is:

def push() {
	sendEvent(name: "switch", value: "on", isStateChange: true, display: false)
	sendEvent(name: "switch", value: "off", isStateChange: true, display: false)
	sendEvent(name: "momentary", value: "pushed", isStateChange: true)
}

The ZWave momentary contact switch the events are are “on” or “off”. I think you may be confusing commands with states or attributes. Its easy to do because many devices have the same names for states and commands. Like “on” or “off” for a switch. As I explained in my last post the function is called “push” but the event drives a state changes to the attribute “momentary” called “pushed”.

Try changing your virtual device to the “Momentary Button Tile” and have the app subscribe to “momentary.pushed”. You can then check the states of the “switch” which are “on” or “off”.

HTH,
Twack


(Steve S) #18

@twack - THANK YOU. This worked. I installed a “Momentary Button Tile” on my home page in the app. Then I made my own smart app with the code below. Does exactly what I wanted it to. I’m including the code here to help others learn.

preferences {
	section("When this switch is pushed") {
		input "master", "capability.momentary", title: "Where?"
	}
	section("Turn off all of these switches") {
		input "switches", "capability.switch", multiple: true, required: false
	}
}

def installed()
{
	subscribe(master, "momentary.pushed", offHandler)
}

def updated()
{
	unsubscribe()
	subscribe(master, "momentary.pushed", offHandler)
}

def offHandler(evt) {
	//log.debug evt.value
    log.debug "Turning off: " + switches
	switches?.off()
}

(Todd Wackford) #19

Glad it worked for you. Virtual switches sure make it nice to control several devices at once doesn’t it? Reduces the number of button pushes too.

Just one question though, why are you subscribing to “momentary.pushed”.off? I think you only need to subscribe to" momentary.pushed". Unless I don’t understand your use case or logic.

Twack


(Av8rdude) #20

Wow…thanks for the example. Since I’m not a developer how could I change this code to toggle off/on with the virtual tile?
Thanks,
Scott
@twack
@stevesell