DeebotUniverse / client.py

Deebot client library in python
https://deebot.readthedocs.io
GNU General Public License v3.0
26 stars 39 forks source link

In HA my X2 did'nt accept cleaning commands (rcp not support error) #492

Open Ulfmerbold2000 opened 2 months ago

Ulfmerbold2000 commented 2 months ago

Checks

The problem

Since Map generation works smoothly now i tried to program something in HA with my bot.

Poorly you can only command him to send his position and to return to station. Cleaning commands are fully ignored...vacuum only, mop and all other variants same negative result

This is far over my skills :/

On which deebot device (vacuum) you have the issue?

Deebot X2 Omni

Which version of the deebot-client are you using?

7.2.0

Country

de

Continent

eu

Anything in the logs that might be useful for us?

2024-05-12 08:37:38.802 DEBUG (MainThread) [deebot_client.authentication] Calling api(1/3): url=https://portal-eu.ecouser.net/api/iot/devmanager.do, params={'mid': 'lf3bn4', 'did': '310b014d-e138-4268-b4f2-eea7bc4bebfa', 'td': 'q', 'u': 'idqmao8ec939fa29', 'cv': '1.67.3', 't': 'a', 'av': '1.3.1'}, json={'cmdName': 'clean', 'payload': {'header': {'pri': '1', 'ts': 1715495858.802571, 'tzm': 480, 'ver': '0.0.50'}, 'body': {'data': {'act': 'start', 'type': 'auto'}}}, 'payloadType': 'j', 'td': 'q', 'toId': '310b014d-e138-4268-b4f2-eea7bc4bebfa', 'toRes': 'hOdT', 'toType': 'lf3bn4'}
2024-05-12 08:37:38.909 DEBUG (MainThread) [deebot_client.mqtt_client.client] Received PUBLISH (d0, q0, r0, m0), 'iot/p2p/clean/HelperMQClientId-awseu-sts-ngiot-mqsjmq-10/ecosys/1234/310b014d-e138-4268-b4f2-eea7bc4bebfa/lf3bn4/hOdT/q/GZz2/j', ...  (116 bytes)
2024-05-12 08:37:38.909 DEBUG (MainThread) [deebot_client.mqtt_client] Got message: topic=iot/p2p/clean/HelperMQClientId-awseu-sts-ngiot-mqsjmq-10/ecosys/1234/310b014d-e138-4268-b4f2-eea7bc4bebfa/lf3bn4/hOdT/q/GZz2/j, payload=b'{"header":{"pri":"1","ts":1715495858.802571,"tzm":480,"ver":"0.0.50"},"body":{"data":{"act":"start","type":"auto"}}}'
2024-05-12 08:37:38.910 DEBUG (MainThread) [deebot_client.mqtt_client] Command clean does not support p2p handling (yet)
2024-05-12 08:37:39.333 DEBUG (MainThread) [deebot_client.authentication] Success calling api url=https://portal-eu.ecouser.net/api/iot/devmanager.do, params={'mid': 'lf3bn4', 'did': '310b014d-e138-4268-b4f2-eea7bc4bebfa', 'td': 'q', 'u': 'idqmao8ec939fa29', 'cv': '1.67.3', 't': 'a', 'av': '1.3.1'}, json={'cmdName': 'clean', 'payload': {'header': {'pri': '1', 'ts': 1715495858.802571, 'tzm': 480, 'ver': '0.0.50'}, 'body': {'data': {'act': 'start', 'type': 'auto'}}}, 'payloadType': 'j', 'td': 'q', 'toId': '310b014d-e138-4268-b4f2-eea7bc4bebfa', 'toRes': 'hOdT', 'toType': 'lf3bn4'}, response={'ret': 'ok', 'resp': {'header': {'pri': 1, 'tzm': 120, 'ts': '1715495858673', 'ver': '0.0.1', 'fwVer': '1.76.0', 'hwVer': '0.1.1', 'wkVer': '0.1.54'}, 'body': {'code': 20003, 'msg': 'rcp not support'}}, 'id': 'GZz2', 'payloadType': 'j'}
2024-05-12 08:37:39.334 WARNING (MainThread) [deebot_client.commands.json.common] Command "clean" was not successfully. body={'code': 20003, 'msg': 'rcp not support'}

Additional information

This happens in automations and directly by the vacuum entity over the integration of Ecovacs

DieterKoblenz commented 4 weeks ago

I've finally had some time to enter the game using mitmproxy.

The ecovacs deebot x2 also uses clean_v2: This is where I clean three rooms:

