Skip to content

Commit

Permalink
[miio] cloud login issues improvement (openhab#13715)
Browse files Browse the repository at this point in the history
* [miio] cloud login issues improvement

* Small change in debug loggin is login issues are expected
* Additional trouble shooting steps in readme
* Fix duplicate name in device list preventing readme maker running
* Catch a json exception in readme maker

close openhab#13611
close openhab#7459

* [miio] fix strange/foreign characters in readme

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
  • Loading branch information
marcelrv authored and psmedley committed Feb 23, 2023
1 parent df6cd0e commit 536fc5e
Show file tree
Hide file tree
Showing 10 changed files with 1,307 additions and 1,180 deletions.
10 changes: 9 additions & 1 deletion bundles/org.openhab.binding.miio/README.base.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,15 @@ Firmware of the device don't accept commands coming from other subnets.
Set the communication in the thing configuration to 'cloud'.

_Cloud connectivity is not working_
The most common problem is a wrong userId/password. Try to fix your userId/password.
The most common problem is a wrong or missing userId/password. Update your Xiaomi cloud userId & password in the [miio binding configuration screen](#binding-configuration).
If the problem persists you can try the following:

* Xiaomi Account verification might be needed. For some users login by the binding is unsuccessful as account verification is required, but the binding currently has no possibilities to handle this.
In order to pass validation your (openHAB server) ip need to be validated/confirmed.
Browse to [https://account.xiaomi.com/](https://account.xiaomi.com/) and logon to your account. Note: use the same external ip address as your openHAB server, e.g. you may need to disable your VPN.
* If above is not possible or fails, You can try to find in the binding debug logging a `location url`. Try to login using this url (just after it fails) with your browser.
* Several users also reported success by resetting their Xiaomi password.

If it still fails, you're bit out of luck. You may try to restart openHAB (not just the binding) to clean the cookies.
As the cloud logon process is still little understood, your only luck might be to enable trace logging and see if you can translate the Chinese error code that it returns.

Expand Down
81 changes: 57 additions & 24 deletions bundles/org.openhab.binding.miio/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/**
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.miio.internal.cloud;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
* This DTO class wraps the login step 1 json structure
*
* @author Marcel Verpaalen - Initial contribution
*/
public class CloudLogin1DTO {
@SerializedName("serviceParam")
@Expose
private String serviceParam;
@SerializedName("qs")
@Expose
private String qs;
@SerializedName("code")
@Expose
private Integer code;
@SerializedName("description")
@Expose
private String description;
@SerializedName("securityStatus")
@Expose
private Integer securityStatus;
@SerializedName("_sign")
@Expose
private String sign;
@SerializedName("sid")
@Expose
private String sid;
@SerializedName("result")
@Expose
private String result;
@SerializedName("captchaUrl")
@Expose
private String captchaUrl;
@SerializedName("callback")
@Expose
private String callback;
@SerializedName("location")
@Expose
private String location;
@SerializedName("pwd")
@Expose
private Integer pwd;
@SerializedName("child")
@Expose
private Integer child;
@SerializedName("desc")
@Expose
private String desc;

public String getServiceParam() {
return serviceParam;
}

public String getQs() {
return qs;
}

public Integer getCode() {
return code;
}

public String getDescription() {
return description;
}

public Integer getSecurityStatus() {
return securityStatus;
}

public String getSign() {
return sign;
}

public String getSid() {
return sid;
}

public String getResult() {
return result;
}

public String getCaptchaUrl() {
return captchaUrl;
}

public String getCallback() {
return callback;
}

public String getLocation() {
return location;
}

public Integer getPwd() {
return pwd;
}

public Integer getChild() {
return child;
}

public String getDesc() {
return desc;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,9 @@ private String loginStep1() throws InterruptedException, TimeoutException, Execu
logger.trace("Xiaomi Login step 1 response = {}", responseStep1);
try {
JsonElement resp = JsonParser.parseString(parseJson(content));
if (resp.isJsonObject() && resp.getAsJsonObject().has("_sign")) {
String sign = resp.getAsJsonObject().get("_sign").getAsString();
CloudLogin1DTO jsonResp = GSON.fromJson(resp, CloudLogin1DTO.class);
final String sign = jsonResp.getSign();
if (sign != null && !sign.isBlank()) {
logger.trace("Xiaomi Login step 1 sign = {}", sign);
return sign;
} else {
Expand Down Expand Up @@ -472,6 +473,13 @@ private String loginStep2(String sign) throws MiIoCryptoException, InterruptedEx
logger.trace("Xiaomi login passToken = {}", passToken);
logger.trace("Xiaomi login location = {}", location);
logger.trace("Xiaomi login code = {}", code);
if (0 != jsonResp.getSecurityStatus()) {
logger.debug("Xiaomi Cloud Step2 response: {}", parseJson(content2));
logger.debug(
"Xiaomi Login code: {} \r\nSecurityStatus: {}\r\nPwd code: {}\r\nLocation logon URL: {}\r\nIn case of login issues check userId/password details are correct.\r\n"
+ "If login details are correct, try to logon using browser from the openHAB ip using the browser. Alternatively try to complete logon with above URL.",
jsonResp.getCode(), jsonResp.getSecurityStatus(), jsonResp.getPwd(), jsonResp.getLocation());
}
if (logger.isTraceEnabled()) {
dumpCookies(url, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ thing.roborock.vacuum.a14 = Roborock T7S
thing.roborock.vacuum.a15 = Roborock S7
thing.roborock.vacuum.a19 = Roborock S4 Max
thing.roborock.vacuum.a23 = Roborock T7S Plus
thing.roborock.vacuum.a26 = Roborock G10S Pro
thing.roborock.vacuum.a27 = Roborock S7 MaxV
thing.roborock.vacuum.a29 = Roborock G10
thing.roborock.vacuum.a30 = Roborock G10
thing.roborock.vacuum.a34 = Roborock Q5
thing.roborock.vacuum.a37 = Roborock T8
thing.roborock.vacuum.a38 = Roborock Q7 Max
thing.roborock.vacuum.a40 = Roborock Q7
thing.roborock.vacuum.a46 = Roborock G10S
thing.roborock.vacuum.a52 = Roborock T8 Plus
thing.roborock.vacuum.a62 = Roborock S7 Pro Ultra
thing.roborock.vacuum.c1 = Xiaowa C1
thing.roborock.vacuum.e2 = Roborock Xiaowa E Series Vacuum v2
thing.roborock.vacuum.m1s = Mi Robot Vacuum 1S
Expand Down Expand Up @@ -2773,14 +2784,14 @@ option.mijia.vacuum.v2-miot.fault-7 = Side-brush-error
option.mijia.vacuum.v2-miot.fault-8 = Fan-motor-error
option.mijia.vacuum.v2-miot.fault-9 = Dustbin-error
option.mijia.vacuum.v2-miot.language-0 = English
option.mijia.vacuum.v2-miot.language-1 = 简体中文
option.mijia.vacuum.v2-miot.language-2 = Español
option.mijia.vacuum.v2-miot.language-3 = Русский
option.mijia.vacuum.v2-miot.language-4 = Italiano
option.mijia.vacuum.v2-miot.language-5 = Français
option.mijia.vacuum.v2-miot.language-6 = Deutsch
option.mijia.vacuum.v2-miot.language-7 = 한국어
option.mijia.vacuum.v2-miot.language-8 = Polski
option.mijia.vacuum.v2-miot.language-1 = Chinese
option.mijia.vacuum.v2-miot.language-2 = Spanish
option.mijia.vacuum.v2-miot.language-3 = Russian
option.mijia.vacuum.v2-miot.language-4 = Italian
option.mijia.vacuum.v2-miot.language-5 = French
option.mijia.vacuum.v2-miot.language-6 = German
option.mijia.vacuum.v2-miot.language-7 = Korean
option.mijia.vacuum.v2-miot.language-8 = Polish
option.mijia.vacuum.v2-miot.mode-1 = Auto-clean
option.mijia.vacuum.v2-miot.mode-2 = Spot-clean
option.mijia.vacuum.v2-miot.mode-3 = Wallflow-clean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@
]
}
}
]
],
"readmeComment": "Value mapping `[\"vacuum-start-sweep\"\u003d\"Vacuum Start Sweep\",\"vacuum-stop-sweeping\"\u003d\"Vacuum Stop Sweeping\",\"battery-start-charge\"\u003d\"Battery Start Charge\",\"brush-cleaner-reset-brush-life\"\u003d\"Brush Cleaner Reset Brush Life\",\"brush-cleaner-reset-brush-life\"\u003d\"Brush Cleaner Reset Brush Life\",\"filter-reset-filter-life\"\u003d\"Filter Reset Filter Life\",\"vacuum-extend-start-clean\"\u003d\"Vacuum Extend Start Clean\",\"vacuum-extend-stop-clean\"\u003d\"Vacuum Extend Stop Clean\",\"map-map-req\"\u003d\"Map Map Req\",\"map-update-map\"\u003d\"Map Update Map\",\"audio-position\"\u003d\"Audio Position\",\"audio-play-sound\"\u003d\"Audio Play Sound\",\"time-delete-timer\"\u003d\"Time Delete Timer\"]`"
},
{
"property": "status",
Expand Down Expand Up @@ -307,7 +308,7 @@
},
"refresh": true,
"actions": [],
"readmeComment": "Value mapping [\"1\"\u003d\"Sweeping\",\"2\"\u003d\"Idle\",\"3\"\u003d\"Paused\",\"4\"\u003d\"Error\",\"5\"\u003d\"Go Charging\",\"6\"\u003d\"Charging\",\"7\"\u003d\"Mopping\"]"
"readmeComment": "Value mapping `[\"1\"\u003d\"Sweeping\",\"2\"\u003d\"Idle\",\"3\"\u003d\"Paused\",\"4\"\u003d\"Error\",\"5\"\u003d\"Go Charging\",\"6\"\u003d\"Charging\",\"7\"\u003d\"Mopping\"]`"
},
{
"property": "fault",
Expand Down Expand Up @@ -370,7 +371,7 @@
},
"refresh": true,
"actions": [],
"readmeComment": "Value mapping [\"1\"\u003d\"Charging\",\"2\"\u003d\"Not Charging\",\"5\"\u003d\"Go Charging\"]"
"readmeComment": "Value mapping `[\"1\"\u003d\"Charging\",\"2\"\u003d\"Not Charging\",\"5\"\u003d\"Go Charging\"]`"
},
{
"property": "brush-left-time",
Expand Down Expand Up @@ -566,7 +567,7 @@
"parameterType": "STRING"
}
],
"readmeComment": "Value mapping [\"0\"\u003d\"Silent\",\"1\"\u003d\"Standard\",\"2\"\u003d\"Strong\",\"3\"\u003d\"Turbo\"]"
"readmeComment": "Value mapping `[\"0\"\u003d\"Silent\",\"1\"\u003d\"Standard\",\"2\"\u003d\"Strong\",\"3\"\u003d\"Turbo\"]`"
},
{
"property": "mop-mode",
Expand Down Expand Up @@ -598,7 +599,7 @@
"parameterType": "STRING"
}
],
"readmeComment": "Value mapping [\"1\"\u003d\"Low\",\"2\"\u003d\"Medium\",\"3\"\u003d\"High\"]"
"readmeComment": "Value mapping `[\"1\"\u003d\"Low\",\"2\"\u003d\"Medium\",\"3\"\u003d\"High\"]`"
},
{
"property": "waterbox-status",
Expand All @@ -622,7 +623,7 @@
},
"refresh": true,
"actions": [],
"readmeComment": "Value mapping [\"0\"\u003d\"Removed\",\"1\"\u003d\"Installed\"]"
"readmeComment": "Value mapping `[\"0\"\u003d\"Removed\",\"1\"\u003d\"Installed\"]`"
},
{
"property": "task-status",
Expand Down Expand Up @@ -682,7 +683,7 @@
"parameterType": "NUMBER"
}
],
"readmeComment": "Value mapping [\"0\"\u003d\"Off\",\"1\"\u003d\"On\"]"
"readmeComment": "Value mapping `[\"0\"\u003d\"Off\",\"1\"\u003d\"On\"]`"
},
{
"property": "carpet-press",
Expand Down Expand Up @@ -710,7 +711,7 @@
"parameterType": "NUMBER"
}
],
"readmeComment": "Value mapping [\"0\"\u003d\"On\",\"1\"\u003d\"Off\"]"
"readmeComment": "Value mapping `[\"0\"\u003d\"On\",\"1\"\u003d\"Off\"]`"
},
{
"property": "serial-number",
Expand Down Expand Up @@ -894,7 +895,7 @@
"parameterType": "NUMBER"
}
],
"readmeComment": "Value mapping [\"0\"\u003d\"Close\",\"1\"\u003d\"Open\"]"
"readmeComment": "Value mapping `[\"0\"\u003d\"Close\",\"1\"\u003d\"Open\"]`"
},
{
"property": "mult-map-info",
Expand Down
Loading

0 comments on commit 536fc5e

Please sign in to comment.