Question about SmartDevice parse() method

(Igocontrol) #1

Hey y’all,

I’m new to SmartThings and trying to learn the programming environment. In the SmartDevice documentation (, there’s a parse(String) method that appears to be public. I believe it’s called by the IDE when the device is running in the simulator.

However, if I try to call it from the smart app (i.e. ‘myDevice.parse(“blah-blah-blah”)’, I get an error:

error Command 'parse' is not supported. Supported commands: []

Is there a way to invoke parse() method form the smart app? I think injecting messages into device would be very handy.


(Florian Z) #2

I am unsure whether you can invoke the parse() method on the device handler inside a SmartApp.

As a work around, you can add a custom capability under “Device Settings”, and call it something like “myParse”. This will give your device handler a “myParse” capability, which you can call like so: myDevice.myParse() from the SmartApp. Within your device handler, you may be able to dispatch the call to the parse() method.

This should get you unstuck for now. Having said that, it feels like calling the parse() method from inside a SmartApp would be the wrong way to go about this. It may be better just to think of the command that you are trying to inject into the parse() handler, as a capability on the device. From an API standpoint, it may not be desirable for you to allow injection of any command into the device handler (i.e. publicly exposing the parse() method). There may be some device state (now, or later), that you may want to manage internally, instead.