Merge pull request #1 from kchiem/master

Add Support for HS105 and add Energy Command
This commit is contained in:
Daniel Bedarf 2018-06-24 22:28:28 +02:00 committed by GitHub
commit 2d8c28713c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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 | | antitheft | Lists configured antitheft rules |
| reboot | Reboot the device | | reboot | Reboot the device |
| reset | Reset the device to factory settings | | 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. 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.

View File

@ -21,6 +21,7 @@
# #
import socket import socket
import argparse import argparse
from struct import pack
version = 0.1 version = 0.1
@ -44,14 +45,15 @@ commands = {'info' : '{"system":{"get_sysinfo":{}}}',
'countdown': '{"count_down":{"get_rules":{}}}', 'countdown': '{"count_down":{"get_rules":{}}}',
'antitheft': '{"anti_theft":{"get_rules":{}}}', 'antitheft': '{"anti_theft":{"get_rules":{}}}',
'reboot' : '{"system":{"reboot":{"delay":1}}}', '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 # Encryption and Decryption of TP-Link Smart Home Protocol
# XOR Autokey Cipher with starting key = 171 # XOR Autokey Cipher with starting key = 171
def encrypt(string): def encrypt(string):
key = 171 key = 171
result = "\0\0\0\0" result = pack('>I', len(string))
for i in string: for i in string:
a = key ^ ord(i) a = key ^ ord(i)
key = a key = a