Is there no trigger from a simple phone button?


(Bob Anderson) #1

I’m on my second day of playing with SmartThings, I’m a software engineer by day. I’m having a little trouble with the mental model of how things are organized a bit.

So SmartApps look great, I’m a programmer, so I love that wide open sandbox capability. I’ve got devices that trigger events that I can write handlers for. Great. So where is the event for clicking a button on my phone?

I must be missing something simple, but I’ve searched and read documentation, and I haven’t seen it yet. I see a bunch of sensor events, and have been able to make my motion sensor trigger a callback, but now I just want to have a button on my phone that triggers a callback (that starts a slow ramp-down of a dimmer, but that’s not pertinent to my question).

Any help appreciated.


Struggling newbie with iTach
#2

There are several ways to do this.

A hello home action is the first way.
Once you have one set up, you can then either use it from inside the ST mobile app (a bit tedious), or you can set up a widget to trigger it (fast and easy). ST widgets are now available for both Android and iOS, I’m not sure about Windows phone.

Alternatively, and good for any phone os, you can associate the hello home action (or your own custom smartapp) with a virtual switch, then use the IFTTT DO button app to flip that switch.

Also, you can make the virtual switch a tile in the free dashboard app, SmartTiles. Very popular, officially supported for installs, and very nice. You can have multiple versions, including one with just a few tiles for fast action:

So basically if you’re writing a custom smartapp, associate it with a virtual switch, then flip that switch directly in a SmartTiles tile or in the official ST mobile app on the Things screen, or wrap it in a Hello Home Action and trigger that as a widget or an IFTTT Do button.

It’s indirect, but once you have it set up, easy to use.

You will find virtual switches the key to solving a lot of use cases in ST. SmartApps and Hello Home Actions can subscribe to the events of a virtual switch, and the virtual switch fits both the official UI and most of the integrations with outside services.

This might be of interest as well:


(Bob Anderson) #3

Thanks for your pointer. It’s a bit strange, I skimmed the entire SmartThings Developer Documentation guide today, and I don’t think the phrase “hello home action” appears anywhere in there. A search seems to confirm that. Isn’t that a bit strange?

Second issue, I went into the Hello Home Actions, this seems to give me a list of some pre-defined actions like turning something on or off, but I don’t see a way to trigger a callback to a custom event handler. Am I missing it?

The IFTTT pathway seems viable, but do I really need 3rd party integration tools to have a single button?

The thing which is confusing me is it seems like there is a UI builder for SmartApp preferences, but the app itself is UI-less from the phone? Is that the idea? That’s a little confusing, because it seems like the primary way a user might want to interact with the system directly.

I will also look into this smarttiles app, that sounds like it might fit the bill, even though I’m a little taken aback that we’re into 3rd party stuff for something as basic as that.


#4

It’s a mess.

Hello Home Actions are part of the official app intended for use by non coders. That’s why I suggested reading the scheduler FAQ before you get elbow deep in the developer docs. Hello Home Actions are all over the intro materials for noncoders.

Then what you can do is have a custom app subscribe to the events of a virtual switch, then have the hello home action flip the virtual switch. It’s hokey, but it gets you into the official UI, in particular widgets.

And, no, custom code is not supposed to generate its own widgets in the ST verse. Or its own UI.

There are a couple of member created rules engines, that do, for example. But they have to be hosted elsewhere.

SmartTiles is a bit different. It was created by a community member, but SmartThings gave it official acknowledgement and it can be installed through an official ST mechanism.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #5

You’ll soon discover that’s the least “strange” or surprising thing about SmartThings.

@JDRoberts has voluntarily writing and posted many FAQs here, so glad he jumped in.

