Skip to content

Fix Roborock source for China region accounts (region routing + unique MQTT client id) - #2346

Open
Sebjojo233 wants to merge 1 commit into
AlexxIT:masterfrom
Sebjojo233:fix-roborock-cn-region
Open

Fix Roborock source for China region accounts (region routing + unique MQTT client id)#2346
Sebjojo233 wants to merge 1 commit into
AlexxIT:masterfrom
Sebjojo233:fix-roborock-cn-region

Conversation

@Sebjojo233

Copy link
Copy Markdown

Fixes #2345, fixes #2207

Two small fixes that together make the Roborock source work for China region accounts (verified end-to-end with a Roborock P20 Pro on a CN account — also added to the known working models list).

1. Region routing in GetBaseURL (#2345)

getUrlByEmail was only queried on euiot.roborock.com. For accounts registered in another region it replies code: 200 with country: null and a default EU url, so login was attempted on the wrong server and always failed with 2012: username or password error.

Now the regional endpoints (us/eu/cn/ru) are queried in order and the first one that recognizes the account (non-null country/countrycode) wins — the same strategy python-roborock uses. If no region recognizes the account, the first region's default url is kept, which preserves the old behavior.

Verified: with a CN account, login now reaches cniot.roborock.com and the account is recognized (my particular account is then stopped by forced 2FA — that's #2046, out of scope here — but the routing is provably fixed since the CN server validates the password instead of the EU server rejecting an unknown account).

2. Unique MQTT client id (#2207)

The MQTT client id was hardcoded to com.roborock.smart:mbrriot, shared by every go2rtc install. The CN broker (mqtt-cn-*.roborock.com) accepts the connection (CONNACK success) and then immediately drops it, which surfaced as streams: unexpected EOF. Reproduced in a minimal client: identical credentials work with a unique client id and are kicked with the fixed one. A random suffix is now appended per connection.

After both fixes the P20 Pro streams fine (H.264 640×480 ~14 fps, pattern PIN works as documented).

🤖 Generated with Claude Code

GetBaseURL queried only euiot.roborock.com, which returns country=null
and a default EU url for accounts registered in another region, so CN
accounts always failed login with 2012. Iterate the regional endpoints
(us/eu/cn/ru) and use the first one that recognizes the account, same
as python-roborock does.

The CN MQTT broker also drops connections whose client id is already in
use; the fixed id was shared by every go2rtc install, so connections
died with 'unexpected EOF' right after CONNACK. Add a random suffix.

Tested with a Roborock P20 Pro on a China region account.

Fixes AlexxIT#2345, fixes AlexxIT#2207

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Roborock: China region accounts can't log in (getUrlByEmail always routed to EU server) Roborock MQTT connect fails with fixed client id

1 participant