forked from beveradb/pysonofflan
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,935 additions
and
1,496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Python: Current File", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "${file}", | ||
"console": "integratedTerminal" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,11 @@ | ||
History | ||
======= | ||
|
||
0.3.0 (2019-05-16) | ||
------------------ | ||
* Cleaned up shutdown code | ||
* Create retry logic throughout to deal with disconnect and other failures | ||
* Added functionality to deal with state maintenance | ||
* Updated dependencies | ||
* Removed flaky test | ||
|
||
0.2.1 (2019-02-02) | ||
------------------ | ||
* Made websocket library usage backwards-compatible with older versions | ||
|
||
0.2.0 (2019-02-02) | ||
------------------ | ||
* Rewrote discovery to use multiple threads so it only takes 1 second | ||
* Improved logging in client class with logger passed through | ||
* Improved handling of event loop to allow usage within existing async codebase | ||
* Added --version argument to CLI | ||
|
||
0.1.7 (2019-02-01) | ||
------------------ | ||
* Migrated from bumpversion to bump2version for cleaner release process | ||
|
||
0.1.6 (2019-02-01) | ||
------------------ | ||
* Another bump to let Travis upload to PyPi itself, to fix the build | ||
|
||
0.1.5 (2019-02-01) | ||
------------------ | ||
* Bumped version after tweaking build workflow | ||
|
||
0.1.4 (2019-01-31) | ||
------------------ | ||
|
||
* Tweaked various build and testing parameters to get code coverage and distribution working | ||
|
||
0.1.3 (2019-01-31) | ||
------------------ | ||
|
||
* Updated README layout | ||
* Added coveralls config for travis and CHANGELOG/HISTORY link | ||
|
||
0.1.2 (2019-01-31) | ||
------------------ | ||
|
||
* Fixed documentation build for ReadTheDocs | ||
* Fixed restructuredtext in history which was breaking PyPi formatting | ||
|
||
0.1.1 (2019-01-30) | ||
------------------ | ||
|
||
* Improved discovery logging | ||
* Added documentation | ||
* Fixed tests | ||
|
||
0.1.0 (2019-01-27) | ||
1.1.0 (2020-01-04) | ||
------------------ | ||
|
||
* First release on PyPI. | ||
* Basic functional CLI client, to allow basic control (on, off, check state) | ||
* Added comprehensive logging with verbosity option to help debug new devices | ||
* Control of device is via async websocket, so should be usable in async code | ||
* Forked from PySonoffLAN package (courtesy of Andrew Beveridge) | ||
* Works on V3 Itead firmware using mDNS for service discovery and REST for service invocation | ||
* Supports DIY mode as well as 'standard' mode (for standard mode API key is needed to be obtained, e.g. by sniffing LAN) | ||
* Supports all known devices for switching, although no sensors added at this point |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from Crypto.Hash import MD5 | ||
from Crypto.Cipher import AES | ||
from Crypto.Util.Padding import unpad | ||
from base64 import b64decode | ||
|
||
|
||
class SonoffR3: | ||
def __init__(self, Apikey): | ||
|
||
h = MD5.new() | ||
h.update(Apikey) | ||
self._key = h.digest() | ||
|
||
def Decrypt(self, encoded, iv): | ||
|
||
cipher = AES.new(self._key, AES.MODE_CBC, iv=b64decode(iv)) | ||
ciphertext = b64decode(encoded) | ||
padded = cipher.decrypt(ciphertext) | ||
plaintext = unpad(padded, AES.block_size) | ||
|
||
return plaintext | ||
|
||
|
||
device = SonoffR3(b"apikey") | ||
print(device.Decrypt(b"ciphertext", b"iv")) |
Oops, something went wrong.