nocmt / ewelink-api-next

CoolKit v2 API Official Library
MIT License
19 stars 4 forks source link

Lan control #5

Closed antonioGabrielGomes closed 1 year ago

antonioGabrielGomes commented 1 year ago

About this selfApiKey, where can it be generated? Could you make a complete example?

`// eWeLink Lan Control import eWeLink from "ewelink-api-next";

const lanClient = new eWeLink.Lan({ selfApikey: "xxx", logObj: eWeLink.createLogger("lan") });

lanClient.discovery((server) => { console.log("server:", server); }); // Start Discovery Service

// Save device information to local cache

// When controlling, it is necessary to pass in deviceId, secretKey, encryption, iv try { const res = await lanClient.zeroconf.switch({ ip: "xxx", port: 80, data: { switch: "on" }, deviceId: "xxx", secretKey: "xxx", encrypt: true, iv: "xxx" }); console.info("Request result::", res); const res2 = await lanClient.zeroconf.switches({ ip: "xxx", port: 80, data: { switches: [ { switch: "on", outlet: 0 }, { switch: "on", outlet: 1 }, { switch: "on", outlet: 2 }, { switch: "on", outlet: 3 } ] }, deviceId: "xxx", secretKey: "xxx", encrypt: true, iv: "xxx" }); console.info("Request result::", res2); } catch (error: any) { console.info(error.message); }`

ghost commented 1 year ago

selfApiKey='user.apikey' obtained after login

ghost commented 10 months ago

You can indirectly obtain your apikey by accessing your device information, home, and other related interfaces