Ligio / hacc-ozmo

Home Assistant Custom Component for Ecovacs Deebot Ozmo 900
MIT License
63 stars 31 forks source link

Yeedi Vacums Unsupported, but possibly could with slight changes #38

Open nfacha opened 2 years ago

nfacha commented 2 years ago

After running some MIM it appears the only thing that changes is the format of the URL it calls, instead of being like: https://eco-{country}-api.ecovacs.com/v1/private/{country}/{lang}/{deviceId}/{appCode}/{appVersion}/{channel}/{deviceType} Should be something like https://gl-pt-api.yeedi.com/v1/private/PT/..........

The rest of the API structure looks ti be the same.

Im able to provide MIM traffic on a device for testing if needed

mrbungle64 commented 2 years ago

@nfacha

Are you interested in using a Node.js library to check if your hypothesis is correct? I would give you instructions on how to test it.

nfacha commented 2 years ago

@nfacha

Are you interested in using a Node.js library to check if your hypothesis is correct? I would give you instructions on how to test it.

I can give it a try yes 😊

mrbungle64 commented 2 years ago

@nfacha, that's great 👍🏻

git clone https://github.com/mrbungle64/ecovacs-deebot.js.git
cd ecovacs-deebot.js
git checkout 'alpha/0.8.3'
npm install

Follow the setup instructions

After that, please add "yeedi.com" as a domain in the settings file:

exports.AUTH_DOMAIN = 'yeedi.com';

Then you can test it 😃

cd example
node ./app2.js

If it's working you can try out some other shortcut functions

mrbungle64 commented 2 years ago

@nfacha

You can maybe "tweak" the config of the model you are using by editing this file. I have pre-populated the values for the yeedi models to the best of my knowledge 😉

Most important are "950type" and "950type_V2". I would guess that most yeedi models are "950type", but not "950type_V2". But I could also be wrong about that.

If you want to try out "950type_V2" you also have to set "950type" to true.

nfacha commented 2 years ago

@nfacha, that's great 👍🏻

git clone https://github.com/mrbungle64/ecovacs-deebot.js.git
cd ecovacs-deebot.js
git checkout 'alpha/0.8.3'
npm install

Follow the setup instructions

After that, please add "yeedi.com" as a domain in the settings file:

exports.AUTH_DOMAIN = 'yeedi.com';

Then you can test it smiley

cd example
node ./app2.js

If it's working you can try out some other shortcut functions

Is there any way to log requests/responses/a debug mode? Im getting invalid authentication errors

mrbungle64 commented 2 years ago

@nfacha

Is there any way to log requests/responses/a debug mode? Im getting invalid authentication errors

NODE_ENV=dev node ./app2.js
nfacha commented 2 years ago
[EcoVacsAPI] callUserAuthApi data: {"code":"0002","msg":"Parameter error. Please try again later.","time":1653843063598}
[EcoVacsAPI] callUserAuthApi error: Error: Failure code 0002: Parameter error. Please try again later.
Failure in connecting: Failure code 0002: Parameter error. Please try again later.

@mrbungle64

mrbungle64 commented 2 years ago

@nfacha

I guess that this and this is different for yeedi.

Im able to provide MIM traffic on a device for testing if needed

Can you please try to get that information?

nfacha commented 2 years ago

@nfacha

I guess that this and this is different for yeedi.

Im able to provide MIM traffic on a device for testing if needed

Can you please try to get that information?

Is the login supposed to be a GET request? :thinking: image

