Initiate SmartApp via HTTP Get or Post?

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

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.

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.

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

I create them manually.

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

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.

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.

2 Likes

@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.

@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

@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.

@matthewnohr do you happen to know?

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

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