Node.js Client for Samsung SmartThings API
//ES6
import { SmartThings } from "smartthings-node";
let st = new SmartThings("PERSONAL_ACCESS_TOKEN"));
//CommonJS
const smartthings = require("smartthings-node");
let st = new smartthings("PERSONAL_ACCESS_TOKEN");
This module is available through npm and requires version > 7.x
$ npm install smartthings-node
Install the smartthings-node module
$ npm install smartthings-node
Import the module
If you are using Typescript or ES6 with it's import syntax:
import { SmartThings } from "smartthings-node";
let st = new SmartThings("PERSONAL_ACCESS_TOKEN"));
If you are using the CommonJS syntax:
const smartthings = require("smartthings-node");
let st = new smartthings.SmartThings("PERSONAL_ACCESS_TOKEN");
Use a sub-module. For example, to get a list of devices with switch capability:
st.devices.listDevicesByCapability('switch')
.then(deviceList => {
console.log(deviceList);
})
An example on how to create Automation SmartApp to control a light bulb using based on current weather can be found at: https://github.com/hijha/smartthings-node/tree/master/examples/weather-controlled-light