POST https://api-ngiot.dc-eu.ww.ecouser.net/api/iot/endpoint/control?<redacted>&apn=clean_V2&fmt=j HTTP/2.0

{"body":{"data":{"act":"start","content":{"type":"freeClean","value":"1,0;1,1;1,2"}}},"header":{"channel":"Android","m":"request","pri":2,"reqid":"B5tzsN","ts":"1718695345068","tzm":120,"ver":"0.0.22"}}

And this is the stop command:

POST https://api-ngiot.dc-eu.ww.ecouser.net/api/iot/endpoint/control<redacted>l&apn=clean_V2&fmt=j HTTP/2.0

{"body":{"data":{"act":"stop"}},"header":{"channel":"Android","m":"request","pri":2,"reqid":"AcsiQj","ts":"1718695488122","tzm":120,"ver":"0.0.22"}}

https://github.com/home-assistant/core/issues/110177

This is the AI Intelligent Hosting command start: {"body":{"data":{"act":"start","content":{"type":"entrust"}}},"header":{"channel":"Android","m":"request","pri":2,"reqid":"QSxQGy","ts":"1718695963637","tzm":120,"ver":"0.0.22"}}

This is a single room vacuum only: {"body":{"data":{"act":"start","content":{"type":"freeClean","value":"1,0"}}},"header":{"channel":"Android","m":"request","pri":2,"reqid":"wRrYAR","ts":"1718696053617","tzm":120,"ver":"0.0.22"}}

edenhaus commented 4 weeks ago

Thanks, @DieterKoblenz for analyzing it :) Unfortunately, it looks like Ecovacs changed the API/endpoints again. Currently, we use the following endpoint https://portal-eu.ecouser.net/api/iot/devmanager.do and the command is in the payload

From your analysis, it looks like there is a new endpoint https://api-ngiot.dc-eu.ww.ecouser.net/api/iot/endpoint/control and we need to pass the command as query param.

If <redacted> was the token, then also the authentication has changed, and there is a lot more analysis needed.

sebcbien37 commented 3 weeks ago

Hi, do you need help ? I don't know if I can help you, but I can try !

edenhaus commented 3 weeks ago

Help is always welcome :) I don't have the model so I can't analyze the traffic between the app and the ecovacs servers

sebcbien37 commented 3 weeks ago

Click on start

{"body":{"data":{"act":"start","content":{"type":"freeClean","value":"1,4;1,1"}}},"header":{"channel":"iOS","reqid":"QwYzgr","ts":"1719048898865","ver":"0.0.50","m":"request","pri":1,"tzm":120}}

{ "auth": { "realm": "ecouser.net", "resource": "IOS581F4F7G8", "token": "XXX", "userid": "XXXX", "with": "users" }, "channel": "c_appstore", "country": "FR", "defaultLang": "en", "device": { "did": "018348f0-6893-457b-ad08-87946a9f64c5", "mid": "lf3bn4", "res": "2TWb", "sn": "XXXX" }, "et1": "1719048899263", "lang": "FR", "location": [ "nps_pop" ], "reqid": "FPFfHp2y", "tags": [ "lf3bn4" ], "uid": "idzlodae8a187147", "version": "v2" }

{"body":{"data":{}},"header":{"channel":"iOS","reqid":"FTOgIf","ts":"1719048899656","ver":"0.0.50","m":"request","pri":1,"tzm":120}}

Click on Pause

{"body":{"data":{"act":"pause"}},"header":{"channel":"iOS","reqid":"CdnAiV","ts":"1719048925959","ver":"0.0.50","m":"request","pri":1,"tzm":120}}

{"body":{"data":{}},"header":{"channel":"iOS","reqid":"sOyGAR","ts":"1719048927244","ver":"0.0.50","m":"request","pri":1,"tzm":120}}

Click on return

{"body":{"data":{"act":"go"}},"header":{"channel":"iOS","reqid":"NIibkB","ts":"1719048977092","ver":"0.0.50","m":"request","pri":1,"tzm":120}}

{"body":{"data":{}},"header":{"channel":"iOS","reqid":"qRFhIv","ts":"1719048978161","ver":"0.0.50","m":"request","pri":1,"tzm":120}}

Click on stop

{"body":{"data":{"act":"stop"}},"header":{"channel":"iOS","reqid":"ZtTdIw","ts":"1719048953531","ver":"0.0.50","m":"request","pri":1,"tzm":120}}

sebcbien37 commented 3 weeks ago

@edenhaus , I can send you all saved messages in private. I can't do more, It's beyond my skills.

edenhaus commented 3 weeks ago

I'm currently short on time for the next month at least. So if someone will step in, feel free to do it