{"id":18695350,"url":"https://github.com/smartthingscommunity/st-schema-simple-example-js","last_synced_at":"2026-02-24T21:34:45.944Z","repository":{"id":40730290,"uuid":"194862735","full_name":"SmartThingsCommunity/st-schema-simple-example-js","owner":"SmartThingsCommunity","description":"Very simple ST-Schema connector that creates one device ","archived":false,"fork":false,"pushed_at":"2022-12-11T17:50:41.000Z","size":69,"stargazers_count":2,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T07:37:15.960Z","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":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-02T12:53:45.000Z","updated_at":"2023-09-11T13:09:40.000Z","dependencies_parsed_at":"2023-01-27T04:05:18.613Z","dependency_job_id":null,"html_url":"https://github.com/SmartThingsCommunity/st-schema-simple-example-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SmartThingsCommunity/st-schema-simple-example-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fst-schema-simple-example-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fst-schema-simple-example-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fst-schema-simple-example-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fst-schema-simple-example-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SmartThingsCommunity","download_url":"https://codeload.github.com/SmartThingsCommunity/st-schema-simple-example-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartThingsCommunity%2Fst-schema-simple-example-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29801036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T21:02:39.706Z","status":"ssl_error","status_checked_at":"2026-02-24T21:02:21.834Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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:40.977Z","updated_at":"2026-02-24T21:34:45.927Z","avatar_url":"https://github.com/SmartThingsCommunity.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ST Schema Simple Example\n\nThis application is about the simplest possible implementation of an ST Schema\ncloud-to-cloud device integration. It's built using the\n[ST Schema SDK for NodeJs](https://github.com/SmartThingsCommunity/st-schema-nodejs). This example creates a single simulated dimmer device\nnamed _Test Dimmer_. The state of the dimmer is saved in memory to keep the\nimplementation as simple as possible, so restarting the server will reset it's\nswitch status to 'off' and switch dimmer level to 100%.\n\nNote that ST Schema requires your cloud application to support [OAuth 2](https://oauth.net/2/) for authentication.\nThis example does not include an OAuth server, but it does include instructions for\nremixing a [Glitch dummy OAuth server](https://glitch.com/~st-dummy-oauth-server) to handle that part of the login process\n\n## Files\n\n- connector.js -- The ST Schema connector app built with the [st-schema](https://www.npmjs.com/package/st-schema) SDK\n- index.js -- An [AWS Lambda](https://aws.amazon.com/lambda/) handler that hosts the connector.\n- server.js -- An [express](https://www.npmjs.com/package/express) web server that hosts the connector\n\n## Getting Started\n\n### Running locally\n\n#### Prerequisites\n\n- [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/) installed\n- [ngrok](https://ngrok.com/) or similar tool to create a secure tunnel to a publically available URL\n- A [Samsung Developer Workspace account](https://smartthings.developer.samsung.com/workspace/)\n- The SmartThings mobile app (available from the [iOS App Store](https://apps.apple.com/us/app/smartthings/id1222822904)\nor [Google Play Store](https://play.google.com/store/apps/details?id=com.samsung.android.oneconnect))\n\n#### Instructions\n\n1. Clone [this project](https://github.com/SmartThingsCommunity/st-schema-simple-example-js)\n\n1. CD into the project directory and run `npm install`\n\n1. Copy `.env-sample` into a file named `.env` and change the `ACCESS_TOKEN_PREFIX` value some other string so that only\nyou can access your server. \n\n1. Start the server with `node server.js`\n\n1. Start ngrok to tunnel traffic to your server URL and port (`localhost:3000`).\n\n1. Register the webhook url in SmartThings Developer Workspace and deploy it for testing.\n\n1. Install the SmartThings mobile app from the [iOS App Store](https://apps.apple.com/us/app/smartthings/id1222822904)\nor [Google Play Store](https://play.google.com/store/apps/details?id=com.samsung.android.oneconnect),\nlog in with the same email address and password used for your developer workspace account, and \ncreate a location (if you have not already done so)\n\n1. Put the SmartThings mobile app in [developer mode](https://smartthings.developer.samsung.com/docs/guides/testing/developer-mode.html) and tap the \"+\" button at the top to\nadd a device. Scroll down to _My Testing Devices_ tap on it, and select your connector. Complete\nthe OAuth login process and return to the Devices page. You should be prompted to assign\na device named _Test Dimmer_ to a room. \n\n### Running in Glitch\n\n#### Prerequisites\n\n- A [Glitch](https://glitch.com/about/) account\n- A [Samsung Developer Workspace account](https://smartthings.developer.samsung.com/workspace/)\n- The SmartThings mobile app (available from the [iOS App Store](https://apps.apple.com/us/app/smartthings/id1222822904)\nor [Google Play Store](https://play.google.com/store/apps/details?id=com.samsung.android.oneconnect))\n\n#### Instructions\n\n1. Remix the [st-schema-simple-example](https://glitch.com/~st-schema-simple-example-js) project.\n\n1. Set the values in the `.env` file using `.env-example` as a guide. \n\n1. Once the remixed app is up and running copy its URL.\n\n1. Register the webhook url in SmartThings Developer Workspace and deploy it for testing.\n\n1. Install the SmartThings mobile app from the [iOS App Store](https://apps.apple.com/us/app/smartthings/id1222822904)\nor [Google Play Store](https://play.google.com/store/apps/details?id=com.samsung.android.oneconnect),\nlog in with the same email address and password used for your developer workspace account, and \ncreate a location (if you have not already done so)\n\n1. Put the SmartThings mobile app in [developer mode](https://smartthings.developer.samsung.com/docs/guides/testing/developer-mode.html) and tap the \"+\" button at the top to\nadd a device. Scroll down to _My Testing Devices_ tap on it, and select your connector. Complete\nthe OAuth login process and return to the Devices page. You should be prompted to assign\na device named _Test Dimmer_ to a room. \n\n### Running in AWS Lambda\n\n#### Prerequisites\n\n- An [AWS account](https://aws.amazon.com) with the [AWS cli](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) \ninstalled on your computer.\n- A [Samsung Developer Workspace account](https://smartthings.developer.samsung.com/workspace/)\n- The SmartThings mobile app (available from the [iOS App Store](https://apps.apple.com/us/app/smartthings/id1222822904)\nor [Google Play Store](https://play.google.com/store/apps/details?id=com.samsung.android.oneconnect))\n\n#### Instructions\n\n1. Clone [this project](https://github.com/SmartThingsCommunity/st-schema-simple-example-js)\n\n1. CD into the project directory and run `npm install`\n\n1. Zip the contents of the project directory and upload it to [create a Lambda function](https://console.aws.amazon.com/lambda/home?region=us-east-1#/create) \nusing the _Node.js 10x` runtime named `simple-st-schema` (or anything you want, just \nsubstitue that name into the statement in the next step)\n\n1. Using the [AWS cli](https://docs.aws.amazon.com/cli/latest/userguide/installing.html)\ngrant permission for SmartThings to call your Lambda by running the command:\n```\n  aws lambda add-permission --profile default \\\n      --function-name simple-st-schema --statement-id smartthings \\ \n      --principal 148790070172 --action lambda:InvokeFunction\n```\n\n1. Register the Lambda ARN in the SmartThings Developer Workspace and deploy it for testing.\n\n1. Install the SmartThings mobile app from the [iOS App Store](https://apps.apple.com/us/app/smartthings/id1222822904)\nor [Google Play Store](https://play.google.com/store/apps/details?id=com.samsung.android.oneconnect),\nlog in with the same email address and password used for your developer workspace account, and \ncreate a location (if you have not already done so)\n\n1. Put the SmartThings mobile app in [developer mode](https://smartthings.developer.samsung.com/docs/guides/testing/developer-mode.html) and tap the \"+\" button at the top to\nadd a device. Scroll down to _My Testing Devices_ tap on it, and select your connector. Complete\nthe OAuth login process and return to the Devices page. You should be prompted to assign\na device named _Test Dimmer_ to a room. \n\n## Configuring the Dummy OAuth Server\n\nST Schema connectors require an OAuth2 connection journey. Since this example \napp does not include OAuth support you must use some other server to complete\nthat journey. It can be any server supporting OAuth2 as long as it is configured\nwith the same client ID and client secret as the ST Schema connector you registered\nin the Developer Workspace. For convenience we've provided a dummy OAuth server\nthat accepts any username and password and can be configured with your client ID and\nsecret.\n\n1. Remix the [st-dummy-oauth-server](https://glitch.com/~st-dummy-oauth-server) project\n\n2. Edit the `.env` file to set your own client ID and secret, for example:\n```\n  EXPECTED_CLIENT_ID=\"somerandomvalueyouchoose\"\n  EXPECTED_CLIENT_SECRET=\"anotherrandomvalueyouchoose\"\n  AUTH_REQUEST_PATH=\"/oauth/login\"\n  ACCESS_TOKEN_REQUEST_PATH=\"/oauth/token\"\n```\n\n## Testing the device\n\nTap the _Test Dimmer_ device icon in the main devices view and it should turn on and off. You should see ST Schema requests\nand responses logged to the console. Remove the `.enableEventLogging(2)` line from `connector.js` to stop these\nmessages. Go into the detail view of the device to see the brightness control. Sliding this control will also \nresult in calls to your connector and messages logged to the console.\n\n## Did that, what's next?\n\nCheck out the [ST Schema Callback Example](https://github.com/SmartThingsCommunity/st-schema-callback-example-js)\nto see how to add proactive statecallbacks to your connector.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartthingscommunity%2Fst-schema-simple-example-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartthingscommunity%2Fst-schema-simple-example-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartthingscommunity%2Fst-schema-simple-example-js/lists"}