Skip to content

Commit

Permalink
Fix openhab#15514: Temperature sensors in JSON from shelly may not be…
Browse files Browse the repository at this point in the history
… in order (openhab#15530)

Signed-off-by: Anton Hattendorf <anton@hattendoerfer.de>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
  • Loading branch information
bofakin authored and austvik committed Mar 27, 2024
1 parent 42e6625 commit bae1382
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit bae1382

Please sign in to comment.