npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

tplink-bulbs

v1.2.1

Published

TypeScript library to control TP-Link Tapo devices via cloud and local network.

Readme

tplink-bulbs

🚀 A modern TypeScript library to control TP-Link Tapo smart devices (like bulbs, plugs, cameras) via cloud API and local LAN.


📦 Installation

npm install tplink-bulbs

or if using from local project:

npm install

Please make sure to ping your lamp once. To do this, you should get all your registered deviced and look for the IP address:

import * as TPLink from 'tplink-bulbs';

const email = '[email protected]';
const password = 'your-password';

async function run() {
  const cloudApi = await TPLink.API.cloudLogin(email, password);
    
  const devices = await cloudApi.listDevicesByType('SMART.TAPOBULB');
  console.log(devices);
}

run().catch(console.error);

Afterwards, ping the lamp. You can do this with tools like curl.

🚀 Quickstart Example

import * as TPLink from 'tplink-bulbs';

const email = '[email protected]';
const password = 'your-password';
const deviceId = 'your-device-id'; // Instead of working with the device ID, you can also use the device IP. 

async function run() {
  const cloudApi = await TPLink.API.cloudLogin(email, password);
    
  const devices = await cloudApi.listDevicesByType('SMART.TAPOBULB');
  console.log(devices);
  const targetDevice = devices.find(device => device.deviceId === deviceId);

  if (!targetDevice) {
    console.error(`Device with ID "${deviceId}" not found.`);
    return;
  }

  const device = await TPLink.API.loginDevice(email, password, targetDevice);
  // If you already know the devices IP address, please use this:
  // const device = await TPLink.API.loginDeviceByIp(email, password, deviceIp);

  const info = await device.getDeviceInfo();
  console.log('Device Info:', info);

  await device.turnOn();
  await device.setColor('violet');
  await TPLink.API.delay(500);

  await device.setColor('red');
  await TPLink.API.delay(500);

  await device.setColor('orange');
  await TPLink.API.delay(500);

  // colours can also be set using hex codes
  await device.setColor('#00ff00');
  await TPLink.API.delay(500);

  // or by providing an RGB object
  await device.setColor({ r: 0, g: 0, b: 255 });
  await TPLink.API.delay(500);

  // you can change only the brightness (or hue/saturation)
  await device.setBrightness(50);
  await TPLink.API.delay(500);

  //...
}

run().catch(console.error);

Note: loginDevice resolves the device's IP address via your local network. Ensure the machine running this code is connected to the same network as the Tapo device. If you already know the IP address or ARP discovery fails, call loginDeviceByIp(email, password, deviceIp) instead.


💡 Features

  • Cloud login
  • List devices from TP-Link Cloud
  • Set color by name, hex, temperature and now also by HSL, HSV, CMYK or RGB
  • A lot of color presets included
  • Full TypeScript strict typing
  • Easy to use

🌈 Available Color Presets

blue, red, yellow, green, cyan, magenta, orange, pink, turquoise, violet, lavender, coral, mint, teal, navy, olive, maroon, grey, white, daylightwhite, warmwhite

(And you can set any hex color like #ff0000 too!)


📄 License

ISC License

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Credits

Credits go to:

  • https://github.com/dickydoouk/tp-link-tapo-connect
  • https://github.com/fishbigger/TapoP100
  • https://github.com/K4CZP3R/tapo-p100-java-poc
  • https://gist.github.com/chriswheeldon/3b17d974db3817613c69191c0480fe55