This sample shows how to use the stateCallbacks for a SmartThings Schema Connector in order to:
- Update the device state
- Trigger the Integration deleted interaction type from the Third-Party cloud side.
- OAuth Server (See [1] and [2] in the references section).
- A Samsung Developer Workspace account.
- The SmartThings mobile app (available from the iOS App Store or Google Play Store).
- For local execution: Node JS and Ngrok to create the HTTPS tunnel.
Note: You can upload the code to other tools such as Glitch.
- Clone or download this repository.
- Install all the necessary modules using the command:
npm install
- Follow the instructions to register a Webhook Connector. (See the sample of the reference no.2)
- Create an .env file as shown in .env-example
- The PORT will depend on your preferences.
- The
ST_CLIENT_ID
andST_CLIENT_SECRET
are the values generated in the Developer Workspace after you register the Connector.
- Create a Device profile with the following capabilities:
- Switch
- Thermostat Mode
- Temperature Measurement
- Health Check
- Thermostat Cooling Setpoint
- Thermostat Heating Setpoint
- Replace "device-profile-id" by the generated ID at the 13th line of the
connector.js
file. - Run this project with the command
node .
- Open the ST mobile app (make sure you enabled theDeveloper mode)
- Select "add" (+) > "Device" > My testing devices > Select the Schema Connector
- Choose in which
location
androom
you want to install the device. - You'll be redirected to the login page of your OAuth Server (Authorization URI).
- It'll be send to the
Token URI
afterwards where the OAuth Server provides an Authentication Token. (it's very important for the callbacks) - 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.
- You should be able to call the stateCallbacks using the endpoints in
server.js
(/command
and/delete
)