This is a command-line interface for Kasa Smart Control – Smartplug/Smart bulb control for Windows, this is based on reverse engineering of the TP-Link protocol. It is still a work in progress, so please check back for updates.

This app allows batch scripts to control devices.


Command Line

NOTE: TPLinkCmd is an app alias, you do not need the full path as this changes on each update.

Logging On

The login command is only required once if you don’t want to include it in your script, this saves the Username and Password (encrypted) for further commands and to update the login token with TP-Link, so you can Win+R type:

TPLinkCmd -login -username "" -password "password" 

and that is it until you change your password, or the -logoff parameter clears them.

You can also add that line to the beginning of you script if you prefer.

Creating a script

Create a text file and name it your_script_name.bat (make sure show file extensions setting is on in Windows, otherwise you get your_script_name.bat.txt and this will not work), it should look like this:

Then add the commands you require to it, you only need the -login command if you didn’t login as above.

Example Script 1
TPLinkCmd -login -username "" -password "password"
TPLinkCmd -device "LAMP" -on
TPLinkCmd -device "LAMP" -brightness 20
TPLinkCmd -device "BEDROOM" -off
TPLinkCmd -logoff

Example Script 2

tplinkcmd -login -username "" -password "password"
echo Turning on PRINTER for 10 minutes
tplinkcmd -device "PRINTER" -on
tplinkcmd -device "PRINTER" -timer start -h 0 -m 10 -action 0
echo Printer will turn off in:
tplinkcmd -device "PRINTER" -timer status

TPLinkCmd -login -username "" -password "password"
Login: OK

TPLinkCmd -login
Password: *********

TPLinkCmd -device "89892347829348798724D8928934927482749879" -rename "LOUNGE"
TPLinkCmd -device "DOOR" -rename "LOUNGE"

It is safer to use the deviceid because TP-Link have allowed name duplicates 

TPLinkCmd -logoff
Logoff: Ok

This clears the cached Username, Password and Login Token

TPLinkCmd -devicelist

The -device parameter can use the deviceid or the name.

89892347829348798724D8928934927482749879 is a device id, if the device has child devices ie, a 3 plug powerstrip there will be 2 extra digits on each child 00, 01 and 02

TPLinkCmd -device "BEDROOM" -on
Relay: 1

TPLinkCmd -device "BEDROOM" -off
Relay: 0

TPLinkCmd -device "BEDROOM" -toggle
Relay: 1

TPLinkCmd -device "BEDROOM" -status
Relay: 0 or 1

TPLinkCmd -device "BEDROOM" -brightness  62
Relay: 1
Brightness: 62

use -off for 0

Supported Devices and Actions

Please let me know in the comments if there are missing working devices in this list, I cannot test all Kasa devices only the ones I own.


  • Relay On/Off/Toggle


  • Relay On/Off/Toggle

KP303 (3 Way Powerstrip)

  • Each socket Relay On/Off/Toggle


  • Relay On/Off/Toggle


  • Relay On/Off/Toggle
  • Brightness


Do not ask support questions in the comments, post a ticket here