From 456d5d3dd07abc7b37fbdc6cf16db9c14333ea3e Mon Sep 17 00:00:00 2001 From: jimtng <2554958+jimtng@users.noreply.github.com> Date: Mon, 6 May 2024 03:24:04 -0400 Subject: [PATCH] Fix textual things not updating on the first change (#4219) Signed-off-by: Jimmy Tanagra --- .../core/model/thing/internal/GenericThingProvider.xtend | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericThingProvider.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericThingProvider.xtend index 3493606dd..7e5b0b5f1 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericThingProvider.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericThingProvider.xtend @@ -605,8 +605,9 @@ class GenericThingProvider extends AbstractProviderLazyNullness implement if (!loadedXmlThingTypes.contains(factory.bundleName) || modelRepository == null) { return } + val things = thingsMap.get(modelName) + val oldThings = things.clone val newThings = newArrayList() - val oldThings = thingsMap.put(modelName, newThings) val model = modelRepository.getModel(modelName) as ThingModel if (model !== null) { @@ -619,10 +620,13 @@ class GenericThingProvider extends AbstractProviderLazyNullness implement val oldThing = oldThings.findFirst[it.UID == newThing.UID] if (oldThing !== null) { if (!ThingHelper.equals(oldThing, newThing)) { + things.remove(oldThing) + things.add(newThing) logger.debug("Updating thing '{}' from model '{}'.", newThing.UID, modelName); notifyListenersAboutUpdatedElement(oldThing, newThing) } } else { + things.add(newThing) logger.debug("Adding thing '{}' from model '{}'.", newThing.UID, modelName); newThing.notifyListenersAboutAddedElement }