{"id":18695366,"url":"https://github.com/smartthingscommunity/device-scene-example-nodejs","last_synced_at":"2025-08-26T06:32:50.707Z","repository":{"id":90221937,"uuid":"320328386","full_name":"SmartThingsCommunity/device-scene-example-nodejs","owner":"SmartThingsCommunity","description":"Example SmartApp that stores installed app context makes callback to the SmartThings platform","archived":false,"fork":false,"pushed_at":"2020-12-10T16:29:31.000Z","size":59,"stargazers_count":2,"open_issues_count":0,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-12T07:37:16.734Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SmartThingsCommunity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-10T16:28:47.000Z","updated_at":"2024-09-11T09:54:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"5bb5f55c-c7a5-4efc-afc2-b6498293b157","html_url":"https://github.com/SmartThingsCommunity/device-scene-example-nodejs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SmartThingsCommunity/device-scene-example-nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fdevice-scene-example-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fdevice-scene-example-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fdevice-scene-example-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fdevice-scene-example-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SmartThingsCommunity","download_url":"https://codeload.github.com/SmartThingsCommunity/device-scene-example-nodejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fdevice-scene-example-nodejs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272186212,"owners_count":24888333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T11:14:44.367Z","updated_at":"2025-08-26T06:32:50.699Z","avatar_url":"https://github.com/SmartThingsCommunity.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Device/Scene Controller Example\n\nThis SmartApp hosts a web page that allows the control of scenes, locks, and switches. \nIt's an example of how to:\n* Execute scenes\n* Execute device commands\n* Subscribe to device state change events by capability\n* Store the auth tokens and settings of installed app instances and use them when making calls to the\nSmartThings API that are not in response to SmartApp lifecycle events.\n\n## File Structure\n\n* lib/db.js \u0026mdash; module for listing installed app instances from the context store\n* lib/smartapp.js \u0026mdash; the SmartApp implementation\n* lib/sse.js \u0026mdash; Server-Sent Event object used to update the web page  \n* locales/en.json \u0026mdash; English version of the app configuration page text\n* public/images \u0026mdash; web image files\n* public/javascript \u0026mdash; web page JavaScript files\n* public/stylesheets \u0026mdash; web page css files\n* server.js \u0026mdash; the Express server that hosts the SmartApp as a web-hook\n* views/index.ejs \u0026mdash; the home page\n* views/isa.ejs \u0026mdash; the installed app instance control page\n\n## Prerequisites\n- A [Samsung Developer Workspace account](https://smartthings.developer.samsung.com/workspace/)\n\n- [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/) installed\n\n- [ngrok](https://ngrok.com/) or similar tool to create a secure tunnel to a publically available URL\n  \n## Getting Started\n\n### Clone this GitHub repository\n```bash\ngit clone https://github.com/SmartThingsCommunity/device-scene-example-nodejs.git\n```\n\n### Start the server\n```bash\ncd device-scene-example-nodejs\nnpm install\nnode server.js\n```\n\n### Start ngrok and point it to your server\n```\nngrok http localhost:3001\n```\nMake note of the HTTPS forwarding URL, for example `https://c79461932dfc.ngrok.io`\n\n### Create an automation in the developer workspace\n\nGo to the SmartThings developer workspace and create an Automation SmartApp. This app should have the scopes:\n```\nr:devices:*\nx:devices:*\nr:scenes:*\nx:scenes:*\n```\nChoose the web-hook option when creating the app. The _targetURI_ should be set to the ngrok forwarding\nURL, for example `https://c79461932dfc.ngrok.io`\n\nTake note of the `appId`, `clientId`, and `clientSecret` displayed after creating your app.\n\n### Confirm that your app is ready to receive lifecycle events\n\nLook in your server log for a line with a URL to use for verifying your app. Visit this URL to confirm\nthe location of your app (you can do this in a web browser).\n\n### Create a .env file and restart the server\n\nCreate a file named `.env` in the project directory that sets your `appId`, `clientId`, and `clientSecret`.\nFor example:\n```\nAPP_ID=912e0214-5706-4407-a299-b3796a57cf56\nCLIENT_ID=61225bef-d2db-4ab0-82f6-d28c0f11911d\nCLIENT_SECRET=94c2b3df-b0ab-4abd-84bf-1823d63b944c\n```\n\nand restart your NodeJS server. Do not restart ngrok or the URL will change (unless your are using a \npaid account)\n\n### Install your SmartApp and visit the web page\n\nInstall your SmartApp using the SmartThings mobile app. Then visit your local web server\nto see and control devices and scenes.\n\nhttp://localhost:3001\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartthingscommunity%2Fdevice-scene-example-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartthingscommunity%2Fdevice-scene-example-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartthingscommunity%2Fdevice-scene-example-nodejs/lists"}