From 7fabe4574c306496224feccf71b65f15802cfcd7 Mon Sep 17 00:00:00 2001 From: Keith Chiem Date: Wed, 8 Nov 2017 02:16:45 -0800 Subject: [PATCH 1/3] make it work with hs105 --- tplink-smartplug.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tplink-smartplug.py b/tplink-smartplug.py index 3a2fde8..34b89cc 100644 --- a/tplink-smartplug.py +++ b/tplink-smartplug.py @@ -21,6 +21,7 @@ # import socket import argparse +from struct import pack version = 0.1 @@ -51,7 +52,7 @@ commands = {'info' : '{"system":{"get_sysinfo":{}}}', # XOR Autokey Cipher with starting key = 171 def encrypt(string): key = 171 - result = "\0\0\0\0" + result = pack('>I', len(string)) for i in string: a = key ^ ord(i) key = a From 49cf14d92f486dcd95167526b58706b5efc1235f Mon Sep 17 00:00:00 2001 From: Keith Chiem Date: Thu, 9 Nov 2017 20:15:08 -0800 Subject: [PATCH 2/3] add 'energy' command for realtime voltage/current/power stats from hs110. --- tplink-smartplug.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tplink-smartplug.py b/tplink-smartplug.py index 34b89cc..b42c232 100644 --- a/tplink-smartplug.py +++ b/tplink-smartplug.py @@ -45,7 +45,8 @@ commands = {'info' : '{"system":{"get_sysinfo":{}}}', 'countdown': '{"count_down":{"get_rules":{}}}', 'antitheft': '{"anti_theft":{"get_rules":{}}}', 'reboot' : '{"system":{"reboot":{"delay":1}}}', - 'reset' : '{"system":{"reset":{"delay":1}}}' + 'reset' : '{"system":{"reset":{"delay":1}}}', + 'energy' : '{"emeter":{"get_realtime":{}}}' } # Encryption and Decryption of TP-Link Smart Home Protocol From e2f848e0640c1d703e2abbcfa56f3b7f57cc3430 Mon Sep 17 00:00:00 2001 From: Keith Chiem Date: Thu, 9 Nov 2017 20:20:19 -0800 Subject: [PATCH 3/3] add 'energy' command. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 251bdb3..21d2686 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Provide the target IP using `-t` and a command to send using either `-c` or `-j` | antitheft | Lists configured antitheft rules | | reboot | Reboot the device | | reset | Reset the device to factory settings | +| energy | Return realtime voltage/current/power| More advanced commands such as creating or editing rules can be issued using the `-j` flag by providing the full JSON string for the command. Please consult [tplink-smarthome-commands.txt](tplink-smarthome-commands.txt) for a comprehensive list of commands.