added demo script

This commit is contained in:
Martín M
2019-06-26 21:28:34 -03:00
parent 11be3e0d58
commit 73c6caaa77
2 changed files with 20 additions and 1 deletions

19
demo/example.js Normal file
View File

@@ -0,0 +1,19 @@
const ewelink = require('../main');
(async () => {
const conn = new ewelink({
email: '<your ewelink email>',
password: '<your ewelink password>',
});
/* get all devices */
const devices = await conn.getDevices();
console.log(devices);
/* get specific devide info */
const device = await conn.getDevice('<your device id>');
console.log(device);
/* toggle device */
await conn.toggleDevice('<your device id>');
})();

View File

@@ -4,7 +4,7 @@
"description": "eWeLink API for Node.js",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"demo": "node ./demo/example.js"
},
"author": "Martín M.",
"license": "MIT",