-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlocal_key.py
More file actions
46 lines (35 loc) · 1.37 KB
/
local_key.py
File metadata and controls
46 lines (35 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""A script to get the local key."""
import asyncio
import argparse
from roborock.web_api import RoborockApiClient
async def main():
"""A script to get the local key."""
parser = argparse.ArgumentParser(
prog='get_local_key',
description='Retrieve the local key for a Roborock device.',
epilog='Example usage: python local_key.py -e your_email@example.com -p your_password'
)
parser.add_argument("-e", "--email", required=True, help="Your Roborock account email")
parser.add_argument("-p", "--password", required=True, help="Your Roborock account password")
args = parser.parse_args()
web_api = RoborockApiClient(username=args.email)
try:
user_data = await web_api.pass_login(args.password)
except Exception as e:
print(f"Login failed: {e}")
return
# Or you can login with a code using web_api.code_login() and .request_code()
# Login via your password
try:
home_data = await web_api.get_home_data_v3(user_data)
except Exception as e:
print(f"Failed to get device data: {e}")
return
for device in home_data.get_all_devices():
local_key = device.local_key
print(f"Device ID: {device.duid}")
print(f"Device Model: {device.name}")
print(f"Local Key: {local_key}")
print()
if __name__ == "__main__":
asyncio.run(main())