Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access non Sonoff devices #88

Open
MarioDBianchi opened this issue May 27, 2020 · 13 comments
Open

Cannot access non Sonoff devices #88

MarioDBianchi opened this issue May 27, 2020 · 13 comments
Labels
enhancement New feature or request

Comments

@MarioDBianchi
Copy link

Hi, I have a few non Sonoff devices, basically 1,2 & 4 channel 7-32V relay boards from eachen.cc that are not being shown by the library.

Seems the appid is for Sonoff specific devices only.

Was able to list them directly from postman using a bearer token got with this library and using appid 'oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq' taken from OpenHab's PHP integration API ( https://github.com/kukkjanos/ewelink )

Now, if I place this APP_ID on the data/constants.js file, the getCredentials call does not autenticate leaving the "at" and "apiKey" blank, from there the rest of the call requirig authentication fails.

@MarioDBianchi
Copy link
Author

PS: got it working.... needed the corresponding APP_SECRET '6Nz4n0xA8s8qdxQf2GqurZj2Fs55FUvM'

Now it works with non Sonoff devices as well !

@skydiver
Copy link
Owner

Hello @MarioDBianchi

The app id and secret was provided by sonoff for this library.

The solution i can think, it's to add a new parameter to the class constructor where you can use a different set of parameters.

What do you think?

@ttz642
Copy link
Contributor

ttz642 commented Jun 2, 2020

On Sunday 31st May I noticed that everything stopped working with credential access problem to server. So I thought I'd update from ubuntu 18.04 to 20.04 & update to ewelink-api 2.0.0 to 3.0.0. Still nothing working still failing credentials when connecting to server, then some things started working on Monday evening.

I think there were either server issues or INTERNET issues.

Now Tue 2nd I'm finding the SonOff devices are working but not the KingArt light switches. If I use the android app all devices are usable, but from the ewelink-api getting the devices just returns the sonoff devices.

So I tried using the APP_ID & APP_SECRET as above and I can now see all the devices off the server. Initially couldn't control them but most things are working now.

Have a few bits to re-check from updating to ewelink-api 3.0.0

@ttz642 ttz642 mentioned this issue Jun 3, 2020
@gaim281
Copy link

gaim281 commented Jun 6, 2020

@MarioDBianchi @ttz642 please advice,
in nodejs how do i use APP_ID & APP_SECRET ? where i assign these params and where do i take the value of? i have non-sonoff 4ch realy board and i cannot see my devices in getDevices api.
thanks for help

@ttz642
Copy link
Contributor

ttz642 commented Jun 7, 2020

@MarioDBianchi @ttz642 please advice,
in nodejs how do i use APP_ID & APP_SECRET ? where i assign these params and where do i take the value of? i have non-sonoff 4ch realy board and i cannot see my devices in getDevices api.
thanks for help

If you on ewelink-api 3.0.0 there in node_modules/ewelink-api/src/data/constants.js

const APP_ID = 'oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq';
const APP_SECRET = '6Nz4n0xA8s8qdxQf2GqurZj2Fs55FUvM';

module.exports = {
  APP_ID,
  APP_SECRET,
};

@gaim281
Copy link

gaim281 commented Jun 7, 2020

@ttz642 Thanks alot.. works!!

@skydiver
Copy link
Owner

@ttz642 and @gaim281

the new app id and app secret where provided by ewelink for this library.

on version 4.0.0 i'm planning to add the option to specify your own set of id and secret.

@skydiver skydiver added the enhancement New feature or request label Jun 10, 2020
@skydiver
Copy link
Owner

@MarioDBianchi @ttz642 and @gaim281

this PR #93 allows to initialize class using custom APP_ID and APP_SECRET

const connection = new ewelink({
  email: 'YOUR EMAIL',
  password: 'YOUR PASSWORD',
  APP_ID: 'CUSTOM APP ID',
  APP_SECRET: 'CUSTOM APP SECRET',
});

const device = await connection.getDevice(deviceId);
console.log(device);

anyone can test this?

thank you

@MarioDBianchi
Copy link
Author

Thanks Martin, It worked as expected !!!

If I omit both APP_ID/APP_SECRET in the constructor it pulls only Sonoff devices following the former behavior, when I add the custom credentials, it start accessing all Sonoff and non Sonoff devices as expected.

The credentials used to show all kind of devices is:

APP_ID: 'oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq',
APP_SECRET: '6Nz4n0xA8s8qdxQf2GqurZj2Fs55FUvM',

Will do more testing during the weekend and post any new finding here.

Regards, Mario.

@lbenech
Copy link

lbenech commented Jul 10, 2020

Hello,

I also confirm that it works for non Sonoff devices with the APP_ID and APP_SECRET mentionned above.
For information, here is the board I used for the test: https://www.amazon.fr/gp/product/B07KD3ST9P/ref=ppx_yo_dt_b_asin_title_o04_s01?ie=UTF8&psc=1

Many thanks.

@rrojasn17
Copy link

@MarioDBianchi @ttz642 and @gaim281

this PR #93 allows to initialize class using custom APP_ID and APP_SECRET

const connection = new ewelink({
  email: 'YOUR EMAIL',
  password: 'YOUR PASSWORD',
  APP_ID: 'CUSTOM APP ID',
  APP_SECRET: 'CUSTOM APP SECRET',
});

const device = await connection.getDevice(deviceId);
console.log(device);

anyone can test this?

thank you

ESTO FUNCIONA!!!! ESTOY USANDO ewelink-api 3.1.1

@ChrisRahme
Copy link

APP_ID: 'oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq',
APP_SECRET: '6Nz4n0xA8s8qdxQf2GqurZj2Fs55FUvM',

Quick question... Why does this work for everyone? Aren't secrets supposed to be individual?

@alexose
Copy link

alexose commented Nov 23, 2022

I have also noticed missing devices in on my end (although not strictly non-Sonoff). This happens with every APP_ID and APP_SECRET I've tried, and seems to have started happening around 6+ months ago.

I took the liberty of poking around the Ewelink Android app and understanding exactly what was going on. Without getting into the weeds too much, it is 100% down to the of kind session that the login sequence initiates. If you log in with an 'old' id and secret, you can only see certain devices. If you log in using the same method that the Android app uses (presumably with a current id and secret) you get the full list.

No idea why they would set it up this way. Maybe they left the "old" login method for backwards compatibility and simply haven't maintained it. Or they're doing it on purpose to make life harder on us. Who knows.

Anyway, it may also be notable that the Android app uses many more parameters than this repo's getCredentials method does:

{"lang":"en","countryCode":"+1","email":"[email protected]","password":"password1234","imei":"1234567890abcdef","os":"Android","model":"sdk_gphone64_arm64_goldfish_arm64","romVersion":"13","appVersion":"4.26.3"}

vs.

{"countryCode":"+1","email":"[email protected]","password":"password1234"}

The whole login string gets hashed against the APP_SECRET, then the hash is included in the authorization header. I'm going to do a bit more research around how this works within the app. Will report back here with findings.

Edit: I was able to extract the new APP_ID and APP_SECRET out of the android app. Works great-- I can see all of my devices.

I don't think simply updating the default ID and secret is a good long-term fix, though. It feels like the better solution is to make folks sign up for their own keys via https://dev.ewelink.cc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants