@@ -10,26 +10,60 @@ Usage:
10
10
11
11
``` shell
12
12
$ python3 get_encryption_key.py MAC USERNAME
13
- Key ID: xx
14
- Encryption key: xxxxxxxxxxxxxxxx
13
+ Key ID: XX
14
+ Encryption key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
15
15
```
16
16
17
17
Where ` MAC ` is MAC address of the lock and ` USERNAME ` is your SwitchBot account username, after that script will ask for your password.
18
18
If authentication succeeds then script should output your key id and encryption key.
19
19
20
20
## Examples:
21
21
22
- #### WoLock
22
+ #### WoLock (Lock-Pro)
23
+
24
+ Unlock:
23
25
24
26
``` python
25
27
import asyncio
26
28
from switchbot.discovery import GetSwitchbotDevices
27
29
from switchbot.devices import lock
30
+ from switchbot.const import SwitchbotModel
31
+
32
+ BLE_MAC = " XX:XX:XX:XX:XX:XX" # The MAC of your lock
33
+ KEY_ID = " XX" # The key-ID of your encryption-key for your lock
34
+ ENC_KEY = " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" # The encryption-key with key-ID "XX"
35
+ LOCK_MODEL = SwitchbotModel.LOCK_PRO # Your lock model (here we use the Lock-Pro)
36
+
37
+
38
+ async def main ():
39
+ wolock = await GetSwitchbotDevices().get_locks()
40
+ await lock.SwitchbotLock(
41
+ wolock[BLE_MAC ].device, KEY_ID , ENCRYPTION_KEY , model = LOCK_MODEL
42
+ ).unlock()
43
+
44
+
45
+ asyncio.run(main())
46
+ ```
47
+
48
+ Lock:
49
+
50
+ ``` python
51
+ import asyncio
52
+ from switchbot.discovery import GetSwitchbotDevices
53
+ from switchbot.devices import lock
54
+ from switchbot.const import SwitchbotModel
55
+
56
+ BLE_MAC = " XX:XX:XX:XX:XX:XX" # The MAC of your lock
57
+ KEY_ID = " XX" # The key-ID of your encryption-key for your lock
58
+ ENC_KEY = " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" # The encryption-key with key-ID "XX"
59
+ LOCK_MODEL = SwitchbotModel.LOCK_PRO # Your lock model (here we use the Lock-Pro)
28
60
29
61
30
62
async def main ():
31
63
wolock = await GetSwitchbotDevices().get_locks()
32
- await lock.SwitchbotLock(wolock[' 32C0F607-18B8-xxxx-xxxx-xxxxxxxxxx' ].device, " key-id" , " encryption-key" ).get_lock_status()
64
+ await lock.SwitchbotLock(
65
+ wolock[BLE_MAC ].device, KEY_ID , ENCRYPTION_KEY , model = LOCK_MODEL
66
+ ).lock()
33
67
34
68
35
69
asyncio.run(main())
0 commit comments