All Projects → vrachieru → tplink-smartplug-api

vrachieru / tplink-smartplug-api

Licence: MIT license
TP-Link HS1xx smart plug API wrapper.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to tplink-smartplug-api

Python Miio
Python library & console tool for controlling Xiaomi smart appliances
Stars: ✭ 1,995 (+4056.25%)
Mutual labels:  home-automation, smart-home
Smart Mirror
The fairest of them all. A DIY voice controlled smart mirror with IoT integration.
Stars: ✭ 2,668 (+5458.33%)
Mutual labels:  home-automation, smart-home
Ha4iot
Open Source Home Automation system for .NET
Stars: ✭ 146 (+204.17%)
Mutual labels:  home-automation, smart-home
Rpieasy
Easy MultiSensor device based on Raspberry PI
Stars: ✭ 85 (+77.08%)
Mutual labels:  home-automation, smart-home
sensor
Sensor by Metriful | Indoor environment monitoring | Documentation and code samples
Stars: ✭ 93 (+93.75%)
Mutual labels:  home-automation, smart-home
Homebridge Netatmo
This is a homebridge plugin for several netatmo devices
Stars: ✭ 99 (+106.25%)
Mutual labels:  home-automation, smart-home
Home Assistant Config Fr
🏠Configuration de Home Assistant en français. 👨🏻‍💻 N'hésitez pas à ⭐ mon repo et à copier les bonnes idées ! 🇨🇵
Stars: ✭ 175 (+264.58%)
Mutual labels:  home-automation, smart-home
Samsung Tv Api
Samsung Smart TV API wrapper.
Stars: ✭ 52 (+8.33%)
Mutual labels:  home-automation, smart-home
tplink-smarthome-crypto
TP-Link Smarthome Crypto
Stars: ✭ 22 (-54.17%)
Mutual labels:  tplink, kasa
tplink-plug-exporter
TP-Link Smart Plug Prometheus Exporter
Stars: ✭ 80 (+66.67%)
Mutual labels:  smart-home, tplink
Fritzctl
A lightweight, easy to use console client for the AVM FRITZ!Box Home Automation.
Stars: ✭ 84 (+75%)
Mutual labels:  home-automation, smart-home
casa
Home Assistant setup for our home
Stars: ✭ 132 (+175%)
Mutual labels:  home-automation, smart-home
Homeassistant Config
Configuration for @brianjking & @KinnaT's Home Assistant Installation
Stars: ✭ 80 (+66.67%)
Mutual labels:  home-automation, smart-home
Xiaomi Flower Care Api
Xiaomi Flower Care (MiFlora) API wrapper.
Stars: ✭ 111 (+131.25%)
Mutual labels:  home-automation, smart-home
Streamdeck Homeassistant
🏠 Use the Elgato Stream Deck as Home Assistant controller. Call any available service and toggle lights or resume your music.
Stars: ✭ 69 (+43.75%)
Mutual labels:  home-automation, smart-home
Entity Controller
Entity and lighting controller for managing devices via timers, scripts, and sun-based time restrictions.
Stars: ✭ 156 (+225%)
Mutual labels:  home-automation, smart-home
Coapnet
CoAPnet is a high performance .NET library for CoAP based communication. It provides a CoAP client and a CoAP server. It also has DTLS support out of the box.
Stars: ✭ 23 (-52.08%)
Mutual labels:  home-automation, smart-home
Tasmota Connect
Add your Tasmota devices as SmartThings devices
Stars: ✭ 51 (+6.25%)
Mutual labels:  home-automation, smart-home
Home Assistant Cli
💻 Command-line tool for Home Assistant
Stars: ✭ 243 (+406.25%)
Mutual labels:  home-automation, smart-home
linux-control
Control your Linux laptop/desktop via Google Assistant
Stars: ✭ 46 (-4.17%)
Mutual labels:  home-automation, smart-home


Version Version
TP-Link HS1xx smart plug API wrapper

About TP-Link SmartPlug

  • TP-Link Smart Plugs are power plugs that can be turned on and off remotely via an app
  • Can be operated either via cloud or lan
  • Offer energy monitoring and scheduling capabilities

Features

  • Configure device
  • Query device information
  • Change plug state

Install

$ pip3 install git+https://github.com/vrachieru/tplink-smartplug-api.git

or

$ git clone https://github.com/vrachieru/tplink-smartplug-api.git
$ pip3 install ./tplink-smartplug-api

Usage

Reading device information

from tplink_smartplug import SmartPlug

plug = SmartPlug('192.168.xxx.xxx')

print('Name:      %s' % plug.name)
print('Model:     %s' % plug.model)
print('Mac:       %s' % plug.mac)
print('Time:      %s' % plug.time)

print('Is on:     %s' % plug.is_on)
print('Nightmode: %s' % (not plug.led))
print('RSSI:      %s' % plug.rssi)
$ python3 example.py
Name:      Livingroom Floor Lamps
Model:     HS100(EU)
Mac:       50:C7:XX:XX:XX:XX
Time:      2018-11-06 14:14:00

Is on:     True
Nightmode: False
RSSI:      -59

Change state

from tplink_smartplug import SmartPlug

plug = SmartPlug('192.168.xxx.xxx')

if plug.is_on:
    plug.turn_off()
    print('Plug turned off')
else:
    plug.turn_on()
    print('Plug turned on')
$ python3 example.py
Plug turned off

$ python3 example.py
Plug turned on

Protocol

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.

The initial key (initialization vector) has a hardcoded value of -85 (= 171).
The first byte of the plaintext is XORed with the key. The key is then set to the plaintext byte.
During the next iteration, the next plaintext byte is XORed with the previous plaintext byte.

Decryption works the same, with the keystream made out of cyphertext bytes.
This is known as an autokey cipher and while it has better statistical properties than simple XOR encryption with a repeating key, it can be easily broken by known plaintext attacks.

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": {} 
    }
}

Commands can be nested, for example:

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

Reference

[1] https://www.softscheck.com/en/reverse-engineering-tp-link-hs110/

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].