{"id":13585481,"url":"https://github.com/vrachieru/tplink-smartplug-api","last_synced_at":"2026-01-20T15:05:44.154Z","repository":{"id":75100151,"uuid":"89861844","full_name":"vrachieru/tplink-smartplug-api","owner":"vrachieru","description":"TP-Link HS1xx smart plug API wrapper.","archived":false,"fork":false,"pushed_at":"2020-08-10T12:32:53.000Z","size":12,"stargazers_count":48,"open_issues_count":0,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-06T03:42:51.656Z","etag":null,"topics":["api-wrapper","home-automation","kasa","reverse-engineering","smart-home","smart-plug","tplink"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vrachieru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-04-30T16:14:29.000Z","updated_at":"2023-12-02T18:22:03.000Z","dependencies_parsed_at":"2024-02-07T14:58:54.424Z","dependency_job_id":null,"html_url":"https://github.com/vrachieru/tplink-smartplug-api","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrachieru%2Ftplink-smartplug-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrachieru%2Ftplink-smartplug-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrachieru%2Ftplink-smartplug-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrachieru%2Ftplink-smartplug-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vrachieru","download_url":"https://codeload.github.com/vrachieru/tplink-smartplug-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247636028,"owners_count":20970848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","home-automation","kasa","reverse-engineering","smart-home","smart-plug","tplink"],"created_at":"2024-08-01T15:04:58.123Z","updated_at":"2026-01-20T15:05:44.141Z","avatar_url":"https://github.com/vrachieru.png","language":"Python","funding_links":[],"categories":["Python","reverse-engineering"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/5860071/48065298-f97e8400-e1d2-11e8-999c-1a84c25cac14.png\" width=\"150px\" border=\"0\" /\u003e\n    \u003cbr/\u003e\n    \u003ca href=\"https://github.com/vrachieru/tplink-smartplug-api/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/version-1.1.2-brightgreen.svg?style=flat-square\" alt=\"Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://travis-ci.org/vrachieru/tplink-smartplug-api\"\u003e\n        \u003cimg src=\"https://img.shields.io/travis/vrachieru/tplink-smartplug-api.svg?style=flat-square\" alt=\"Version\"\u003e\n    \u003c/a\u003e\n    \u003cbr/\u003e\n    TP-Link HS1xx smart plug API wrapper\n\u003c/p\u003e\n\n## About TP-Link SmartPlug\n\n* [TP-Link Smart Plugs](https://www.tp-link.com/us/home-networking/smart-home/smart-plugs) are power plugs that can be turned on and off remotely via an app \n* Can be operated either via cloud or lan\n* Offer energy monitoring and scheduling capabilities \n\n## Features\n\n* Configure device\n* Query device information\n* Change plug state\n\n## Install\n\n```bash\n$ pip3 install git+https://github.com/vrachieru/tplink-smartplug-api.git\n```\nor\n```bash\n$ git clone https://github.com/vrachieru/tplink-smartplug-api.git\n$ pip3 install ./tplink-smartplug-api\n```\n\n## Usage\n\n### Reading device information\n\n```python\nfrom tplink_smartplug import SmartPlug\n\nplug = SmartPlug('192.168.xxx.xxx')\n\nprint('Name:      %s' % plug.name)\nprint('Model:     %s' % plug.model)\nprint('Mac:       %s' % plug.mac)\nprint('Time:      %s' % plug.time)\n\nprint('Is on:     %s' % plug.is_on)\nprint('Nightmode: %s' % (not plug.led))\nprint('RSSI:      %s' % plug.rssi)\n```\n\n```bash\n$ python3 example.py\nName:      Livingroom Floor Lamps\nModel:     HS100(EU)\nMac:       50:C7:XX:XX:XX:XX\nTime:      2018-11-06 14:14:00\n\nIs on:     True\nNightmode: False\nRSSI:      -59\n```\n\n### Change state\n\n```python\nfrom tplink_smartplug import SmartPlug\n\nplug = SmartPlug('192.168.xxx.xxx')\n\nif plug.is_on:\n    plug.turn_off()\n    print('Plug turned off')\nelse:\n    plug.turn_on()\n    print('Plug turned on')\n```\n\n```bash\n$ python3 example.py\nPlug turned off\n\n$ python3 example.py\nPlug turned on\n```\n\n## Protocol\n\nA python client for the proprietary TP-Link Smart Home protocol to control TP-Link `HS100` and `HS110` WiFi Smart Plugs.  \nThe SmartHome protocol runs on TCP port `9999` and uses a trivial `XOR` autokey encryption that provides no security.\n\nThe initial key (`initialization vector`) has a hardcoded value of `-85 (= 171)`.  \nThe first byte of the plaintext is `XORed` with the key. The key is then set to the plaintext byte.  \nDuring the next iteration, the next plaintext byte is `XORed` with the previous plaintext byte. \n\nDecryption works the same, with the keystream made out of cyphertext bytes.  \nThis 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.\n\nThere is no authentication mechanism and commands are accepted independent of device state (configured/unconfigured).\n\nCommands are formatted using JSON, for example:\n```json\n{ \n    \"system\": { \n        \"get_sysinfo\": {} \n    }\n}\n```\n\nCommands can be nested, for example:\n```json\n{\n    \"system\": {\n        \"get_sysinfo\": {}\n    },\n    \"time\": {\n        \"get_time\": {}\n    }\n}\n```\n\n## Reference\n\n[1] https://www.softscheck.com/en/reverse-engineering-tp-link-hs110/\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvrachieru%2Ftplink-smartplug-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvrachieru%2Ftplink-smartplug-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvrachieru%2Ftplink-smartplug-api/lists"}