[miio] Minor improvement documentation & deviceId update message (#11046)

* [miio] Minor improvement documentation & message
* [miio] minor cleanup from sat
* miio] fix another minor datetimeformat SAT issue

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
Marcel 2021-07-24 21:21:14 +02:00 committed by GitHub
parent 487dc0e49f
commit aac28589e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 14 deletions

View File

@ -80,9 +80,11 @@ However, for devices that are unsupported, you may override the value and try to
| model | text | false | Device model string, used to determine the subtype | | model | text | false | Device model string, used to determine the subtype |
| refreshInterval | integer | false | Refresh interval for refreshing the data in seconds. (0=disabled) | | refreshInterval | integer | false | Refresh interval for refreshing the data in seconds. (0=disabled) |
| timeout | integer | false | Timeout time in milliseconds | | timeout | integer | false | Timeout time in milliseconds |
| communication | test | false | Communicate direct or via cloud (options values: 'direct', 'cloud') | | communication | text | false | Communicate direct or via cloud (options values: 'direct', 'cloud') |
| cloudServer | text | false | Identifies the country server to use in case of cloud communication |
Note: Suggest to use the cloud communication only for devices that require it. It is unknown at this time if Xiaomi has a rate limit or other limitations on the cloud usage. e.g. if having many devices would trigger some throttling from the cloud side. Note: Suggest to use the cloud communication only for devices that require it.
It is unknown at this time if Xiaomi has a rate limit or other limitations on the cloud usage. e.g. if having many devices would trigger some throttling from the cloud side.
### Example Thing file ### Example Thing file
@ -90,7 +92,7 @@ Note: Suggest to use the cloud communication only for devices that require it. I
or in case of unknown models include the model information of a similar device that is supported: or in case of unknown models include the model information of a similar device that is supported:
`Thing miio:vacuum:s50 "vacuum" @ "livingroom" [ host="192.168.15.20", token="xxxxxxx", deviceId="326xxxx", model="roborock.vacuum.s4", communication="direct" ]` `Thing miio:vacuum:s50 "vacuum" @ "livingroom" [ host="192.168.15.20", token="xxxxxxx", deviceId="326xxxx", model="roborock.vacuum.s4", communication="direct", cloudServer="de" ]`
# Advanced: Unsupported devices # Advanced: Unsupported devices

View File

@ -80,9 +80,11 @@ However, for devices that are unsupported, you may override the value and try to
| model | text | false | Device model string, used to determine the subtype | | model | text | false | Device model string, used to determine the subtype |
| refreshInterval | integer | false | Refresh interval for refreshing the data in seconds. (0=disabled) | | refreshInterval | integer | false | Refresh interval for refreshing the data in seconds. (0=disabled) |
| timeout | integer | false | Timeout time in milliseconds | | timeout | integer | false | Timeout time in milliseconds |
| communication | test | false | Communicate direct or via cloud (options values: 'direct', 'cloud') | | communication | text | false | Communicate direct or via cloud (options values: 'direct', 'cloud') |
| cloudServer | text | false | Identifies the country server to use in case of cloud communication |
Note: Suggest to use the cloud communication only for devices that require it. It is unknown at this time if Xiaomi has a rate limit or other limitations on the cloud usage. e.g. if having many devices would trigger some throttling from the cloud side. Note: Suggest to use the cloud communication only for devices that require it.
It is unknown at this time if Xiaomi has a rate limit or other limitations on the cloud usage. e.g. if having many devices would trigger some throttling from the cloud side.
### Example Thing file ### Example Thing file
@ -90,7 +92,7 @@ Note: Suggest to use the cloud communication only for devices that require it. I
or in case of unknown models include the model information of a similar device that is supported: or in case of unknown models include the model information of a similar device that is supported:
`Thing miio:vacuum:s50 "vacuum" @ "livingroom" [ host="192.168.15.20", token="xxxxxxx", deviceId="326xxxx", model="roborock.vacuum.s4", communication="direct" ]` `Thing miio:vacuum:s50 "vacuum" @ "livingroom" [ host="192.168.15.20", token="xxxxxxx", deviceId="326xxxx", model="roborock.vacuum.s4", communication="direct", cloudServer="de" ]`
# Advanced: Unsupported devices # Advanced: Unsupported devices

