Skip to content

gittycat/smartplug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API to access the TP-Link HS110 SmartPlug

Go Report Card

Simple, idiomatic and working API to access a TP-Link HS100 or HS110 smartplug.

The focus is on presenting the minimum code needed to query the smartplug. There are about 50 calls documented to control the device. Only a handful of calls are implemented here although extending it should be fairly trivial.

How to Use

Here's a minimal program to retrieve Power and Current metrics.

package main

import (
    "fmt"
    "github.com/gittycat/smartplug"
)

func main() {
    p := smartplug.NewSmartplug("192.168.1.9", "9999") // ip, port
    info, err := p.Meter()
    if err != nil {
        panic(err)
    }
    fmt.Printf("Power: %d mW  Current: %d mA\n", info.PowerMw, info.CurrentMa)
}

The included example/example.go program shows how to retrieve the metrics at intervals.

Credits

The encryption and decryption is based on the python code from SoftsCheck

This API is possible due to the reverse engineering work done by Lubomir Stroetmann and Tobias Esser at SoftsCheck. https://www.softscheck.com/en/reverse-engineering-tp-link-hs110/

They also include a command line python app to query and control the device.

About

TPLink HS110 smart plug API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages