mavalderrama / smartplugs

tplink home smartplugs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Re-implementation of softScheck/tplink-smartplug to work as REST API & Docker

A re-implementation of this software to works as REST API in a Raspberry PI

tplink_smartplug.py

A python client for the proprietary TP-Link Smart Home protocol to control TP-Link HS100 and HS110 WiFi Smart Plugs. The SmartHome protocol runs on TCP port 9999 and uses a trivial XOR autokey encryption that provides no security.

There is no authentication mechanism and commands are accepted independent of device state (configured/unconfigured).

Commands are formatted using JSON, for example:

{"system":{"get_sysinfo":null}}

Instead of null we can also write {}. Commands can be nested, for example:

{"system":{"get_sysinfo":null},"time":{"get_time":null}}

A full list of commands is provided in tplink-smarthome-commands.txt.

Usage

./tplink_smartplug.py -t <ip> [-c <cmd> || -j <json>]

Provide the target IP using -t and a command to send using either -c or -j. Commands for the -c flag:

Command Description
on Turns on the plug
off Turns off the plug
info Returns device info
cloudinfo Returns cloud connectivity info
wlanscan Scan for nearby access points
time Returns the system time
schedule Lists configured schedule rules
countdown Lists configured countdown rules
antitheft Lists configured antitheft rules
reboot Reboot the device
reset Reset the device to factory settings
energy Return realtime voltage/current/power

More advanced commands such as creating or editing rules can be issued using the -j flag by providing the full JSON string for the command. Please consult tplink-smarthome-commands.txt for a comprehensive list of commands.

About

tplink home smartplugs

License:Apache License 2.0


Languages

Language:Python 97.1%Language:Makefile 1.7%Language:Dockerfile 1.2%