Automating TP-Link Kasa Devices with Shortcuts
One of the things I love about Shortcuts is how it can act as a bridge between apps and services that don’t officially support Apple’s automation ecosystem. A perfect example of this is TP-Link’s Kasa line of smart plugs, switches, and bulbs. Kasa devices don’t natively integrate with Shortcuts–but with a little API trickery, you can bring them right into your automations.
Over the past week, I’ve been experimenting with three public Shortcuts that unlock the Kasa cloud API:
Get Kasa API Token
Get Kasa Device Details
Turn On/Off Kasa Device
Together, they form a powerful workflow that lets you log in to your account, retrieve all of your devices, and control them–all without ever opening the Kasa app.
Step 1: Authenticating with the Kasa Cloud
Everything starts with the Get Kasa API Token Shortcut. This Shortcut asks for the email and password tied to your Kasa account, along with a UUID (a unique identifier that mimics the Kasa app itself). With these values, the Shortcut sends a login request to the Kasa cloud endpoint:
https://wap.tplinkcloud.com/
The response includes a temporary API token–your golden ticket for making further requests. Without it, nothing else works. Tokens do expire occasionally (usually after an app update), but re-running the Shortcut instantly refreshes your access.
Step 2: Retrieving Your Devices
Once you have a token, the next step is to get a list of devices tied to your account. That’s where Get Kasa Device Details comes in.
This Shortcut takes your token and sends a getDeviceList request. The response is a JSON dictionary containing all of your Kasa devices–each with a friendly name (alias), a deviceId, and an appServerUrl (the regional server that manages the device).
The Shortcut loops through this dictionary, extracts the essentials, and combines them into a clean, human-readable list. Instead of parsing raw JSON, you get something like:
"Living Room Plug": {"Device ID": "8006XXXXXX", "App Server URL": "https://use1-wap.tplinkcloud.com"}
This is the crucial information you’ll need to actually control the device.
Step 3: Turning Devices On and Off
With the token, device ID, and server URL in hand, the final piece of the puzzle is Turn On/Off Kasa Device.
This Shortcut first prompts you for the values you retrieved in step two, then asks you to choose an action: On or Off. Internally, those options map to 1 and 0, which the API uses to change the relay state.
The Shortcut builds a JSON request that looks like this:
{
"method": "passthrough",
"params": {
"deviceId": "YOUR_DEVICE_ID",
"requestData": "{\"system\":{\"set_relay_state\":{\"state\":1}}}"
}
}
Send that request to the Kasa cloud, and–like magic–your smart plug or bulb responds instantly.
Why This Matters
Kasa devices are popular because they’re inexpensive, reliable, and don’t require a separate hub. But until now, integrating them with Shortcuts has meant relying on Homebridge, third-party apps, or clunky workarounds.
These three Shortcuts cut out the middleman. They give you direct control over your Kasa devices from within Shortcuts, meaning you can tie them into existing automations:
- Turn on a desk lamp when you start a Focus mode.
- Power cycle your router with a tap on the Home Screen.
- Shut off everything in the house with a single command to Siri.
Credit Where It’s Due
All of this is made possible thanks to the excellent research and documentation by Joshua Tz, who published the Kasa API details. His guide is available here and is an invaluable resource for anyone who wants to go deeper into the API beyond what Shortcuts can do.
Future Improvements
Right now, the workflow involves some copy-paste steps–retrieving the token in one Shortcut, then pasting it into another. With a bit of refinement, the whole process could be chained into a single Shortcut: log in, fetch devices, pick one, and toggle it–all in one go. That’s the kind of polish that makes Shortcuts shine.
But even as-is, this trio of Shortcuts transforms Kasa devices from “app-only” gadgets into fully programmable components of your Apple ecosystem. And that’s the magic of Shortcuts: giving you the tools to bend devices and services to your will–even when their makers don’t.