TP-Link has a set of interesting WiFi smart plugs -- the HS100 which provides remote access and control for a power plug, and HS110 which is essentially HS100 but with energy monitoring.
tplinkhs110
is a Go library for accessing these smart plugs, based on the information available above. I have tested them out with a HS110 only and it works perfectly fine. An example of how to use this library is:
package main
import (
"fmt"
"github.com/shirdonl/tplinkhs110"
)
func main() {
plug := tplinkhs110.Hs1xxPlug{IPAddress: "192.168.0.196"}
results, err := plug.MeterInfo()
if err != nil {
fmt.Println("err:", err)
}
fmt.Println(results)
}
The results printed (after cleaning up):
{
"emeter": {
"get_realtime": {
"current": 0.015135,
"voltage": 296.213416,
"power": 1.193017,
"total": 0.061,
"err_code": 0
},
"get_vgain_igain": {
"vgain": 16566,
"igain": 13042,
"err_code": 0
}
}
}
Functions include:
- TurnOn() -- turning on the power on the plug
- TurnOff() -- turning off the power on the plug
- SystemInfo() -- getting information on the plug
- MeterInfo() -- metering info on the plug, including the current, voltage, power and the total power consumption till date, as well as the vgain and igain
- DailyStats(month, year) -- energy consumed per day for the given month and year