• EnglishSpanishGermanFrenchPolishChinese (Traditional)


EnglishSpanishGermanFrenchPolishChinese (Traditional)

Operating systems, scripting, PowerShell and security

Operating systems, software development, scripting, PowerShell tips, network and security

Menú principal
  • Categorías
  • Cursos
  • Libro de PowerShell
  • Lo mejor
  • Lo último
  • Proyectos
  • Contactar
Ir al contenido

Obtener el token y el deviceId del enchufe Inteligente TP-Link Wi-Fi HS100 desde Node.JS y mostrarlo en PowerShell

Obtener el token y el deviceId mediante el siguiente código en Node.JS:

PowerShell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const { login } = require("tplink-cloud-api");
const uuidV4 = require("uuid/v4");
 
const TPLINK_USER = "[email protected]";
const TPLINK_PASS = "aaaaa234aaaaaa";
const TPLINK_TERM = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa";
 
async function main() {
// 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");
 
console.log("token,deviceID");
console.log(tplink.getToken()+","+myPlug.getDeviceId());
}
 
main();

Mostrar la información obtenida desde el código anterior en PowerShell con el siguiente código:

PowerShell
1
2
3
4
5
6
7
8
$var = node .\nodepower.js
$data = $var | ConvertFrom-Csv
 
$data.token
$data.deviceID
 
$data | Out-GridView
Publicado el día 17 de abril de 2020

CATEGORÍAS

JavaScript, Node.js, PowerShell

ETIQUETAS

Cloud, Código, Connected, ConvertFrom-Csv, data, DeviceID, Function, HS100, Jesús Niño, Jesús Niño Camazón, JSON, Log, Out-GridView, TP-Link, TP-Link Wi-Fi HS100

MÁS

  • Crear un sistema para ver rutinas de entrenamientos con información sobre el entrenamiento y dibujos (versión con Popovers) (utilizando jQuery, Bootstrap, JSON)
  • Explicación sobre el uso de funciones que están en DLL del sistema operativo (en PowerShell)
  • Cómo depurar scripts en ISE de Windows PowerShell
  • Apagar y encender la Bombilla Inteligente TP-Link Kasa Regulable KL110 desde PowerShell
  • 11. Gestión del Directorio Activo (nivel intermedio)
  • Obtener el token y el deviceId del enchufe Inteligente TP-Link Wi-Fi HS100 desde Node.JS y mostrarlos en una web con Express