1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
const { login } = require("tplink-cloud-api"); const uuidV4 = require("uuid/v4"); const TPLINK_PASS = "adfsadfasdfsadf"; const TPLINK_TERM = "ddddd-sdfadf-adfsaf-asdfs-adsfsdf"; var express = require('express'); var bodyParser = require('body-parser'); var app = express(); async function main() { app.use(express.static('public')); app.use(bodyParser.json()); // log in to cloud, return a connected tplink object const tplink = await login(TPLINK_USER, TPLINK_PASS, TPLINK_TERM); // get a list of raw json objects (must be invoked before .get* works) const dl = await tplink.getDeviceList(); let myPlug = tplink.getHS100("porta"); app.get("/", function (request, response) { response.send(tplink.getToken()+"-------------"+myPlug.getDeviceId()); }); var listener = app.listen(process.env.PORT, function () { console.log('This app is listening on port ' + listener.address().port); }); } main(); |