-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (24 loc) · 904 Bytes
/
index.js
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
const { EufyHomeSession, TuyaAPISession } = require('./lib/clients');
const email = process.argv[2];
const password = process.argv[3];
if (!email || !password) {
console.error('usage: node index.js "<EUFY ACCOUNT EMAIL>" "<EUFY ACCOUNT PASSWORD>"');
return;
}
(async () => {
try {
const eufyClient = new EufyHomeSession(email, password);
const userInfo = await eufyClient.getUserInfo();
const tuyaClient = new TuyaAPISession(`eh-${userInfo.id}`, userInfo.phone_code);
const homes = await tuyaClient.listHomes();
for (const home of homes) {
console.log(`Home: ${home.groupId}`);
const devices = await tuyaClient.listDevices(home.groupId);
for (const device of devices) {
console.log(`Device: ${device.name}, device ID ${device.devId}, local key ${device.localKey}`);
}
}
} catch (error) {
console.error('Error:', error);
}
})();