The latest Android App has a widget that can be used to call any “Hello Home” phrase (they are called phrases if you want to execute them in your own SmartApps.

Also be sure to check out http://SmartTiles.click for an excellent lightweight browser based UI.

And browse the Forums extensively. :wink:


(Bob Anderson) #6

Thanks, you’re very helpful.

Learning of the existence of “virtual switch” was a small breakthrough. Although I have to say it seems convoluted. Coming at this cold and after a first read through of the basic abstractions, I would have expected that the smartphone device would support a button capability, and I’d simply set up handlers to respond to that. But I guess that’s not possible if SmartApps have no UI elements.


(sidjohn1) #7

You can also check out pollster : https://github.com/statusbits/smartthings/tree/master/Pollster
This is an app that executes when touched and also on a timer. Ive also seen other smartapps make themselves executable on touch by subscribing to themselves. I hope this helps


(Tony - SmartThings Unpublished Contributor ) #8

Specifically, just add the subscription

 subscribe(app, onAppTouch)

and then add code you want executed on button touch within the event handler onAppTouch() method.

You can call the event handler anything you want.


(Bob Anderson) #9

Ah! So the app icon itself can act as a button if you just want a single one? Is there a way to trigger that with 1 click instead of 3? (ST app, My Apps, app icon), maybe using a widget?


(sidjohn1) #10

Yes, but its a bit convoluted. Create a “Hello Home” action to turn on a virtual switch, write your smartapp to subscribe to the on command and execute what every code your heart desires and then turn the virtual switch off. Pin the “Hello Home” action as a widget in iOS or android. Its a bit hackey, but it will work. A little searching around the forums will fill in the blanks.
Me personally… and this is just my 2 cents. Interact with the smartthings IOS/Android/Windows app as little as humanly possible. Allow yourself the hardware and write your smartapps to be smart enough to figure everything out that it needs to do an when to do it with out you having to push a button. So yes script yourself out of needing to push that button :wink: You will be much happier with smartthings if you do.


(Bob Anderson) #11

Thank you.

I agree with your basic philosophy of preferring automation over user-initiated action as much as possible. But sometimes it can’t be avoided, e.g., the “I want to watch a movie now” sensor has yet to be developed. :smiley:


(Tony - SmartThings Unpublished Contributor ) #12

Yes, each app can act as a single button.

You could use the ST widget to control Hello Home actions and other things.

If you have android devices, check out Tasker. If you have a jailbroken iOS device, check out activator, assistant+, activate command.


#13

This is the “home automation” vs “home control” argument. I think it usually comes down to individual use cases. Some people will prefer one, some the other, most a mix of the two.

Because I have a lot of visitors (large family that visit often plus personal aides), I find I need to offer intuitive home control options pretty much in every room. Even if the automation exists and works fine, the visitors won’t all feel comfortable with it.

But there’s no question you’re right that the ST official mobile app seems much better suited to home automation than home control. Although the recent addition of widgets is a nice control feature. :blush:


(sidjohn1) #14

Tasker is good stuff, I’m considering buying a pressure mat to place under my sofa cushion so when i sit in my spot my TV, Stereo system and Apple TV all magically power up from cold off or sleep mode and await my commands. Drat… I think that is still technically pushing a button :wink:


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #15

It’s called: “Alexa, Turn on Movie Mode”. And it works…!!!


(Bob Anderson) #16

Good point!

Does it work with two kids in a shouting match, one jumping on a squeaky trampoline, and a dog barking at the same time? 'Cause a button is robust to that. :smile:

Maybe it just needs a new prefix “Everybody STFU!.. Alexa, turn on movie mode”


#17

My favorite unboxing video ever: 1 new Echo, 1 ipad with Siri, 1 dad, 1 mom, 3 little kids.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #18

“Alexa … play movie Frozen! … again … again …”.


(Tony - SmartThings Unpublished Contributor ) #19

Not true if you have Kodi/XBMC - use pushbutton to send notification to ST that movie has started playing.


(The Viking AKA "Holy Crap You're a Giant!") #20

The question is: How do I do this?
I don’t have ANY programming background.