From: bofakin <143448461+bofakin@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:47:10 +0000 (+0200) Subject: Fix openhab#15514: Temperature sensors in JSON from shelly may not be in order (... X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=f1ccd728a6ef3874410db32f06a08813ae533faf;p=openhab-addons.git Fix openhab#15514: Temperature sensors in JSON from shelly may not be in order (#15530) Signed-off-by: Anton Hattendorf --- diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java index f1b3e3a77e..7e8f335b2f 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java @@ -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"); }