Simple SmartApp Tutorial (SmartApp SDK)

The end goal for sharing is going to be publication. In the old groovy world, one had to pass around code. We are hoping to eliminate that for the average user.

1 Like

Thanks for your feedback, @jody.albritton. Iā€™m sure SmartThings team is working on this. Canā€™t wait to see this public sharing feature to be supported in near future.

1 Like

im having the same problem lol, im not super tech savvy so theres gotta be something im missing. ive done everything in this tutorial step by step just wondering what ive missed. i guess i need to keep doing my research. i had no problem installing smartapps using the ide and copying code, this seems a little tricky, but i will learn before its all said and done lol

Yeah I was having the same problem, here is how I got around it. If you go to your glitch project where you can actually edit code, there is a pop up menu on the bottom left when you click ā€œtoolsā€ . Click on it and then click into ā€œLogsā€.

A log window will appear at the bottom with any HTTP requests sent to your application, they should look like this.

2020-08-25T12:06:24.071Z info: CONFIRMATION request for app WHATEVER-YOUR-TOKEN-IS, to enable events visit https://api.smartthings.com/apps/WHATEVER-YOUR-TOKEN-IS/confirm-registration?token=CONFIRMATION-TOKEN

All you have to do is paste the https://api.smartthings.com/apps/WHATEVER-YOUR-TOKEN-IS/confirm-registration?token=CONFIRMATION-TOKEN portion from your log into a browser and then when you go back and check the your app on the Samsung developers website it should be verified.

Hope this helps!

5 Likes

@jody.albritton Just finish our workflow on using your SmartApp SDK for creating a custom API Access app type. Well done, sir. Canā€™t expect more from an SDK. Thank you for your great work!

2 Likes

Developer Mode and App is not available on IOS?!
While works on the same account in Android.

Hi Andrew,

If you go to the SmartThings iOS app, click on settings and then hold down the ā€œAbout SmartThingsā€ button for 5 seconds. There will be no pop up to reset the app and enter developer mode as on this page (well there wasnā€™t for me). If you close the app completely, on iPhone double clicking the home button then swiping up. Renter the app and head to settings you should see something like the screen below at the very bottom of settings to enable developer mode.

Just went through the video tutorial and like others was able to successful complete my first SmartApp using this new API. Thanks @Warren1 for clearing up the one issue.
A problem that I am having is with the live logging. I donā€™t see anything. Everything works, just no live logging. Is there something Iā€™m missing?

I was hoping I could get some help with a webhook app Iā€™m working on. I have node.js running on my own server, with a javascript program to response to calls, but I cannot seem to get SmartThings to verify app registration. I confirmed that my server is responding to POST and GET commands, but it never receives anything from SmartThings when I attempt to verify the app.

Anyone else having such a problem?

Have you registered your app through the Developer Portal for OAuth?

You need to fill out this form to register with SmartThings also if you want to link it back to your own server. It will let you set up an OAuth project then.

Iā€™m receiving correctly the request for verification. Make sure you are passing the request to the appā€™s handler handleHttpCallback.

const app = new SmartApp()

server.post('/', async (req, res) => {
    app.handleHttpCallback(req, res);
});

I have that line in my code to respond to POST requests. I have it listening on port 3001, so I donā€™t know if this could be a problem.
Testing POST and GET requests to my server works from outside my LAN. But it does not receive any requests for verification from smartthings. Could it be that I doesnā€™t work with a port not set to 443 for https requests for verification?

So I found out my problem. Using cURL, I would get a certificate error, but couldnā€™t figure out why, as using online tools everything worked from the browser. It appears that the certificates for my server were the issue. Placing the contents of the certificate chain into the cert file allowed it to work with cURL. I then attempted to verify the app with smartthings, and BINGO, it works!

1 Like

Awesome! Thanks for sharing your solution.

1 Like

When I try to follow above, I couldnā€™t find the SmartApp on my Galaxy note10 mobile. With that I think itā€™s been 2 years from this. Is it still available to follow the instructions above?

Well, I could see a SmartApp as my example in routine of SmartThings menu.
Does SmartApp have to be used only for routine having condition and action?

To see your custom SmartApps you need to:

  1. In the ST app, go to Automations
  2. Select add (+) and tap on ā€œAdd routineā€
  3. Go to ā€œDiscoverā€. Scroll down the page and youā€™ll find the SmartAppā€™s list at the bottom.

Please, let me know if you found it.

3 Likes

No. As you will discover the Automations tab of the mobile app lists three sorts of Automations. First Scenes, then Routines (which used to also be called Automations but were sensibly renamed) and then your installed SmartApps. The + menu used to have an option to add SmartApps but that was moved into the Discover tab of ā€˜Add routineā€™ below the Routine templates. It didnā€™t make much sense when Routines were still called Automations and makes even less now.

1 Like

Thanks for your swift answer, I found it as you explained.

1 Like

I have nodeJS SmartApps Iā€™m running on a Raspberry Pi using ngrok. Because I have the free tier version of ngrok, I get only one URL to use, so I have to use the same one for multiple SmartApps I may want to be running. So far this hasnā€™t been a problem, as I can simply key off of the appId when a POST message is received to direct the message to the right SmartApp instance.

However, I have run up against an issue with the language support: I have these lines in my SmartApp instantiation for each of two SmartApps:

.configure 18n({prefix: ā€œapp1_ā€})

.configureI18n({prefix: ā€œapp2_ā€})

This allows me (presumably) to keep the en.json files separate for each SmartApp, at least that was the intentā€¦

The problem is that this doesnā€™t work. It seems that the SDK is not keeping the two I18n instances separate. Only the .configureI18n for the second SmartApp that is loaded (via nodeJS require) seems to honored. The first SmartApp to load is missing all its text in the mobile app; the second one is fine. If I copy all of the app1ā€™s json into app2ā€™s json file (app2_en.json), then they both work ok. This leads me to believe that invoking .configureI18n uniquely for different SmartApps doesnā€™t work properly in the SDK.

Is there some other way I can accomplish this? I donā€™t see any other way of providing a specific file name to .configureI18n, but if the SDK isnā€™t keeping them separate across SmartApps, then it may be impossible without a fix to the SDK.

Hi, Todd!
Please, allow me to check with the engineering team and Iā€™ll get back to you as soon as I can.
Update:
@TAustin, the workaround youā€™re using is the best bet. The team mentioned it is due to the way the i18n package is handled by the SDK.
So, please open an ā€œissueā€ directly in the Github repo so they can analyze it further and see if it can be supported.

2 Likes