denki (電気)
Control TP-Link Kasa and Tapo devices over your local network. Switch supported plugs and lights, inspect energy usage and record measurements for scripts. 電気 means “electricity” in Japanese.
Documentation & demo · Rust API · Supported devices
Install
With Rust 1.99 or newer:
Cargo installs into ~/.cargo/bin; keep it on PATH. To upgrade, run
cargo install denki --locked. GitHub releases contain source archives, not
prebuilt executables. See getting started for an exact
tagged-source install and contributing for development setup.
Connect a device
For Kasa, scan, independently verify the device address, then enroll your own alias:
Scan does not create new Kasa aliases. Legacy Kasa aliases must be explicitly
re-saved with denki alias NAME IP before group commands can control them.
Scan never moves a saved Kasa alias based on an unauthenticated device ID. After a
DHCP change, verify the new address independently (for example, in your router),
then run denki alias "desk plug" NEW_IP. Kasa scan results are unauthenticated
and do not include physical-control command hints. Verify a device independently
before controlling it. See discovery.
For a Tapo P125, save its address and TP-Link account credentials:
Replace names and example addresses with your devices. login prompts for the
password. --tapo (--tpap) negotiates TPAP/KLAP; existing --klap aliases keep
the original client. Scan probes saved Tapo addresses. Unknown IPs default to Kasa.
Set DENKI_REQUIRE_TPAP=1 to refuse non-TPAP authentication, including KLAP
fallback. KLAP handshake captures permit offline password guessing; the default
compatibility mode warns when KLAP is selected.
See Tapo setup and limits.
Energy and groups
On an energy-capable model:
P125 does not provide energy monitoring in Denki. The energy guide
covers units, JSONL, unavailable readings and failed samples. Preview a group
before switching it: denki group off "office" --dry-run lists matches without
contacting devices.
Support and development
Capabilities depend on model, firmware and connection mode. P125 automatic-mode info and on/off readbacks are hardware-verified; toggle and its KLAP fallback remain unverified. Upstream support alone does not establish Denki support. devices.toml and the support guide record exact capabilities and evidence.
- Commands, aliases and credentials · troubleshooting
- Library examples · architecture
- Contributing and offline tests · agent guide
- Publishing · changelog · CI maintenance
Device responses are limited to 1 MiB on every control transport. Human-readable output escapes terminal control characters; unsafe aliases never become command hints. JSON escapes terminal-active Unicode reversibly and preserves values for programs.
TPAP/KLAP auto-negotiation uses a bundled, hardened copy of Mihai Dinculescu's tapo library. Denki is MIT licensed; dependencies retain their own licenses.
denki doctor "device" shows Wi-Fi signal and suggests next steps for connection,
authentication, and protocol failures. --json includes a next_steps array;
weak signal is a warning, not a failed connectivity check. Doctor never switches power.
Use denki identify "desk plug" --confirm to record physical identification,
and denki doctor --all for read-only fleet health checks. See the
command guide.