-
Notifications
You must be signed in to change notification settings - Fork 108
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
eweLink has made some changes last week. API needs updating #21
Comments
Hello @primalnow All tests has passed. Did a few manual tests and get expected results on:
Where did you see these changes? Any link to investigate? Thanks.- |
Changes were discussed here: peterbuga/HASS-sonoff-ewelink#162 My server is 'as' If I don't do the "(async () => ", I get "SyntaxError: await is only valid in async function" Websocket is working fine. But other commands give a '400' `
})();` Output:
|
Hey @primalnow I can't reproduce your error, everything works fine to me. Which device are you using? I've tested with this device and i was able to turn on/off, get power consumption. Thanks.- |
I have all kinds of devices. More than 70. I tried with a few. None work.
…On Sat, Oct 19, 2019, 4:49 AM Martin M. ***@***.***> wrote:
Hey @primalnow <https://github.com/primalnow>
I can't reproduce your error, everything works fine to me.
Which device are you using?
From the link you posted, i see there are errors with a Sonoff POW R2.
I've tested with this device and i was able to turn on/off, get power
consumption.
Thanks.-
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#21?email_source=notifications&email_token=AGHTZ7NCOVWCEABSXJULLQTQPJDOVA5CNFSM4JBO7N22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBWPK7Q#issuecomment-544011646>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGHTZ7L3BBHZGBVFOIIIU43QPJDOVANCNFSM4JBO7N2Q>
.
|
Good afternoon.
Using Email and password - works
|
yes I also saw the issues. what I am able to do is to getdevices. You can do it by updating the following parameter under node-modules/ewelink-api/mixins/devices/getDevicesMixin.js , `const getDevicesMixin = {
// nounce : '' + nonce(),
}, module.exports=getDevicesMixin; |
Thanks @murtaza9000 that worked for me, to getDevices.
|
Hello @murtaza9000 and @sanketmehta7 Do you wanna make a PR so we can add these changes? Thanks.- |
Thanks for the update. But the error persists. At least for the CN/AS server. |
I can make PR...also issue with other apis still remains (having added same param to them), I couldn't get getDevice & toggleState (ws api) working...just able to get above devices list only. Any one tried mix of param with success can help with those remaining api params...Also any body know how to reverse proxy api calls from the app itself, to debug req/res data. I tried Charles proxy but not able to decode ssl url data. |
Hey @sanketmehta7 This is strange because i cannot reproduce any of those errors. Tests are passing successfully. Can you try to run Also, which region are you using? |
Actually true, I was only able to make it work with getdevices. Not with other. Yes @skydiver you may do PR at least for this. But any luck for other apis @sanketmehta7 . And are you have session out issue from the application "ewelink"? |
Guys, i've created a new branch There is a new method, This can be tested on this way:
Thanks |
Hi @skydiver , So, getDeviceAlt is working fine but setDevicePowerState is giving me the error: const status = await connection.setDevicePowerState('device id', 'on'); Once I update setDevicePowerStateMixin.js line 17 : to const device = await this.getDeviceAlt(deviceId); It fixed. |
Hey @murtaza9000 Thanks for the feedback. I've updated If everything works fine, we can replace the original |
Hi @skydiver, Can you check this? By the way, do you have any other docs about ewelink-api? im reading Thanks |
Hi @skydiver . Its fine working perfect. |
Hello everyone: This PR tries to solve errors reported on this thread: https://github.com/skydiver/ewelink-api/pull/26/files
Will be great if we can get someone else who can test and confirm is working. Thanks.- |
@skydiver I'm using the current version without any of the patches... I had the same problem trying to use ewelink-api with alternative access method using apikey, I noticed the response returned the region as the us, I'm in the EU. with code: I get:
If I add the region to the new connection, ie: I get: And everything works OK ! -- |
Problem persists: connection eWeLink { devices { error: 400, msg: 'params incomplete' } |
If your using the login method you don't need the at or apiKey. See comment below on use of region during login. I'd actually keep region for all connections, seems to influence which server is used and consequently access & speed. |
Hey @primalnow Does the |
I didn't need to use the branch, just used the stock 1.8.0 |
Input: `const ewelink = require('ewelink-api'); (async () => { const connection = new ewelink({
/* get all devices */ /* get specific devide info */ /* toggle device */ })(); Output: MacBook-Pro:ewelink-node faisal$ node test.js ` |
Everyone: The region parameter is required for everyone who is not using US servers, so, this is how you need to initialize the class:
More context: when using email and password with the wrong region (default is us), the login request fails, and performs a second login request with the right region. So, not using region parameter is possible with email/password but not recommended since adds a few extra seconds to login because takes 2 api requests. When using access token without region will fail with an error 400/401, so, in this scenario you MUST provide your region. I believe the changes on |
MacBook-Pro:ewelink-node faisal$ npm list Input:const ewelink = require('ewelink-api'); (async () => { const connection = new ewelink({ console.log('connection' , connection); /* get all devices */ /* get specific devide info */ /* toggle device */ })(); OutputMacBook-Pro:ewelink-node faisal$ node test.js |
Serverless - Copied from https://ewelink-api.now.sh/docs/demos/serverless INPUTconst connection = new ewelink({ const login = await connection.login(); const accessToken = login.at; const newConnection = new ewelink({ const thirdConnection = new ewelink({ const anotherNewConnection = new ewelink({ OUTPUTMacBook-Pro:ewelink-node faisal$ node test-serverless.js SyntaxError: await is only valid in async function |
NODE SCRIPT - copied from https://ewelink-api.now.sh/docs/demos/node INPUTconst ewelink = require('ewelink-api'); (async () => { const connection = new ewelink({ const login = await connection.login(); console.log('connection' , connection); /* get all devices */ /* get specific devide info */ /* toggle device */ })(); OUTPUTMacBook-Pro:ewelink-node faisal$ node test.js |
I'll have a proper look tomorrow, but a few observations inline bold and I've deleted a lot of code and replaced with . . .
Should you use "as" as the region as that is reported later on suggesting that's where you were registered.
connection.getDevice(''); MUST include a device id, eg 0123456789
server has reported you as being in region as
|
fix for |
Don't think you need any fixes, Release 1.8.0 & 1.8.1 work fine provided region is correctly set and no missing code. |
asian users keep getting bumped between |
I'm using 1.8.1 and having the same issue ( |
In release 1.8.1, getDevicesMixin.js only have 2 params (lang and getTags) |
@ferryariawan 1.8.1 just includes a new method called |
I get the getDevices to work after adding this to getDevicesMixin |
@ferryariawan just released 1.8.2 who includes these changes |
@peterbuga Thanks for jumping in :) @skydiver Thanks for all your hard work. getDevices is working perfectly now. However, nothing else is. ` getDevicePowerState { error: 'params is incomplete', msg: 'Device does not exist' } getDeviceCurrentTH { code: 400, error: 'params is incomplete' } getDeviceChannelCount { error: 'params is incomplete', msg: 'Device does not exist' } getDevice { code: 400, error: 'params is incomplete' } toggleDevice { error: 'params is incomplete', msg: 'Device does not exist' } ` |
@skydiver if you like I can share a few devices with you. Not sure if that would work. If you're willing to do it with me in real time, I can give you access to my ewelink account. |
After you have have done the Class Instantiation the connection has the region associated with the account, I think, can somebody having a problem with region try this?
should now contain the region required by subsequent methods. |
@ttz642 The latest update has fixed getDevices. It's the rest of the functions that are still not working. |
when adding the new params to the |
@peterbuga I tried with the exact device ID, returned by the getDevices command. I did not rely on the ID's in the app :-) You know I'm thorough. :) |
hey @peterbuga i believe we already did this change on PR #26 on this file Didn't merged yet because i'm not sure if it was really necessary or just by always using region was enough |
I've merged I'm gonna wait after some feedback before relesing 1.9.0 to npm. Hope this fixes everyone problems 🤞 ... and remember to keep using region when initializing the class. |
As of last week, ewelink made some changes in how it sends data. I don't know of the changes, but I do know that there were some changes. A similar problem was faced with the SONOFF API for homeassistant.
I would really appreciate if you can update this API to reflect the changes.
As for now,
The login with email/password - OK.
Login with accesstoken/apikiey - FAIL
Listening to the websocket (https://ewelink-api.now.sh/docs/available-methods/openwebsocket) - OK
getDevices - FAIL
ToggleDevice - FAIL
I haven't tested rest of the commands, since I just started using the API today.
Would really appreciate your attention. Thanks.
-Faisal Qureshi
Some error logs:
all devices { error: 400, msg: 'params incomplete' }
a device { code: 400, error: 'params is incomplete' }
Trying to use the accesstoken:
login details -> { error: 400, msg: 'Authentication error' }
devices { error: 401, msg: 'Authentication error' }
The text was updated successfully, but these errors were encountered: