From f1ccd728a6ef3874410db32f06a08813ae533faf Mon Sep 17 00:00:00 2001 From: bofakin <143448461+bofakin@users.noreply.github.com> Date: Sun, 8 Oct 2023 22:47:10 +0200 Subject: [PATCH] Fix openhab#15514: Temperature sensors in JSON from shelly may not be in order (#15530) Signed-off-by: Anton Hattendorf --- .../binding/shelly/internal/api/ShellyDeviceProfile.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 f1b3e3a77..7e8f335b2 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"); }