Skip to content

A rest api client for the proprietary TP-Link Smart Home protocol to control TP-Link HS110 WiFi Smart Plugs.

License

Notifications You must be signed in to change notification settings

larmic-iot/tp-link-hs110-api

Repository files navigation

tp-link-hs110-api

License Go build Docker build and push (Release) Docker hub image Docker Image Version (latest by date)

A REST api client (adapter) for the proprietary TP-Link Smart Home protocol to control TP-Link HS110 WiFi Smart Plugs. The SmartHome protocol runs on TCP port 9999 and uses a trivial XOR autokey encryption that provides no security. This application uses a REST api as a wrapper on the TCP socket connection. There is no authentication mechanism and REST endpoints documented in open api 3.1.

This project inspired by tplink-smartplug written in python and improves my Go knowledge.

Versioning

Semantic Versioning 2.x is used. Version number MAJOR.MINOR.PATCH with

  • MAJOR version increase on incompatible API changes
  • MINOR version increase on adding new functionality in a backwards compatible manner
  • PATCH version increase on backwards compatible bug fixes or documentation

Usage

The easiest way is to use the docker image. Otherwise, the artifact will have to be built by yourself.

$ docker pull larmic/tp-link-hs110-api
$ docker run -d -p 8080:8080 --rm --name larmic-tp-link-hs110-api larmic/tp-link-hs110-api

Example requests

$ curl http://localhost:8080/tp-link-api                        # Open Api 3.1 specification
$ curl http://localhost:8080/tp-link-api/10.0.0.1               # General energy plug information
$ curl http://localhost:8080/tp-link-api/10.0.0.1/consumption   # Energy consumption

Build application by yourself

Requirements

  • Docker
  • Go 1.17.x (if you want to build it without using docker builder)

Build it

$ make docker-build                             # build local docker image
$ make docker-all                               # build docker container
$ make IMAGE_TAG="0.0.1" docker-all             # build docker container with specific version

Run it native

$ make run                                      # start native app 
$ curl http://localhost:8080/api/10.0.0.210     # call rest service
$ ctrl+c                                        # stop native app

Run it using docker

$ make docker-run                               # start docker image 
$ curl http://localhost:8080/api/10.0.0.210     # call rest service
$ make docker-stop                              # stop and remove docker app

About

A rest api client for the proprietary TP-Link Smart Home protocol to control TP-Link HS110 WiFi Smart Plugs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published