jayhjha / smartthings-node Goto Github PK
View Code? Open in Web Editor NEWNode.js Client for Samsung SmartThings API
License: MIT License
Node.js Client for Samsung SmartThings API
License: MIT License
Node version: v10.9.0
I used the CommonJS version:
var smartthings = require('smartthings-node');
var st = new smartthings("MY-PERSONAL-ACCESS-TOKEN");
st.devices.listDevicesByCapability('switch')
.then(deviceList => {
console.log(deviceList);
});
The full error message:
TypeError: smartthings is not a constructor
at Object.<anonymous> (/MY-APP-DIR/app.js:52:10)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:266:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
pi@retropie:~/git/Bticino_smartthings $ npm install smartthings-node
npm WARN deprecated [email protected]: request has been deprecated, see https://git hub.com/request/request/issues/3142
npm ERR! Error: Method Not Allowed
npm ERR! at errorResponse (/usr/share/npm/lib/cache/add-named.js:260:10)
npm ERR! at /usr/share/npm/lib/cache/add-named.js:120:12
npm ERR! at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.j s:167:7)
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this entire log,
npm ERR! including the npm and node versions, at:
npm ERR! http://github.com/npm/npm/issues
npm ERR! System Linux 4.9.35-v7+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "smartthings-node"
npm ERR! cwd /home/pi/git/Bticino_smartthings
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code E405
npm WARN deprecated [email protected]: request-promise has been deprecated b ecause it extends the now deprecated request package, see https://github.com/req uest/request/issues/3142
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/git/Bticino_smartthings/npm-debug.log
npm ERR! not ok code 0
.
According to my initial check, some apis don't suppport apptoken as a parameter.
listDevicesByDeviceId(deviceId) { //<= no token parameter
let queryParams = { deviceId: deviceId };
return this.listDevices(queryParams);
}
listDevices(queryParams, smartAppToken) { //<= has token parameter, but it can not be used by listDeviceByDeviceid
let authToken = this.getAuthToken(smartAppToken);
return requestbuilder_1.default(authToken, 'devices', 'GET', queryParams);
}
Do you have an example of how to install a device remotely using this api?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.