Initiate SmartApp via HTTP Get or Post?


(Chrisb) #1

Is it possible to initiate a SmartApp via HTTP POST or GET?


(Reed Taylor) #2

I’ve been doing this via a virtual switch as the smartapp initiator (subscribing to “on” events, then resetting it in the event handler) and then flipping it using URLs in the example OAuth script provided by SmartThings (happy to share links if you need 'em).

So far I like the virtual switch trigger solution – even though it creates some “clutter” – because it also allows various smartapps to trigger one another via switch flipping.


(Chrisb) #3

Yeah, that’s what I’m doing for most of my SmartApps to that I’m triggering via Ubi. Just wondering if there was a “cleaner” method to do it.

I’ve got 20 different virtual button tiles running now for various apps and setups. As you said, it works and it does have the advantage that apps can call other apps using this method.

But I’m trying to limit the steps involved in setting up an advanced Ubi/SmartThings operation. For someone who’s relatively new to ST and/or Ubi I trying to share some of the nice stuff that can be done between the setups, but the instructions end up being extensive and complex.


(swanny) #4

Are you guys creating the virtual button tiles manually or can you create them as child devices in the SmartApp?


(Chrisb) #5

I create them manually.


(swanny) #6

You should be able to do something like this in your smart app to make the device:

def child = addChildDevice("smartthings", "On/Off Button Tile", "uniqueDNI", null, [label:"Fancy Tile Name", completedSetup: true])

However, I get this error when I try to use ST default device types:
physicalgraph.app.exception.UnknownDeviceTypeException: Device type ‘On/Off Button Tile’ in namespace ‘smartthings’ not found. @ line 40

This code works fine if I change it to a custom device type. Maybe someone else knows if it should use a different namespace.

I would think using this type of auto device creation should make install and uninstall cleaner for what you are doing?

Dave


(Chrisb) #7

Interesting… I didn’t know about this. Unfortunately it won’t work for my setup. Ubi needs to be able to see the device as a stand alone device so it can use it as a trigger or as an action.


(Geko) #8

Actually, you don’t need to create multiple virtual buttons. You can have one device acting as a bridge between multiple apps using undocumented ‘data’ field in the event class. This is how Aeon Minimote device type is implemented. All buttons send the same message - “pushed” or “held” with the button number is encoded in the ‘data’ field. Then “Button Controller” app parses data filed to figure out which button was pushed. I believe you can extend this mechanism to pass arbitrary messages between the apps.


(swanny) #9

@geko That’s an interesting idea. I’ll have to check it out.

@chrisb Child devices do show up in the My Devices List and in the “Things” section on mobile devices, so I think they can be used like normally devices. I think it just provides convince for the SmartApp to create, destroy and act upon the devices.


(Alex) #10

@swanny
Did you ever got this to work? Is there a way to use the stock devices with “smartthings” namespace or does it only work for custom ones?

Thanks


(swanny) #11

@625alex I didn’t really play around with it any more past what I posted. Sorry.

Maybe @Ben can hook you up with someone who knows how to have a SmartApp select by device type for standard ST devices.


#12

@matthewnohr do you happen to know?


(Matt Nohr) #13

I’m pretty sure the addChildDevice() call only works for child devices that you own. That would explain the UnknownDeviceTypeException error you saw.


(Alex) #14

@matthewnohr
Why is there such a restriction? Is there a good reason for preventing my app to create a stock virtual tile?