Skip to content

CLI for TP-Link Cloud API - control Kasa smart home devices

License

Notifications You must be signed in to change notification settings

piekstra/tplink-cloud-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tplc - TP-Link Cloud CLI

A cross-platform CLI for controlling TP-Link Kasa and Tapo smart home devices via the cloud API. Built in Rust for speed and portability.

Installation

Homebrew (macOS / Linux)

brew install piekstra/tap/tplc

Pre-built binaries

Download the latest release for your platform from GitHub Releases.

From source

cargo install --git https://github.com/piekstra/tplink-cloud-cli

Quick start

# Authenticate (interactive prompt with MFA support)
tplc login

# List all devices
tplc devices list

# Turn a device on/off
tplc power on "Living Room Lamp"
tplc power toggle "Porch Light"

# Check power status
tplc power status "Living Room Lamp"

Commands

Authentication

tplc login              # Interactive login (supports MFA)
tplc logout             # Clear stored credentials
tplc status             # Check authentication status

Credentials can also be provided via environment variables:

  • TPLC_USERNAME - TP-Link account email
  • TPLC_PASSWORD - Account password

Login authenticates with both Kasa and Tapo clouds simultaneously (same TP-Link credentials). Tokens are stored securely in your OS keychain (macOS Keychain, Windows Credential Manager, Linux Secret Service).

Devices

tplc devices list                   # List all devices
tplc devices get "Device Name"      # Get device details
tplc devices search "lamp"          # Search by partial name

Power control

tplc power on "Device Name"         # Turn on
tplc power off "Device Name"        # Turn off
tplc power toggle "Device Name"     # Toggle state
tplc power status "Device Name"     # Check on/off

Energy monitoring

For devices with energy monitoring (HS110, KP115, KP125, P110, HS300 outlets):

tplc energy realtime "Device Name"              # Current power draw
tplc energy daily "Device Name"                 # Daily stats (current month)
tplc energy daily "Device Name" --year 2026 --month 1
tplc energy monthly "Device Name"               # Monthly stats (current year)
tplc energy summary                             # All emeter devices

Light strip controls

For light devices (KL430, KL420L5, L530):

tplc light brightness "Strip" 75                        # Set brightness (0-100)
tplc light color "Strip" --hue 240 --saturation 100     # Set color
tplc light temp "Strip" 4000                            # Color temperature (2500-9000K)
tplc light state "Strip"                                # Get current state

Schedules

tplc schedule list "Device Name"
tplc schedule add "Device Name" --action on --time 07:00 --days mon,tue,wed,thu,fri
tplc schedule add "Device Name" --action off --sunset
tplc schedule edit "Device Name" RULE_ID --disable
tplc schedule delete "Device Name" RULE_ID
tplc schedule clear "Device Name"               # Delete all rules

Device info

tplc info sysinfo "Device Name"     # System information
tplc info network "Device Name"     # WiFi info (SSID, signal)
tplc info time "Device Name"        # Device clock
tplc led on "Device Name"           # Turn indicator LED on
tplc led off "Device Name"          # Turn indicator LED off

Output format

Default output is JSON (machine-readable). Add --table or -t for human-readable tables:

tplc devices list -t
╭──────────────────┬────────┬────────┬───────┬────────┬────────┬───────────────╮
│ NAME             │ MODEL  │ TYPE   │ CLOUD │ STATUS │ EMETER │ DEVICE ID     │
├──────────────────┼────────┼────────┼───────┼────────┼────────┼───────────────┤
│ Living Room Lamp │ KP115  │ plug   │ kasa  │ online │ yes    │ 80067B24...   │
│ Porch Light      │ HS200  │ switch │ kasa  │ online │ no     │ A3F19C02...   │
│ Smart Plug Mini  │ P100   │ plug   │ tapo  │ online │ no     │ C2E8A901...   │
╰──────────────────┴────────┴────────┴───────┴────────┴────────┴───────────────╯

Errors are output as JSON to stderr with appropriate exit codes:

Exit code Meaning
0 Success
1 General error
2 Authentication error
3 Device not found
4 Device offline

Device resolution

Devices can be referenced by:

  1. Exact alias (case-sensitive)
  2. Device ID
  3. Case-insensitive alias match
  4. Partial alias match (if unambiguous)

Multi-outlet devices (HS300, KP303, KP400, etc.) expose each outlet as a separate device addressable by its alias. Devices from both Kasa and Tapo clouds are searched automatically.

Supported devices

Kasa devices

Model Type Energy monitoring
HS100, HS103, HS105 Smart Plug
HS110 Smart Plug Yes
HS200 Smart Switch
HS300 Smart Power Strip (6 outlets) Yes (per outlet)
KP115, KP125 Smart Plug Yes
KP200, KP400 Outdoor Plug (2 outlets)
KP303 Smart Power Strip (3 outlets)
EP40 Outdoor Plug
KL420L5, KL430 Smart Light Strip

Tapo devices

Model Type Energy monitoring
P100 Mini Smart Wi-Fi Plug
P110 Mini Smart Wi-Fi Plug Yes
L530 Smart Wi-Fi Light Bulb

Claude Code usage

tplc is designed to be used by AI agents. All commands output structured JSON by default (errors go to stderr), so agents can parse results directly. See CLAUDE.md for skill/plugin integration guidance.

Related

License

GPL-3.0 - see LICENSE for details.

About

CLI for TP-Link Cloud API - control Kasa smart home devices

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published