
This assumes you've already configured the aws-sdk package to interact with your Lambda, so extending your context store to DynamoDB is a drop-in solution. If you are hosting your SmartApp as an AWS Lambda, this DynamoDB context store makes perfect sense. Amazon AWS DynamoDBĪvailable as a node package on NPM or fork on GitHub. To get started with our context store example below, we will add a compatible ContextStore plugin that will persist these tokens (among other things) to a database. If you'd like to add a custom context store plugin, please consider contributing. Note that there is no in-memory context store you must use a context store plugin.

This token includes a refresh_token, and will automatically be refreshed by the SDK when necessary.
SMARTTHINGS CT100 SMARTAPP INSTALL
If you are making out-of-band API calls on behalf of a user's installed app, you will need to use the 24-hour access token that is supplied after the INSTALL and UPDATE lifecycles. These access tokens are not able to be refreshed and should not be stored. These user tokens are ephemeral and last 5 minutes. Making API Calls Outside of an EVENT Handlerīy default, the SmartApp SDK will facilitate API calls on behalf of a user within the EVENT lifecycle. page( 'mainPage', ( context, page, configData) => ) on the SmartApp object. enableEventLogging( 2) // logs all lifecycle event requests and responses as pretty-printed JSON. * Define the SmartApp */ const smartapp = new SmartApp() To run your SmartApp with an HTTP server, such as Express.js: const SmartApp = require( express = require( 'express') When all services and Device features involved in a Rule are local, Rules execute locally on a Hub, allowing you to benefit from greater speed, stability, and security than cloud-reliant solutions. It is given here as a brief showcase of the SDK, and is not meant to be a good candidate for a SmartApp.īefore hosting your own Automation, be sure to check out Rules. The example SmartApp below is the equivalent of a simple Rule (if contact sensor opens/closes, turn lights on/off) which is easily achieved via our Rules API. Node.js: const SmartApp = require( ES2015+: import SmartApp from Examples To learn more about SmartApps, including choosing the best hosting solution for your SmartApp, visit the SmartApp developer documentation. Webhook SmartApps are any publicly-accessible web server that will receive a POST request payload.ĪWS Lambda SmartApps are hosted in the Amazon Web Services cloud and are invoked by ARN instead of a public-DNS address. There are two distinct options for hosting your SmartApp: AWS Lambda and Webhook. Creating a SmartApp allows you to control and get status notifications from SmartThings devices using the SmartThings API. Your application will respond to lifecycle events sent from SmartThings to perform actions on behalf of your users and will execute any scheduled tasks that you have created in the SmartApp. The complexity of execution and the number of expected users will need to be examined to understand the hardware or execution requirements your app needs to handle. All of the SmartApp execution will happen on the server or Lambda that you control. SmartApps are custom applications that execute outside of the SmartThings Platform. ✅ Firebase Cloud Firestore plugin ( usage).✅ Context Store plugins – easily scale access token management (and more) to support many users.✅ Winston framework manges log messages.✅ Integrated i18n framework provides configuration page localization.✅ Configuration page API simplifies page definition.✅ Event handler framework dispatches lifecycle events to named event handlers.✅ Javascript API hides details of REST calls and authentication.This SDK includes a set of Node.js libraries for building Webhook and AWS Lambda SmartApps, and interacting with the public SmartThings API. See the Version 2.0.0 release notes for more information. Axios is now used rather than request-promise-native for making HTTP calls, resulting in changes to the error.Methods that return lists now return arrays instead of objects with the properties items and _links.The major non-backwards compatible changes include: This major release is not fully backwards compatible with version 1.X, though for most SmartApps the changes required should be relatively minor. For a detailed look at the API, check out the reference documentation.
