ewelink-api
ewelink-api copied to clipboard
Cannot access non Sonoff devices
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.
PS: got it working.... needed the corresponding APP_SECRET '6Nz4n0xA8s8qdxQf2GqurZj2Fs55FUvM'
Now it works with non Sonoff devices as well !
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?
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
@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
@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,
};
@ttz642 Thanks alot.. works!!
@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.
@MarioDBianchi @ttz642 and @gaim281
this PR https://github.com/skydiver/ewelink-api/pull/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
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.
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.
@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
APP_ID: 'oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq', APP_SECRET: '6Nz4n0xA8s8qdxQf2GqurZj2Fs55FUvM',
Quick question... Why does this work for everyone? Aren't secrets supposed to be individual?
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.