View File

@ -76,7 +76,7 @@ public class ActionConditions {
* @param value * @param value
* @return RGB value + brightness as first byte * @return RGB value + brightness as first byte
*/ */
private static @Nullable JsonElement HsvToBRGB(@Nullable Command command, @Nullable JsonElement value) { private static @Nullable JsonElement hsvToBRGB(@Nullable Command command, @Nullable JsonElement value) {
if (command != null && command instanceof HSBType) { if (command != null && command instanceof HSBType) {
HSBType hsb = (HSBType) command; HSBType hsb = (HSBType) command;
Color color = Color.getHSBColor(hsb.getHue().floatValue() / 360, hsb.getSaturation().floatValue() / 100, Color color = Color.getHSBColor(hsb.getHue().floatValue() / 360, hsb.getSaturation().floatValue() / 100,
@ -171,7 +171,7 @@ public class ActionConditions {
case "BRIGHTNESSEXISTING": case "BRIGHTNESSEXISTING":
return brightnessExists(value); return brightnessExists(value);
case "HSVTOBRGB": case "HSVTOBRGB":
return HsvToBRGB(command, value); return hsvToBRGB(command, value);
case "BRIGHTNESSONOFF": case "BRIGHTNESSONOFF":
return brightness(value); return brightness(value);
case "HSBONLY": case "HSBONLY":

View File

@ -374,7 +374,8 @@ public abstract class MiIoAbstractHandler extends BaseThingHandler implements Mi
String deviceId = configuration.deviceId; String deviceId = configuration.deviceId;
if (deviceId.length() == 8 && deviceId.matches("^.*[a-zA-Z]+.*$")) { if (deviceId.length() == 8 && deviceId.matches("^.*[a-zA-Z]+.*$")) {
logger.warn( logger.warn(
"As per openHAB version 3.2 the deviceId is no longer a string with hexadecimals, instead it is a string with the numeric respresentation of the deviceId. If you continue seeing this message, update deviceId in your thing configuration"); "As per openHAB version 3.2 the deviceId is no longer a string with hexadecimals, instead it is a string with the numeric respresentation of the deviceId. If you continue seeing this message, update deviceId in your thing configuration. Expected change for thing '{}': Update current deviceId: '{}' to '{}'",
getThing().getUID(), deviceId, Utils.fromHEX(deviceId));
deviceId = ""; deviceId = "";
} }
try { try {

View File

@ -18,12 +18,12 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -89,7 +89,7 @@ import com.google.gson.JsonObject;
public class MiIoVacuumHandler extends MiIoAbstractHandler { public class MiIoVacuumHandler extends MiIoAbstractHandler {
private final Logger logger = LoggerFactory.getLogger(MiIoVacuumHandler.class); private final Logger logger = LoggerFactory.getLogger(MiIoVacuumHandler.class);
private static final float MAP_SCALE = 2.0f; private static final float MAP_SCALE = 2.0f;
private static final SimpleDateFormat DATEFORMATTER = new SimpleDateFormat("yyyyMMdd-HHmmss"); private static final DateTimeFormatter DATEFORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss");
private static final Gson GSON = new GsonBuilder().serializeNulls().create(); private static final Gson GSON = new GsonBuilder().serializeNulls().create();
private final ChannelUID mapChannelUid; private final ChannelUID mapChannelUid;
@ -654,7 +654,7 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
final String mapPath = BINDING_USERDATA_PATH + File.separator + map final String mapPath = BINDING_USERDATA_PATH + File.separator + map
+ DATEFORMATTER.format(new Date()) + ".rrmap"; + LocalDateTime.now().format(DATEFORMATTER) + ".rrmap";
CloudUtil.writeBytesToFileNio(mapData, mapPath); CloudUtil.writeBytesToFileNio(mapData, mapPath);
logger.debug("Mapdata saved to {}", mapPath); logger.debug("Mapdata saved to {}", mapPath);
} }

View File

@ -246,7 +246,7 @@
"actions": [ "actions": [
{ {
"command": "start_cf", "command": "start_cf",
"parameterType": "EMPTY", "parameterType": "NONE",
"parameters": [ "parameters": [
0, 0,
0, 0,