]> git.basschouten.com Git - openhab-addons.git/commitdiff
Fix openhab#15514: Temperature sensors in JSON from shelly may not be in order (...
authorbofakin <143448461+bofakin@users.noreply.github.com>
Sun, 8 Oct 2023 20:47:10 +0000 (22:47 +0200)
committerGitHub <noreply@github.com>
Sun, 8 Oct 2023 20:47:10 +0000 (22:47 +0200)
Signed-off-by: Anton Hattendorf <anton@hattendoerfer.de>
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java

index f1b3e3a77ea336067bc366158fa6c7ce7976aff5..7e8f335b2f4b066e70ff51b0f11525343a7e8e32 100644 (file)
@@ -126,7 +126,10 @@ public class ShellyDeviceProfile {
         initFromThingType(thingType);
 
         String json = jsonIn;
-        if (json.contains("\"ext_temperature\":{\"0\":[{")) {
+        // It is not guaranteed, that the array entries are in order. Check all
+        // possible variants. See openhab#15514.
+        if (json.contains("\"ext_temperature\":{\"0\":[{") || json.contains("\"ext_temperature\":{\"1\":[{")
+                || json.contains("\"ext_temperature\":{\"2\":[{")) {
             // Shelly UNI uses ext_temperature array, reformat to avoid GSON exception
             json = json.replace("ext_temperature", "ext_temperature_array");
         }