This library provides a programmatic interface for controlling TP-Link Kasa smart home devices directly over the local network. It supports a wide range of devices including smart plugs (HS100, HS110, KP303), smart bulbs (LB100, KL125), and light strips (KL430), enabling local control without reliance on the TP-Link cloud services. The current stable version is 5.0.0, which targets Node.js environments version 16 and higher. While no explicit release cadence is documented, major version bumps suggest significant updates and potential breaking changes. A key differentiator is its focus on local LAN communication, offering increased privacy and potentially faster response times compared to cloud-dependent solutions. It ships with full TypeScript type definitions for an enhanced development experience, but importantly, does not support TP-Link Tapo devices.
npm install tplink-smarthome-apiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate the client, connect to a specific Kasa smart device by IP address, retrieve its system information, toggle its power state, and adjust brightness for bulbs. It also shows how to use the client's discovery feature to find devices on the local network and react to new devices coming online.
Upgrade your Node.js installation to version 16 or newer (e.g., using `nvm install 16` or higher).
Ensure your smart home devices are TP-Link Kasa models. For Tapo devices, alternative integration methods or libraries are required.
Consider disabling automatic firmware updates for critical Kasa devices. Monitor the library's GitHub repository for updates and community reports on breaking firmware changes.
Check your network firewall rules, ensure devices are on the same subnet/VLAN, and consider assigning static IP addresses to your Kasa devices for direct connection. Rebooting your router can sometimes resolve discovery issues.
Review the `CHANGELOG.md` for specific breaking changes and migration instructions when upgrading from previous major versions.
If using ES Modules (Node.js `--experimental-modules` or `"type": "module"` in `package.json`), use `import { Client } from 'tplink-smarthome-api';`. If using CommonJS, ensure you are using `const { Client } = require('tplink-smarthome-api');` and your `tsconfig.json` (if applicable) is set up for CJS output or `allowSyntheticDefaultImports: true`.Double-check the device IP address, ensure the device is powered on and connected to the network, verify your network settings allow UDP communication, and confirm it's a Kasa device, not Tapo.
This library cannot control Tapo devices. You will need to find a different library or integration solution specifically for TP-Link Tapo products.
Change your import statements from `const { Client } = require('tplink-smarthome-api');` to `import { Client } from 'tplink-smarthome-api';`. If you need to use `require` for other CJS modules, you might need to use a bundler or ensure your files are treated as CommonJS.No dependency data recorded yet.