JS Library for connecting/controlling Tapo Smartplugs, Light Bulbs etc.
npm install tapo-smartplug-controlts
const tapo = require('tapo-smartplug-control');
const cloudToken = await cloudLogin(email, password);
const devices = await listDevicesByType(cloudToken, 'SMART.TAPOPLUG');
`
Once you know what device to use, do this:
`ts
const deviceToken = await loginDeviceByIp(email, password, ip);
// or
const deviceToken = await loginWithDevice(email, password, devices[0]);
const deviceInfoResponse = await getDeviceInfo(deviceToken);
console.log(deviceInfoResponse);
`
Device State
To change the state of your device, e.g turn it off or on you can do this:
`ts
await tapo.on(deviceToken); // turn on
await tapo.off(deviceToken); // turn off
`
Load videos from tapo-care cloud
`ts
const cloudVideos = await tapoCareCloudVideos(cloudToken, deviceId); //deviceId from listDevicesByType
``