skydiver / ewelink-api

eWeLink API for JavaScript
https://www.npmjs.com/package/ewelink-api
MIT License
265 stars 109 forks source link

Accessible devices don't appear in getDevices() #104

Open lachlansleight opened 3 years ago

lachlansleight commented 3 years ago

When running getDevices(), I was receiving an empty array []. However, if I log into the ewelink app and find the device ID of one of the BLue50 SX1 smart plugs I have and manually put it into getDevice() it connects successfully and can be controlled.

const connection = new ewelink({
    email: '[MY_EMAIL]',
    password: '[MY_PASSWORD]',
    region: 'us'
});

//this doesn't work, returns an empty array
const devices = await connection.getDevices();
console.log(devices);

//this works, returns the device successfully
const device = await connection.getDevice([KNOWN_DEVICE_ID])
console.log(device);

The advice given in #88 for non-sonoff devices didn't help - I still receive an empty array.

The device firmware is 3.4.1 (current version), and my ewelink app is on v4.4.1

skydiver commented 3 years ago

sadly i don't have a non sonoff device to test

you can take a look if this issue helps: https://github.com/skydiver/ewelink-api/issues/88#issuecomment-643574472

if not, hopefully someone can help 🤞

bwp91 commented 3 years ago

@skydiver may be worth a look at the v2 of the coolkit api? I’ve left a link of the official reference, and a link to my homebridge plugin which uses it. My plugin also works with non-sonoff devices, basically all ewelink devices. HTH :)

https://github.com/CoolKit-Technologies/apiDocs/blob/master/en/APICenterV2.md#api-center

https://github.com/bwp91/homebridge-ewelink/blob/master/lib/eWeLinkHTTP.js

skydiver commented 3 years ago

Thank you @bwp91

Definitely i will take a look

I was using this one https://coolkit-technologies.github.io/apiDocs/#/en/PlatformOverview but didn't know there is a version 2

bwp91 commented 3 years ago

@skydiver would be very happy to get more involved with this project if needed

skydiver commented 3 years ago

Hey @bwp91, of course, help is always welcome

vdkuil commented 3 years ago

I ran into a similar problem, but the devices show up when using ewelink-api@2.0.0 version. It stopped working after 2.0.1. I don't see many differences in the code though.

vdkuil commented 3 years ago

Seems like the change required for me was the change of APP_ID and APP_SECRET. Once I changed them back to the old values from ewe-link version 2.0.0 everything seems to work again.