Skip to content

Commit

Permalink
Merge pull request softScheck#1 from kchiem/master
Browse files Browse the repository at this point in the history
Add Support for HS105 and add Energy Command
  • Loading branch information
blndev authored Jun 24, 2018
2 parents a8f9e9d + e2f848e commit 2d8c287
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 4 additions & 2 deletions tplink-smartplug.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#
import socket
import argparse
from struct import pack

version = 0.1

Expand All @@ -44,14 +45,15 @@ def validIP(ip):
'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
Expand Down

0 comments on commit 2d8c287

Please sign in to comment.