(Covered some parts as I'm not sure what is the auth credentias, would assume the token)

nfacha commented 2 years ago

@nfacha

I guess that this and this is different for yeedi.

Im able to provide MIM traffic on a device for testing if needed

Can you please try to get that information?

Or most likely this: image

mrbungle64 commented 2 years ago

@nfacha

Is the login supposed to be a GET request? thinking

Yes

Or most likely this:

Thanks for the information. I'll directly try to implement the different parameters.

mrbungle64 commented 2 years ago

@nfacha

Can you find an URL with the parameters "bizType" and "openId"?

mrbungle64 commented 2 years ago

@nfacha

I just pushed a commit with some changes. Can you please try again?

mrbungle64 commented 2 years ago

@nfacha

Can you find an URL with the parameters "bizType" and "openId"?

In the case of Ecovacs it's bizType=ECOVACS_IOT and openId=global.

We also need the values of the "authAppkey" parameter (you covered them in the screenshots). See "AUTH_USERLOGIN_AUTH_APPKEY" and "AUTH_GETAUTH_AUTH_APPKEY" https://github.com/mrbungle64/ecovacs-deebot.js/blob/alpha/0.8.3/library/ecovacsConstants.js

We may also need the values of "AUTH_USERLOGIN_SECRET" and "AUTH_GETAUTH_SECRET" for yeedi. But maybe the existing ones will work also.

nfacha commented 2 years ago

@nfacha

Can you find an URL with the parameters "bizType" and "openId"?

In the case of Ecovacs it's bizType=ECOVACS_IOT and openId=global.

We also need the values of the "authAppkey" parameter (you covered them in the screenshots). See "AUTH_USERLOGIN_AUTH_APPKEY" and "AUTH_GETAUTH_AUTH_APPKEY" https://github.com/mrbungle64/ecovacs-deebot.js/blob/alpha/0.8.3/library/ecovacsConstants.js

We may also need the values of "AUTH_USERLOGIN_SECRET" and "AUTH_GETAUTH_SECRET" for yeedi. But maybe the existing ones will work also.

authAppkey=1581917520081

mrbungle64 commented 2 years ago

@nfacha

authAppkey=1581917520081

In both cases? For the Ecovacs API there are 2 different keys

nfacha commented 2 years ago

@nfacha

authAppkey=1581917520081

In both cases? For the Ecovacs API there are 2 different keys

On the login request it should be 1581917520081 and on getAuthCode request (nearest thing I found, is this it?) is 1581923437995

bizType is indeed ECOVACS_IOT, the openId one where should it be?

mrbungle64 commented 2 years ago

@nfacha

authAppkey=1581917520081

In both cases? For the Ecovacs API there are 2 different keys

On the login request it should be 1581917520081 and on getAuthCode request (nearest thing I found, is this it?) is 1581923437995

👍🏻

bizType is indeed ECOVACS_IOT, the openId one where should it be?

Should be in the same request

nfacha commented 2 years ago

@nfacha

authAppkey=1581917520081

In both cases? For the Ecovacs API there are 2 different keys

On the login request it should be 1581917520081 and on getAuthCode request (nearest thing I found, is this it?) is 1581923437995

👍🏻

bizType is indeed ECOVACS_IOT, the openId one where should it be?

Should be in the same request

`> > > @nfacha

authAppkey=1581917520081

In both cases? For the Ecovacs API there are 2 different keys

On the login request it should be 1581917520081 and on getAuthCode request (nearest thing I found, is this it?) is 1581923437995

👍🏻

bizType is indeed ECOVACS_IOT, the openId one where should it be?

Should be in the same request

https://gl-pt-openapi.yeedi.com/v1/global/auth/getAuthCode?uid=20210301214027_55dbeb47a9721b912f12b41d55991b6c&accessToken=xxxx&bizType=ECOVACS_IOT&deviceId=dff74ff9b5a7986542d804b760b572ae&authTimespan=1653928378194&authAppkey=1581923437995&authSign=59c0b51ddf08d5b9e763f84036a06ade

I don't see it here

EDIT: Oh, its the one on the path?

mrbungle64 commented 2 years ago

@nfacha

I just pushed a commit with the keys you just gave me. Can you please try again if the login is working now

nfacha commented 2 years ago

@nfacha

I just pushed a commit with the keys you just gave me. Can you please try again if the login is working now

[EcovacsAPI] Setting up EcovacsAPI instance [EcovacsAPI] Calling main api user/login with {"account":"xxx@gmail.com","password":"xxx"} [EcoVacsAPI] callUserAuthApi calling https://gl-pt-api.yeedi.com/v1/private/PT/EN/5ca2b856b967af070b57e6dc87d57cd5/yd_global_e/1.3.0/google_play/1/user/login [EcoVacsAPI] callUserAuthApi config account=xxx%40gmail.com&password=xxx&authTimespan=1653934449729&requestId=7233e5e0401e6ac33a19812dc1b381cd&authTimeZone=GMT-8&authAppkey=1581917520081&authSign=af81f0aff1d29698915968419feab1cc [EcoVacsAPI] callUserAuthApi data: {"code":"0002","msg":"Parameter error. Please try again later.","time":1653934449954} [EcoVacsAPI] callUserAuthApi error: Error: Failure code 0002: Parameter error. Please try again later. Failure in connecting: Failure code 0002: Parameter error. Please try again later.

The URL for the MIM equivalent is:

https://gl-pt-api.yeedi.com/v1/private/PT/EN/aaa74921d5424848899fd3581115d58f/yd_global_e/1.3.0/google_play/1/user/login

The parameter after the EN is different, could it be it?

mrbungle64 commented 2 years ago

@nfacha

Do you mean aaa74921d5424848899fd3581115d58f?

This is a md5 hash of a deviceId generated by the node-machine-id module.

mrbungle64 commented 2 years ago

@nfacha

But you can try if it works if you hardcode it here

const deviceId = 'aaa74921d5424848899fd3581115d58f';
nfacha commented 2 years ago

@nfacha

But you can try if it works if you hardcode it here

const deviceId = 'aaa74921d5424848899fd3581115d58f';

Nope, looks like its not it, from the other params I only see the authSign, timezone and timestamp changing, my app payload: account=xxx%40gmail.com&password=xxx&requestId=dd2a05a814c374a50e3d17e948784992&authTimespan=1653934710730&authTimeZone=GMT-0&authAppkey=1581917520081&authSign=ed46aa4e478c7a65546f3f9f8a4bc0c9

mrbungle64 commented 2 years ago

@nfacha

Is this URL also still the same when you use the modfied app2.js? https://gl-pt-api.yeedi.com/v1/private/PT/EN/aaa74921d5424848899fd3581115d58f/yd_global_e/1.3.0/google_play/1/user/login

nfacha commented 2 years ago

@nfacha

Is this URL also still the same when you use the modfied app2.js? https://gl-pt-api.yeedi.com/v1/private/PT/EN/aaa74921d5424848899fd3581115d58f/yd_global_e/1.3.0/google_play/1/user/login

Yeah it is, this is the full request of a working authentication from the app:

https://gl-pt-api.yeedi.com/v1/private/PT/EN/aaa74921d5424848899fd3581115d58f/yd_global_e/1.3.0/google_play/1/user/login?account=xxxx&password=xxxx&requestId=dd2a05a814c374a50e3d17e948784992&authTimespan=1653934710730&authTimeZone=GMT-0&authAppkey=1581917520081&authSign=ed46aa4e478c7a65546f3f9f8a4bc0c9

mrbungle64 commented 2 years ago

@nfacha

Can you please post the current URL from app2.js?

nfacha commented 2 years ago

@nfacha

Can you please post the current URL from app2.js?

This?

[EcoVacsAPI] callUserAuthApi calling https://gl-pt-api.yeedi.com/v1/private/PT/EN/aaa74921d5424848899fd3581115d58f/yd_global_e/1.3.0/google_play/1/user/login [EcoVacsAPI] callUserAuthApi config account=xxxx&password=xxxx&authTimespan=1653936921141&requestId=a861650ba190171f3e31e9e802ad57ff&authTimeZone=GMT-8&authAppkey=1581917520081&authSign=726ce1aac2d7a8feb534328af42b6d1a

mrbungle64 commented 2 years ago

@nfacha

Yeah it is, this is the full request of a working authentication from the app:

Yes, but sorry this was my fault. I thought you meant the yeedi Mobile App 😉

mrbungle64 commented 2 years ago

@nfacha Can you please post the current URL from app2.js?

This?

[EcoVacsAPI] callUserAuthApi calling https://gl-pt-api.yeedi.com/v1/private/PT/EN/aaa74921d5424848899fd3581115d58f/yd_global_e/1.3.0/google_play/1/user/login [EcoVacsAPI] callUserAuthApi config account=xxxx&password=xxxx&authTimespan=1653936921141&requestId=a861650ba190171f3e31e9e802ad57ff&authTimeZone=GMT-8&authAppkey=1581917520081&authSign=726ce1aac2d7a8feb534328af42b6d1a

So I think it's now using the correct hash (aaa74921d5424848899fd3581115d58f), right?

nfacha commented 2 years ago

The URL on this comment ( https://github.com/Ligio/hacc-ozmo/issues/38#issuecomment-1141412636 ) is a valid, working auth request from the mobile app

@nfacha Can you please post the current URL from app2.js?

This? [EcoVacsAPI] callUserAuthApi calling https://gl-pt-api.yeedi.com/v1/private/PT/EN/aaa74921d5424848899fd3581115d58f/yd_global_e/1.3.0/google_play/1/user/login [EcoVacsAPI] callUserAuthApi config account=xxxx&password=xxxx&authTimespan=1653936921141&requestId=a861650ba190171f3e31e9e802ad57ff&authTimeZone=GMT-8&authAppkey=1581917520081&authSign=726ce1aac2d7a8feb534328af42b6d1a

So I think it's now using the correct hash (aaa74921d5424848899fd3581115d58f), right?

Yeah, its hardcoded as you instructed to what the app was using

mrbungle64 commented 2 years ago

@nfacha

ok, I still think that we need to find out this:

We may also need the values of "AUTH_USERLOGIN_SECRET" and "AUTH_GETAUTH_SECRET" for yeedi.

See https://github.com/mrbungle64/ecovacs-deebot.js/blob/alpha/0.8.3/library/ecovacsConstants.js

It's used to generate a md5 hash for the authSign parameter.

mrbungle64 commented 2 years ago

@nfacha

Do you have the ability to decompile the yeedi mobile app?

mrbungle64 commented 2 years ago

@nfacha

I already found the values 😉 Please checkout the branch again and use the unmodified version to test it.

nfacha commented 2 years ago

@nfacha

I already found the values wink Please checkout the branch again and use the unmodified version to test it.

Still getting Parameter error. Please try again later using the unmodified updated version

mrbungle64 commented 2 years ago

@nfacha

Please try if it's working if you swap the values:

exports.AUTH_USERLOGIN_SECRET_YD = '304a71592690995b2bb304e66b5ddee6';
exports.AUTH_USERLOGIN_AUTH_APPKEY_YD = '1581923437995';

...
exports.AUTH_GETAUTH_SECRET_YD = '952811748462c05cac2a9b4453489216';
exports.AUTH_GETAUTH_AUTH_APPKEY_YD = '1581666897411';
nfacha commented 2 years ago

@nfacha

Please try if it's working if you swap the values:

exports.AUTH_USERLOGIN_SECRET_YD = '304a71592690995b2bb304e66b5ddee6';
exports.AUTH_USERLOGIN_AUTH_APPKEY_YD = '1581923437995';

...
exports.AUTH_GETAUTH_SECRET_YD = '952811748462c05cac2a9b4453489216';
exports.AUTH_GETAUTH_AUTH_APPKEY_YD = '1581666897411';

Assuming this were to be added on the settings file (added, not replaced as they were not there) the error persists

mrbungle64 commented 2 years ago

@nfacha Please try if it's working if you swap the values:

exports.AUTH_USERLOGIN_SECRET_YD = '304a71592690995b2bb304e66b5ddee6';
exports.AUTH_USERLOGIN_AUTH_APPKEY_YD = '1581923437995';

...
exports.AUTH_GETAUTH_SECRET_YD = '952811748462c05cac2a9b4453489216';
exports.AUTH_GETAUTH_AUTH_APPKEY_YD = '1581666897411';

Assuming this were to be added on the settings file (added, not replaced as they were not there) the error persists

@nfacha You have to replace it in library/ecovacsConstants.js: https://github.com/mrbungle64/ecovacs-deebot.js/blob/alpha/0.8.3/library/ecovacsConstants.js

nfacha commented 2 years ago
exports.AUTH_USERLOGIN_SECRET_YD = '304a71592690995b2bb304e66b5ddee6';
exports.AUTH_USERLOGIN_AUTH_APPKEY_YD = '1581923437995';

Still get the same parameters error

mrbungle64 commented 2 years ago

@nfacha

I just pushed another commit with different keys ... Please checkout the branch again and try again 😉

nfacha commented 2 years ago

@nfacha

I just pushed another commit with different keys ... Please checkout the branch again and try again wink

Login works \o/

Now it is returning some 404 after the login:

[EcovacsAPI] Setting up EcovacsAPI instance
[EcovacsAPI] Calling main api user/login with {"account":"xxx@gmail.com","password":"xxx"}
[EcoVacsAPI] callUserAuthApi calling https://gl-pt-api.yeedi.com/v1/private/PT/EN/5ca2b856b967af070b57e6dc87d57cd5/yd_global_e/1.3.0/google_play/1/user/login
[EcoVacsAPI] callUserAuthApi config account=xxx%40gmail.com&password=xxx&authTimespan=1654074879011&requestId=dea13c3bca55e91d48fe42d5d05a04e3&authTimeZone=GMT-8&authAppkey=1581917520081&authSign=6b54e85b0c4492cb1399d15cf6023286
[EcoVacsAPI] callUserAuthApi data: {"code":"0000","msg":"操作成功","time":1654074879643,"data":{"uid":"xxx","accessToken":"xxx","userName":"xxx","email":"xxx@gmail.com","mobile":null,"loginName":"xxx@gmail.com","ucUid":"xxx"},"success":true}
[EcovacsAPI] Calling main api user/getAuthCode with {"uid":"xxx","accessToken":"xxx"}
[EcoVacsAPI] callUserAuthApi calling https://gl-pt-openapi.yeedi.com/v1/agreement/getUserAcceptInfo
[EcoVacsAPI] callUserAuthApi config uid=xxxxxx&accessToken=xxxxx&authTimespan=1654074879860&bizType=ECOVACS_IOT&deviceId=xxxx&openId=global&authAppkey=1581923437995&authSign=49801605daf2a0543fb0797211077af6
[EcoVacsAPI] callUserAuthApi error: AxiosError: Request failed with status code 404
mrbungle64 commented 2 years ago

@nfacha

@nfacha I just pushed another commit with different keys ... Please checkout the branch again and try again wink

Login works \o/

That's great 👍🏻

Now it is returning some 404 after the login:

[EcovacsAPI] Setting up EcovacsAPI instance
[EcovacsAPI] Calling main api user/login with {"account":"xxx@gmail.com","password":"xxx"}
[EcoVacsAPI] callUserAuthApi calling https://gl-pt-api.yeedi.com/v1/private/PT/EN/5ca2b856b967af070b57e6dc87d57cd5/yd_global_e/1.3.0/google_play/1/user/login
[EcoVacsAPI] callUserAuthApi config account=xxx%40gmail.com&password=xxx&authTimespan=1654074879011&requestId=dea13c3bca55e91d48fe42d5d05a04e3&authTimeZone=GMT-8&authAppkey=1581917520081&authSign=6b54e85b0c4492cb1399d15cf6023286
[EcoVacsAPI] callUserAuthApi data: {"code":"0000","msg":"操作成功","time":1654074879643,"data":{"uid":"xxx","accessToken":"xxx","userName":"xxx","email":"xxx@gmail.com","mobile":null,"loginName":"xxx@gmail.com","ucUid":"xxx"},"success":true}
[EcovacsAPI] Calling main api user/getAuthCode with {"uid":"xxx","accessToken":"xxx"}
[EcoVacsAPI] callUserAuthApi calling https://gl-pt-openapi.yeedi.com/v1/agreement/getUserAcceptInfo
[EcoVacsAPI] callUserAuthApi config uid=xxxxxx&accessToken=xxxxx&authTimespan=1654074879860&bizType=ECOVACS_IOT&deviceId=xxxx&openId=global&authAppkey=1581923437995&authSign=49801605daf2a0543fb0797211077af6
[EcoVacsAPI] callUserAuthApi error: AxiosError: Request failed with status code 404

Please change the following in library/ecovacsConstants.js from

exports.GLOBAL_GETAUTHCODE_PATH = 'global/auth/getAuthCode';
exports.GLOBAL_GETAUTHCODE_PATH_YD = 'agreement/getUserAcceptInfo';

to

exports.GLOBAL_GETAUTHCODE_PATH = 'global/auth/getAuthCode';
exports.GLOBAL_GETAUTHCODE_PATH_YD = 'global/auth/getAuthCode';

The values should be the same now.

nfacha commented 2 years ago
exports.GLOBAL_GETAUTHCODE_PATH = 'global/auth/getAuthCode';
exports.GLOBAL_GETAUTHCODE_PATH_YD = 'global/auth/getAuthCode';
[EcoVacsAPI] callUserAuthApi calling https://gl-pt-openapi.yeedi.com/v1/global/auth/getAuthCode
[EcoVacsAPI] callUserAuthApi config uid=20210301214027_55dbeb47a9721b912f12b41d55991b6c&accessToken=xxx&authTimespan=1654102787629&bizType=ECOVACS_IOT&deviceId=5ca2b856b967af070b57e6dc87d57cd5&openId=global&authAppkey=1581923437995&authSign=5cdee36fb1b2c30a94e94b4cd415df0b
[EcoVacsAPI] callUserAuthApi data: {"code":"0002","msg":"接口鉴权失败","time":1654102788330}
[EcoVacsAPI] callUserAuthApi error: Error: Failure code 0002: 接口鉴权失败
Failure in connecting: Failure code 0002: 接口鉴权失败

Interface authentication failed according to google translate

mrbungle64 commented 2 years ago
exports.GLOBAL_GETAUTHCODE_PATH = 'global/auth/getAuthCode';
exports.GLOBAL_GETAUTHCODE_PATH_YD = 'global/auth/getAuthCode';
[EcoVacsAPI] callUserAuthApi calling https://gl-pt-openapi.yeedi.com/v1/global/auth/getAuthCode
[EcoVacsAPI] callUserAuthApi config uid=20210301214027_55dbeb47a9721b912f12b41d55991b6c&accessToken=xxx&authTimespan=1654102787629&bizType=ECOVACS_IOT&deviceId=5ca2b856b967af070b57e6dc87d57cd5&openId=global&authAppkey=1581923437995&authSign=5cdee36fb1b2c30a94e94b4cd415df0b
[EcoVacsAPI] callUserAuthApi data: {"code":"0002","msg":"接口鉴权失败","time":1654102788330}
[EcoVacsAPI] callUserAuthApi error: Error: Failure code 0002: 接口鉴权失败
Failure in connecting: Failure code 0002: 接口鉴权失败

Interface authentication failed according to google translate

@nfacha Please try again. It is possible that this is just a temporary error.

mrbungle64 commented 2 years ago

@nfacha

I found out that the org is also different (ECOWW vs. ECOYDWW). Please checkout the branch again and try again 😉

mrbungle64 commented 2 years ago

@nfacha

I found out that the org is also different (ECOWW vs. ECOYDWW). Please checkout the branch again and try again wink

@nfacha Can you please give me some feedback?

nfacha commented 2 years ago

@nfacha

I found out that the org is also different (ECOWW vs. ECOYDWW). Please checkout the branch again and try again wink

@nfacha Can you please give me some feedback?

Not at a computer atm, will provide feedback in a couple hours 😊

mrbungle64 commented 2 years ago

@nfacha

I have already received feedback from another user.

I need to further analyze where other differences are between the two APIs. I'll get back to you when I find out something.

nfacha commented 2 years ago

@nfacha

I have already received feedback from another user.

I need to further analyze where other differences are between the two APIs. I'll get back to you when I find out something.

Sure :) Let me know if you need anything in the meantime

mrbungle64 commented 2 years ago

@nfacha I have already received feedback from another user. I need to further analyze where other differences are between the two APIs. I'll get back to you when I find out something.

Sure :) Let me know if you need anything in the meantime

@nfacha

ok, you can check some things 😃