Adds support for the TP-Link Kasa device family to Scrypted: cameras, plugs/outlets, switches/dimmers, and bulbs. Discovery is unified — one UDP/9999 sweep finds everything and the plugin routes each device to the right Scrypted interfaces.
In Scrypted:
- Open the Plugins page.
- Choose Install and enter
scrypted-kasa. - The plugin appears as Kasa Plugin in the device list — see Setup below.
- Reads the camera's proprietary multipart stream (HTTPS port 19443,
/https/stream/mixed) and re-streams H.264 video + G.711 µ-law audio over local RTSP for Scrypted, HomeKit, the NVR, etc. - Streams talk audio back to the camera's speaker via the camera's separate uplink endpoint
(HTTPS port 18443,
/https/speaker/audio/g711block) — usable from HomeKit and any other Scrypted client that supports two-way audio. - Exposes the camera's spotlight (when present, e.g. KC420WS) as an
OnOffchild light device in the same room as the camera. Driven by the LINKIE2 control protocol on port 10443. - Exposes the camera's siren (when present) as an
OnOffchild siren device, also in the camera's room. HomeKit shows it as a switch inside the camera accessory. Triggering it turns the siren on; the camera auto-stops after the duration configured in the Kasa app (default 30 s). - Exposes the camera's own on/off ("camera off" in the Kasa app) as a Privacy Mode
child switch. On turns the camera off, which stops video for every client, not just
HomeKit, so it suits home/away automations. While the camera is off, stream attempts fail
with a short "turned off" message instead of an error, and video resumes on its own when
it's turned back on. The camera also exposes this state as a
PrivacyModeinterface. A HomeKit plugin with PrivacyMode support binds it to the camera's on/off in the Home app (including Home/Away camera modes). That needs HomeKit Secure Video recording (a motion source, or HomeKit Secure Video 3) and is turned on per camera with the HomeKit plugin's Camera Privacy Mode setting. Home hubs reapply the Home app's camera mode whenever they reconnect, so turning the camera on or off here or in the Kasa app only lasts until then. - Exposes the camera's status LED as the camera's own
OnOffinterface, so HomeKit's per-camera "Link Status Indicator" toggle drives the LED. - Exposes pan/tilt (when present, e.g. KC410S) as the camera's own
PanTiltZoominterface: step moves in the Scrypted and NVR camera views, plus the viewpoints saved in the Kasa app as presets. HomeKit has no pan/tilt support, so this is not visible there. - Motion events from camera (per-camera setting, off by default): uses the camera's own
motion detection as the camera's
MotionSensor, read over LINKIE2 once a second (smartlife.cam.ipcamera.vod.get_detect_event_state). No video is decoded on the server. Sensitivity and zones come from the Kasa app, and person detection or a doorbell ring also count as motion. Motion stays on for 10 s after the camera last reports it. With Video Analysis on the same camera, its Built-In Motion Sensor option picks which detector wins. - Snapshots from camera (per-camera setting, off by default): answers snapshot requests
from the camera's own JPEG endpoint (
/https/stream/snapshot.jpgon port 19443) instead of decoding a frame from the video stream. It takes about half a second and works while the stream is in use, but the image is a fixed 640x360. If the camera fails a snapshot or takes longer than about 3 s, the last good one is returned instead (for up to 10 minutes, and never while the camera is turned off or for an event snapshot such as a motion notification). - Adds a Reboot camera button to the camera's Settings tab
(
smartlife.cam.ipcamera.system.set_rebootover LINKIE2). Useful when the video stream stops — connection refused on port 19443 while the control port still answers — which otherwise needs a power cycle. The camera is back after about 30 s.
Each device class is its own implementation, descended from a shared KasaIotDevice
base that holds the relay protocol:
KasaPlug— plain plugs/outlets (HS100/HS103/HS105/HS107/HS110/KP100/...).OnOff,ScryptedDeviceType.Outlet.KasaSwitch— plain wall switches (HS200/HS210/KS200/...).OnOff,ScryptedDeviceType.Switch.KasaDimmer— dimmer plugs and switches (HS220 plug, KS230 3-way switch).OnOff+Brightness,ScryptedDeviceType.Light(dimmable devices are exposed as lights since they're almost always wired to a light fixture, matching the Kasa app's UX).KasaBulb— smart bulbs (LB1xx, KL1xx).OnOff+Brightness, plusColorSettingHsvfor color bulbs andColorSettingTemperaturefor variable-temperature bulbs.
Plugs, switches and dimmers that report a status LED get a Status LED toggle in their Settings.
Devices with energy monitoring (HS110, KP115, KP125, EP25, ...) show live power, voltage, current and total energy on their Settings and Readme tabs, plus today's and this month's usage. The Readme tab also lists daily usage for the last 30 days and monthly usage for the last 12 months, read from the totals the plug keeps itself, so no history is stored in Scrypted.
Multi-outlet plug strips (HS300, KP303) aren't modeled yet — discovery skips them.
If a device stops answering after a firmware update (seen on KP115 firmware 1.1.1), turn on Third-party Compatibility in the Kasa app (Me → Settings) to reopen TCP/UDP 9999. Matter-capable switches and plugs (KS205, KS225, EP40M) are a different case: their firmware has no 9999 interface at all, so they can't be discovered or driven this way. They do run a local HTTP server with a KLAP login handshake, documented in docs/PROTOCOL.md. Its credential is the TP-Link account the device is bound to, and the firmware has no way to set or reset it from the network.
docs/PROTOCOL.md documents every endpoint the plugin uses, in enough detail to write a driver in another language.
Tested camera models: KD110, KC200, KC401, KC420WS, EC71.
- Install the plugin.
- Open the plugin's page and click Discover Devices. Discovery runs only when you click the button — there are no background scans.
- Every LAN-visible Kasa device appears in the list — cameras, plugs, switches, dimmers, and bulbs are all discovered together.
- For each device you want to adopt, fill in the adoption form and click adopt:
- Name — pre-filled with the device's alias or model; edit to taste.
- Room — optional, picked from a dropdown of rooms already in use by other Scrypted devices, or type a new one.
- Username / Password (cameras only) — your Kasa account email and password. After the first camera is configured these are pre-populated from any other Kasa camera in Scrypted.
Adopted devices get their IP, port, name, model, MAC, serial number, and hardware
version populated automatically (HomeKit shows the hardware version as Hardware
Revision). The manufacturer is reported as TP-Link Kasa.
Discovery sends a single UDP/9999 burst on each connected /24:
- A broadcast of the IOT.SMARTHOME
get_sysinfoquery. - A paced unicast of the same query at every IP on the subnet (~3 ms between sends). Some devices (e.g. KC420WS cameras) drop broadcast probes but still answer when the packet is addressed directly. Pacing keeps the kernel/network from coalescing or dropping the burst.
If a device is on a different VLAN/broadcast domain or a non-/24 subnet, use the manual setup below.
- Install the plugin.
- Use Add Device to create a new device. The Add form takes:
- Type — Camera, Plug, Switch, Dimmer, or Bulb.
- Name — required.
- Room — optional, with the same dropdown of existing rooms as the discovery flow.
- After creation, open the device's settings and fill in:
- IP Address of the device on your LAN
- Port (default 19443 for cameras, 9999 for everything else)
- For cameras: Username + Password (your Kasa account email + password)
- The plugin opens a single HTTPS connection to the camera on port 19443 and parses the
multipart/x-mixed-replacebody, splitting it into video parts (video/x-h264, annex-b) and audio parts (audio/g711u). - It scans the first H.264 frames for SPS (NAL 7) and PPS (NAL 8) and inlines them into
the locally served SDP as
sprop-parameter-sets+profile-level-id. This lets short -timeout consumers (HomeKit, browser players) pick up the codec immediately. - It then packetizes the raw H.264 and G.711 µ-law streams as RTP itself (no ffmpeg) and serves them from a local RTSP server that Scrypted reads from.
- When a client engages two-way audio, the plugin opens a long-lived chunked POST to
https://<ip>:18443/https/speaker/audio/g711blockand ffmpeg-transcodes the client's audio to 8 kHz mono G.711 µ-law. - Each 20 ms (160 byte) audio block is wrapped in a
multipart/x-mixed-replacepart withContent-Type: audio/g711uand streamed to the camera. Emptyaudio/heartbeatparts are sent every 3 s during silence to keep the connection alive.
- Non-streaming features go through the camera's "LINKIE2" RPC on port 10443. Wire format:
HTTPS POST
/data/LINKIE2.json, bodyapplication/x-www-form-urlencodedwith a singlecontent=<base64(xor_ab(json))>field. The XOR-AB autokey cipher is the same one used by Kasa's UDP/9999 discovery protocol. - On adoption (and whenever credentials change) the plugin queries these LINKIE2 endpoints
serially:
smartlife.cam.ipcamera.dayNight.get_force_lamp_state— if it returnson/off, a childOnOfflight device named " Spotlight" is registered in the camera's room.smartlife.cam.ipcamera.siren.get_state— same pattern; produces a " Siren" switch child device.smartlife.cam.ipcamera.switch.get_is_enable— produces a " Privacy Mode" switch child device, inverted: on meansset_is_enableoff, and addsPrivacyModeto the camera's own interfaces. A turned-off camera keeps its stream port open but answers HTTP 503.smartlife.cam.ipcamera.led.get_status— drives the camera's ownOnOffso HomeKit can bind itsCameraOperatingModeIndicator(a.k.a. "Status Light") characteristic to it. Enable Link Status Indicator in the HomeKit plugin's per-camera settings to activate the binding.
- Toggling any of the three calls the matching
set_*method with{"value": "on"|"off"}. smartlife.cam.ipcamera.ptz.get_capability— if it succeeds,PanTiltZoomis added to the camera andget_all_presetpopulates its presets. Fixed-lens models answer with-10008and are left alone. Moves useset_movewith{"direction": "left"|"right"|"top"|"bottom", "speed": 1-10}, where speed is the step size of a single discrete step (Scrypted's -1..1 magnitude maps toceil(|v| * 10)); presets useset_run_to_presetwith{"index": n}. There is no absolute-position, home, or zoom command, so those PTZ movements are rejected.
- Authentication uses the cloud account password. All three endpoints take Basic auth with the plain Kasa email as the username; the password format differs by endpoint — receive uses base64(plaintext), talk and LINKIE2 use md5_hex(plaintext). The plugin uses each in the right place.
- LINKIE2 requests must include a
User-Agent: Kasa/...header and theAuthorizationheader on the very first request — the camera silently drops requests without them. - The camera presents a self-signed TLS certificate; certificate verification is disabled.
- One live stream connection per camera. The camera serves a single client on the live
stream (
/https/stream/mixedon port 19443); a second connection opens at the TCP level but stalls in the TLS handshake until it times out. The snapshot endpoint on the same port isn't affected. Scrypted's rebroadcast (prebuffer) plugin holds that one connection and fans it out to HomeKit, the NVR and other clients, so keep it enabled. Another local client (a second NVR, a manualcurl) can't connect to the stream while Scrypted holds it. - Auto-discovery sweeps the local /24 only. Larger subnets (e.g. /23) are skipped to avoid flooding.
git clone https://github.com/sv-tools/scrypted-kasa-plugin.git
cd scrypted-kasa-plugin
npm installCommon scripts:
| Command | Purpose |
|---|---|
npm run build |
Webpack bundle into out/main.nodejs.js (+ plugin.zip) |
npm run fmt |
Format src/**/*.ts with prettier |
npm run fmt:check |
Verify formatting — what CI runs |
npm run lint |
ESLint |
npm run lint:fix |
ESLint with auto-fix |
npm run scrypted-deploy <host> |
Build and deploy to a Scrypted server |
CI on every PR runs fmt:check, lint, and build. Releases publish to npm
automatically when a v* tag is pushed (e.g. git tag v1.2.3 && git push --tags).
The publish workflow signs the package with npm provenance
via GitHub OIDC.
MIT — see LICENSE.