mirror of
https://github.com/skydiver/ewelink-api.git
synced 2025-12-27 07:31:41 +01:00
added demo script
This commit is contained in:
19
demo/example.js
Normal file
19
demo/example.js
Normal 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>');
|
||||
})();
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user