part4 - ecovacs Writing a python script
ecovacs-part4
Table of Contents
python3 --version
Python 3.11.2
sudo apt-get update
apt-get install python3-pip
ha docker 2026.2.1
docker exec -it ha sh
cd /usr/local/lib/python3.13/site-packages/deebot_client/hardware/
step 1.first copy p1jij8.py and rename as n0vyif.py within deebot_client/hardware/deebot/
cp lr4qcs.py mxse7w.py
step 2.Writing a python script using CleanV2 instructs the robovac to start cleaning.
import aiohttp
import asyncio
import logging
import time
from deebot_client.api_client import ApiClient
from deebot_client.authentication import Authenticator, create_rest_config
from deebot_client.commands.json.clean import CleanAction, CleanV2
from deebot_client.events import BatteryEvent
from deebot_client.mqtt_client import MqttClient, create_mqtt_config
from deebot_client.util import md5
from deebot_client.device import Device
device_id = md5(str(time.time()))
account_id = "your email or phonenumber (cn)"
password_hash = md5("yourPassword")
country = "DE"
async def main():
async with aiohttp.ClientSession() as session:
logging.basicConfig(level=logging.DEBUG)
rest_config = create_rest_config(session, device_id=device_id, alpha_2_country=country)
authenticator = Authenticator(rest_config, account_id, password_hash)
api_client = ApiClient(authenticator)
devices_ = await api_client.get_devices()
bot = Device(devices_.mqtt[0], authenticator)
mqtt_config = create_mqtt_config(device_id=device_id, country=country)
mqtt = MqttClient(mqtt_config, authenticator)
await bot.initialize(mqtt)
# Execute commands
await bot.execute_command(CleanV2(CleanAction.START))
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever() Debug
To know exactly what the Deebot app sends to the robot, you have to capture the MQTT messages it publishes to the cloud.
<your_venv_folder>/lib/python3.x/site-packages/deebot_client/mqtt_client.py
cd /usr/local/lib/python3.13/site-packages/deebot_client/mqtt_client.py
docker exec -it ha sh
find / -name mqtt_client.py
/usr/local/lib/python3.13/site-packages/deebot_client/mqtt_client.py
/usr/local/lib/python3.13/site-packages/yolink/mqtt_client.py
/usr/local/lib/python3.13/site-packages/thinqconnect/mqtt_client.py
cd /data/homeassistant202405
docker cp ha:/usr/local/lib/python3.13/site-packages/deebot_client/mqtt_client.py .
docker cp mqtt_client.py ha:/usr/local/lib/python3.13/site-packages/deebot_client/mqtt_client.py
If you add the below to mqtt_client.py under line 248, then when you make a request from your app. you can see the value for each room or scenario:
_LOGGER.info("FULL MQTT MESSAGE:\nTopic: %s\nPayload:\n%s", message.topic, message.payload.decode("utf-8", errors="replace"))
self._last_message_received_at = datetime.now()
def _handle_message(self, message: Message) -> None:
_LOGGER.debug(
"Got message: topic=%s, payload=%s", message.topic, message.payload
)
# Add here
_LOGGER.info("FULL MQTT MESSAGE:\nTopic: %s\nPayload:\n%s", message.topic, message.payload.decode("utf-8", errors="replace"))
_LOGGER.exception("x5 pro FULL MQTT MESSAGE:\nTopic: %s\nPayload:\n%s", message.topic, message.payload.decode("utf-8", errors="replace"))
self._last_message_received_at = datetime.now(tz=UTC)
topic_split = message.topic.value.split("/")
if message.topic.matches("iot/atr/#"):
self._handle_atr(topic_split, message.payload)
elif message.topic.matches("iot/p2p/#"):
self._handle_p2p(topic_split, message.payload)
http://192.168.2.125:8123/config/logs
Logger: deebot_client.mqtt_client
Source: /usr/local/lib/python3.13/site-packages/deebot_client/mqtt_client.py:255
First occurred: 9:14:43 AM (88 occurrences)
Last logged: 9:15:32 AM
x5 pro FULL MQTT MESSAGE: Topic: iot/p2p/getLifeSpan/b5da2e66-a843-4d5c-b71f-b6f88b86b7d6/mxse7w/D5ZMrszv/HelperMQClientId-sts-ngiot-mqserver-eco2-5/ecosys/1234/p/mFww/j Payload: {"body":{"code":0,"data":[{"left":10043,"total":18000,"type":"brush"},{"left":3948,"total":7200,"type":"heap"},{"left":8163,"total":9000,"type":"sideBrush"}],"msg":"ok"},"header":{"fwVer":"1.74.0","hwVer":"0.1.1","pri":1,"ts":"1771377295811","tzm":480,"ver":"0.0.1","wkVer":"0.1.54"}}
x5 pro FULL MQTT MESSAGE: Topic: iot/atr/onMapTrace/b5da2e66-a843-4d5c-b71f-b6f88b86b7d6/mxse7w/D5ZMrszv/j Payload: {"body":{"data":{"pointCount":1,"tid":"636028893","totalCount":1217,"traceStart":1216,"traceValue":"XQAABAAFAAAAAFyAmTB2XtgAAA=="}},"header":{"fwVer":"1.74.0","hwVer":"0.1.1","pri":1,"ts":"1771377297039","tzm":480,"ver":"0.0.1","wkVer":"0.1.54"}}
x5 pro FULL MQTT MESSAGE: Topic: iot/atr/onAIMap/b5da2e66-a843-4d5c-b71f-b6f88b86b7d6/mxse7w/D5ZMrszv/j Payload: {"body":{"data":{"cid":"111","mid":"52243489","pointValue":[],"totalCount":0}},"header":{"fwVer":"1.74.0","hwVer":"0.1.1","pri":1,"ts":"1771377297763","tzm":480,"ver":"0.0.1","wkVer":"0.1.54"}}
x5 pro FULL MQTT MESSAGE: Topic: iot/atr/onPos/b5da2e66-a843-4d5c-b71f-b6f88b86b7d6/mxse7w/D5ZMrszv/j Payload: {"body":{"data":{"chargePos":[{"a":-89,"invalid":0,"t":3,"x":6166,"y":-8042}],"deebotPos":{"a":171,"invalid":0,"x":6822,"y":-7884},"mid":"52243489"}},"header":{"fwVer":"1.74.0","hwVer":"0.1.1","pri":1,"ts":"1771377297882","tzm":480,"ver":"0.0.1","wkVer":"0.1.54"}}
x5 pro FULL MQTT MESSAGE: Topic: iot/atr/onMapTrace/b5da2e66-a843-4d5c-b71f-b6f88b86b7d6/mxse7w/D5ZMrszv/j Payload: {"body":{"data":{"pointCount":1,"tid":"636028893","totalCount":1218,"traceStart":1217,"traceValue":"XQAABAAFAAAAAFeAmXBmXtgAAA=="}},"header":{"fwVer":"1.74.0","hwVer":"0.1.1","pri":1,"ts":"1771377298041","tzm":480,"ver":"0.0.1","wkVer":"0.1.54"}}
enable debug logging for the integration
configuration.yaml
#
# ----------------------------------- logger -----------------------------------
#
logger:
default: warning
logs:
homeassistant.components.mqtt: debug
deebot_client: debug
homeassistant.components.ecovacs: debug
aiohttp: debug
docker logs -f ha | grep deebot
where can i find the config entry diagnostic information
here you can find the diagnostics data
https://github.com/DeebotUniverse/client.py/issues/832
https://github.com/DeebotUniverse/client.py/issues/845#issuecomment-2802200673
Quick clean
https://github.com/orgs/home-assistant/discussions/1910
Comments
Comments are closed