]> git.basschouten.com Git - openhab-addons.git/commitdiff
[miio] Minor improvement documentation & deviceId update message (#11046)
authorMarcel <marcel@verpaalen.com>
Sat, 24 Jul 2021 19:21:14 +0000 (21:21 +0200)
committerGitHub <noreply@github.com>
Sat, 24 Jul 2021 19:21:14 +0000 (21:21 +0200)
* [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>
bundles/org.openhab.binding.miio/README.base.md
bundles/org.openhab.binding.miio/README.md
bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/basic/ActionConditions.java
bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoAbstractHandler.java
bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoVacuumHandler.java
bundles/org.openhab.binding.miio/src/main/resources/database/yeelink.light.color1.json

index ec6771736d597b7b4f7a66c7243b44b0b827cd70..1398a2a7f409e5cbadd0973a449c83adc73977a4 100644 (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                  |
 | refreshInterval | integer | false    | Refresh interval for refreshing the data in seconds. (0=disabled)   |
 | 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
 
@@ -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:
 
-`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
 
index d39f57eb4b32e1cf3553a78db242f3e9e3720836..cabb4b57acaecee59e8f89dda71ca77d0ab95caa 100644 (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                  |
 | refreshInterval | integer | false    | Refresh interval for refreshing the data in seconds. (0=disabled)   |
 | 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
 
@@ -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:
 
-`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
 
index 0b4cb553eeb1f6642545c036f7bfd6ca77a3cb10..8882a18b880f87c7e7af5c61f084c6fb80181604 100644 (file)
@@ -76,7 +76,7 @@ public class ActionConditions {
      * @param value
      * @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) {
             HSBType hsb = (HSBType) command;
             Color color = Color.getHSBColor(hsb.getHue().floatValue() / 360, hsb.getSaturation().floatValue() / 100,
@@ -171,7 +171,7 @@ public class ActionConditions {
             case "BRIGHTNESSEXISTING":
                 return brightnessExists(value);
             case "HSVTOBRGB":
-                return HsvToBRGB(command, value);
+                return hsvToBRGB(command, value);
             case "BRIGHTNESSONOFF":
                 return brightness(value);
             case "HSBONLY":
index 83832f3334bdaaa5184e027fc4e51b1163af3128..93acefd1b46e3690d3fa7ccfdeb0cdec55fd1c70 100644 (file)
@@ -374,7 +374,8 @@ public abstract class MiIoAbstractHandler extends BaseThingHandler implements Mi
         String deviceId = configuration.deviceId;
         if (deviceId.length() == 8 && deviceId.matches("^.*[a-zA-Z]+.*$")) {
             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 = "";
         }
         try {
index e3b36f664e4894737cbeb0418600f19a7555254d..75f4918e3c5c7ece26074d0f5086792e743e3410 100644 (file)
@@ -18,12 +18,12 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
-import java.text.SimpleDateFormat;
 import java.time.Instant;
+import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.Collections;
-import java.util.Date;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -89,7 +89,7 @@ import com.google.gson.JsonObject;
 public class MiIoVacuumHandler extends MiIoAbstractHandler {
     private final Logger logger = LoggerFactory.getLogger(MiIoVacuumHandler.class);
     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 final ChannelUID mapChannelUid;
 
@@ -654,7 +654,7 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler {
                     ByteArrayOutputStream baos = new ByteArrayOutputStream();
                     if (logger.isDebugEnabled()) {
                         final String mapPath = BINDING_USERDATA_PATH + File.separator + map
-                                + DATEFORMATTER.format(new Date()) + ".rrmap";
+                                + LocalDateTime.now().format(DATEFORMATTER) + ".rrmap";
                         CloudUtil.writeBytesToFileNio(mapData, mapPath);
                         logger.debug("Mapdata saved to {}", mapPath);
                     }
index 7e41b83c9746f8977d3be96d96c37c07a6942b71..18305fa735de97882448d74dc451e96adddf7cd2 100644 (file)
                                "actions": [
                                        {
                                                "command": "start_cf",
-                                               "parameterType": "EMPTY",
+                                               "parameterType": "NONE",
                                                "parameters": [
                                                        0,
                                                        0,