Simple SmartApp Tutorial (SmartApp SDK)

Getting Started with a Simple SmartApp using the new SmartApp SDK

This SDK builds on the CoreSDK and provides kick start for SmartApp development. The SmartApp SDK reduces the amount of code necessary to write a SmartApp using the new platform and API. The SmartApp SDK supports both Webhook and AWS Lamda deployment, but this tutorial will focus on the deploying a webhook SmartApp using Glitch.

Maybe Try this first:

Prerequisites

  • Samsung Account
  • Developer Workspace Account
  • Github or Glitch Account
  • One Contact Sensor
  • One or more Light Devices

Guide

I suggest having all of the required accounts created before getting started. You will need a location prepared with at least one contact sensor and one or more light devices.

Links

SDK: GitHub - SmartThingsCommunity/smartapp-sdk-nodejs: Javascript/NodeJS SDK to create SmartThings SmartApps
Developer Workspace: Developer Workspace
Glitch Project to Remix: Simple Smartapp

Update (2022/12/21)

How to install the SmartApp?

Reference:

Youtube Video

12 Likes

This may be long-answered, but just to clarify - this new path of development means we’re now totally on our own for actually hosting the app? So either we pay for AWS, Glitch, or something similar or our own server setup at home? The flexibility seems cool, but at the same time this seems like it locks out most of the user base from casually sharing code around for easy use.

4 Likes

@brbeaird It is a completely different model. Glitch does have a free option and makes it very easy to share around code. The ease of use is why we picked Glitch for our examples. It could be argued that it is easier to share code around on glitch than it was with the old IDE. That said I think we locked a lot of of casual developers out before by only supporting groovy. Today we rolled out new SDKs that use typescript and javascript. We do have a java sdk and we are looking at other languages as well. By moving towards an API first app platform we are opening things up to all developers and all languages. The hosting was, to me at least, only one minor convenience. We are definitely thinking about how to sustainably run the the platform and be developer friendly at the same time.

1 Like

I can understand that. Glitch seems really cool for sharing the code for sure. Don’t get me wrong - I love this SDK and am pumped to be able to use NodeJS.

3 Likes

This is just the start of the conversation too, so we want to hear all of your feedback as well.

1 Like

What have you got in your mind?

You can run code on a raspberry pi from home without modifying your firewall by using ngrok. Ngrok let’s you run an app tunnel so that you can recieve webhook callbacks for your app.

There is also the opportunity to create entirely client side applications using the CoreSDK that is linked at the top of the post.

https://ngrok.com/

1 Like

I run an old refurbished HP desktop in a coat closet with Unraid OS on it. I already have a few Node projects running in Docker containers on it, so I would probably just build SmartThings projects on that.

But as @jody.albritton mentioned, raspberry pi is a perfectly fine method, too. All you need aside from that is a way to expose it to the outside world, either through a firewall hole in your modem or running something simple like ngrok (although I’m not sure their free tier is stable enough for running something like this 24/7).

The good news is the open API approach gives us tons of options. The not-so-great news is you kinda need a decent amount of experience in this area to get it working, so it may discourage some people who get overwhelmed by it vs. being able to copy/paste stuff into the groovy IDE.

Also wanted to mention - if you guys ever released a hub that could run API apps like this locally and had a built-in way to share and install community apps, you couldn’t take my money fast enough.

11 Likes

Am I hearing local smart app execution??? No cloud?? Take my cash!! :wink: I love the idea of a RPI too as long as it is not too complicated to maintain. I run the interface between my DSC Alarm system and ST on an RPI and am always afraid that if something breaks it will be a nightmare to set back up. I am not a Linux guru so I get lost easily when a new version breaks everything.

4 Likes

Going to be working on a weekend project. Anyone else?

2 Likes

Can this be ran from a Docker container on my RPi with a git clone and Dockerfile.

It can as long as you use ngrok or some other way to get events to the PI

Can I make calls to the hub (HubAction) like the actual groovy implementation ?

We have not released a new solution for hub connected devices at this time. The groovy option is the only solution for hubAction at this time.

1 Like

I seem to stall out at

App Credentials

SmartThings is not able to verify the registration of the WebHook SmartApp. Please make sure your app is available and properly implemented, and verify again. Learn more

I have followed the tutorial 5 time and alway get stuck here any thoughts are pointer on where to look for a clue?

Robert

Hello @Robert_Smith1,

You can try this workaround for the app registration verification:

  1. The WebHook SmartApp must be running to receive the CONFIRMATION request from SmartThings with the verification URL (before finishing the registration step)
  2. Once you receive the URL, paste it on the browser’s search box, this request must return the Target URL you configured during the app registration. Example:

In the Console:

2020-06-22T00:42:36.865Z info: CONFIRMATION request for app XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX, to enable events visit https://api.smartthings.com/apps/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/confirm-registration?token=XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX

Browser response:

{ "targetUrl": "https://mywebhooksmartapp..." }
  1. In the Develop page (Developer Workspace), click on “Verify app registration” and after some seconds, it will detect that it is already verified.

Let me know if you have any doubts.

I totally agree with your idea.

I’m runnng ubuntu on my raspberry pi at home for managing RS485 connected IoT devices, but it is very annoying to keep it updated (all the security updates, etc…), or it would be hacked.

Also raspberry pi uses SD card for main storage, which is far from being a stable primary storage, so that I’m always worried about when this SD card will be broken.

What I like about groovy smartapp plus smartthings ide is that, I don’t have to be annoyed to maintain the service.

I undetstand that it is because of all the hard work from smartthings team, but as an end user, install-and-forget is a big advantage of using groovy smartapp for me.

So if there’s any way to run the new smartapp (nodejs or whatever it migt be) in the smartthings hub, then we customers don’t need to care about managing ports and securities of their own server. And this will also help to keep the smartthings platform secure.

Because smartthings hubs should already have secure connections to the smartthings platform server, it might be easier to implement than implementing with ngrok or such third party thing.

1 Like

@jody.albritton Hey thanks a lot for this new SDK. Tried it out and worked pretty well.

Just a question related to sharing my smartapp to other public users. Hosting it on Glitch (or my own server) is OK and straightforward to share with people who are quite have technical knowledge . But I’m wondering if is there any option for people who don’t want to go Developer Workspace to register the app, but instead can install my smartapp directly from their SmartThings app (or any other one-click solution)? I have successfully enrolled as a parted of SmartThings, but seem the option to publish my app to public users is still not ready yet.

1 Like