Fix openhab#15514: Temperature sensors in JSON from shelly may not be in order (#15530)

Signed-off-by: Anton Hattendorf <anton@hattendoerfer.de>
This commit is contained in:
bofakin 2023-10-08 22:47:10 +02:00 committed by GitHub
parent 756b32d988
commit f1ccd728a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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");
}