From 61f68c8ea956f144ceb9c24591582201bbac2368 Mon Sep 17 00:00:00 2001 From: David Haguenauer Date: Fri, 29 Dec 2017 23:13:41 -0500 Subject: [PATCH] Add support for HS105 protocol Compared to the HS100 and HS110, where messages sent and received begin with a four-byte header that can be safely ignored (and set to zero in the existing code), the HS105 mini-plug requires queries to have a correct length header matching the message length. This changeset provides such a header when sending queries. We still ignore the header when receiving responses from the smart plug. --- tplink-smartplug.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tplink-smartplug.py b/tplink-smartplug.py index 59b412c..3ad5e58 100644 --- a/tplink-smartplug.py +++ b/tplink-smartplug.py @@ -21,6 +21,7 @@ # import socket import argparse +import struct 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 = struct.pack(">I", len(string)) for i in string: a = key ^ ord(i) key = a