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. diff --git a/tplink-smartplug.py b/tplink-smartplug.py index 3a2fde8..b42c232 100644 --- a/tplink-smartplug.py +++ b/tplink-smartplug.py @@ -21,6 +21,7 @@ # import socket import argparse +from struct import pack version = 0.1 @@ -44,14 +45,15 @@ 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 # 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