Giter VIP home page Giter VIP logo

st-schema-devstatecallback's Introduction

st-schema-devstatecallback

This sample shows how to use the stateCallbacks for a SmartThings Schema Connector in order to:

  1. Update the device state
  2. Trigger the Integration deleted interaction type from the Third-Party cloud side.

Pre-requisites

  1. OAuth Server (See [1] and [2] in the references section).
  2. A Samsung Developer Workspace account.
  3. The SmartThings mobile app (available from the iOS App Store or Google Play Store).
  4. For local execution: Node JS and Ngrok to create the HTTPS tunnel.

Note: You can upload the code to other tools such as Glitch.

Connector Setup

  1. Clone or download this repository.
  2. Install all the necessary modules using the command: npm install
  3. Follow the instructions to register a Webhook Connector. (See the sample of the reference no.2)
  4. Create an .env file as shown in .env-example
  • The PORT will depend on your preferences.
  • The ST_CLIENT_ID and ST_CLIENT_SECRET are the values generated in the Developer Workspace after you register the Connector.
  1. Create a Device profile with the following capabilities:
  • Switch
  • Thermostat Mode
  • Temperature Measurement
  • Health Check
  • Thermostat Cooling Setpoint
  • Thermostat Heating Setpoint
  1. Replace "device-profile-id" by the generated ID at the 13th line of the connector.js file.
  2. Run this project with the command node .

Install Device

  1. Open the ST mobile app (make sure you enabled theDeveloper mode)
  2. Select "add" (+) > "Device" > My testing devices > Select the Schema Connector
  3. Choose in which location and room you want to install the device.
  4. You'll be redirected to the login page of your OAuth Server (Authorization URI).
  5. It'll be send to the Token URI afterwards where the OAuth Server provides an Authentication Token. (it's very important for the callbacks)
  6. If everything is correct, you should be able to see a "Success" message, there wouldn't be any interaction result in the logs and the device should be added in the corresponding location.
  7. You should be able to call the stateCallbacks using the endpoints in server.js (/command and /delete)

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.