My first SmartApp in AWS lambda

I’ve developed in the classic environment and I’m considering the switch to AWS lambda. Anyone have a good link walking me thru my first smartapp in AWS lambda?

I find the following (as well as AWS lambda videos), but none are as clear as the classic first-smartapp documentation listed in the second link.

https://smartthings.developer.samsung.com/docs/smartapps/smartapp-basics.html

https://docs.smartthings.com/en/latest/getting-started/first-smartapp.html

Hi @radon

Please, check this example:

Also, I’d recommend you to check the Cloud-to-Cloud example code, so you can get an idea of how it works with st-schema interactions:

Have fun!
Erick.

1 Like

Erick,

Thanks for the response! Looking at the ReadMe file and code gives me a feel for things. The Prerequisite links in the ReadMe file are a good start on things to setup and learn.

Q: The Prereq utilizes the AWS cmd line. What is your take on the AWS Cloud9 IDE? https://aws.amazon.com/cloud9/

Before I start my AWS endeavor, I’d like to ask the community what their experience has been with making the switch. What guidance can you give?

In full disclosure, I’ve been busy with modifications to my groovy code and have not taken time to pursue AWS yet. I’m looking for any additional tips that might make the transition go as smooth as possible.

Reference: https://smartthings.developer.samsung.com/docs/smartapps/smartapp-basics.html

In addition to the ReadMe-Prereqs in Erick’s link, the Developer Flow found in the above reference is useful, but I’m anticipating there is much more to learn. I’m hoping community experience may enlighten me with what they found difficult or useful.

I’m thinking I may want to start with the following and open to suggestions.

  1. Create an AWS account.

  2. Create, edit, run Hello World in AWS. (Pure AWS, to test/understand AWS concepts.)

  3. CRUD (create/read/update/delete) persistent data in AWS. (We use this instead of the Classic “state” & “atomicState” - Correct?!?)

  4. Connect AWS to SmartThings.

  5. My first AWS SmartApp “Hello World” (I’m still a bit fuzzy on how this is done; I assume my code dynamically generates the JSON that is sent.) https://smartthings.developer.samsung.com/docs/tutorials/how-to/design-pages-smartapp.html

  6. My first event. (i.e. write code to generate and send JSON to SmartThings to subscribe to events; and then write code to process the events.)

My motivation for making the switch to AWS is that I assume I’ll no longer be constrained by the flaws of the Classic platform. AWS has true support for concurrency (e.g. locks, atomic operations, sync blocks; bye-bye to state & atomicState). We can schedule AWS threads down to milliseconds if so desired (and no Overwrite issues). We no longer have the Live Logging issues (e.g. dropped output, out of order output, mixed output). We are not constrained by Groovy With SmartThings.

https://docs.smartthings.com/en/latest/getting-started/groovy-for-smartthings.html

Are there any other Pros would you’d like to point out? And more importantly, what Cons should I be aware of?

I am a little worried that it will be more difficult to jump start friends & family. With classic we simply created an account and added devices and apps. Will they now need AWS?!?

1 Like

Hi, @radon

Using the aws cli with SmartThings is quite simple, especially with aws profiles and regions SmartThings needs to access functions.

Another cool thing using AWS instead WebHooks is that I don’t have to worry about running the app and register it every time at the Developer Workspace for testing or debugging it.

I see the last response was in November '19. I am more familiar with javascript than I am Groovy, so, I am going to begin looking at AWS Lambda. As someone mentioned above, it appears to be straight forward. I would say one of the main differences is it will be more private than say an environment like Smartthings IDE. Not sure how it will be for a “public” integration environment.

1 Like

Does anyone have any advice on using the AWS API Gateway, or exposing the Lambda for direct access (against AWS preferences)?

This is the only thread I could find about developing an AWS Lambda smartapp. I am trying to do this but having trouble getting AWS to recognize the @smartthings/smartapp library reference in the require statement used in the examples. The rest of it is cumbersome but understandable. I have the CLI configured, and I have my Lambda function written. It just won’t run because the import doesn’t work. Do I have to put the API in my AWS account?

1 Like

Hi, @kewashi

As a workaround, I suggest you to zip your lambda SmartApp along with the node_modules. This will allow your SmartApp to reach the @smartthings/smartapp dependency. Also, you could use the ClaudiaJS deployment framework that will help you to wrap an express instance and be able to debug your SmartApp locally before deploying it at AWS.

I hope this information results useful to you.

1 Like

Thanks man… Claudia look very powerful. Will try it out

1 Like