From bae13823fd830aece01b82b2c57afca80a205eb4 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) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anton Hattendorf Signed-off-by: Jørgen Austvik --- .../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 f1b3e3a77ea3..7e8f335b2f4b 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 ShellyDeviceProfile initialize(String thingType, String jsonIn) throws Sh 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"); }