diff --git a/src/lib/ngsiNotify/Notifier.cpp b/src/lib/ngsiNotify/Notifier.cpp index 6fd17245da..fb5070f1ab 100644 --- a/src/lib/ngsiNotify/Notifier.cpp +++ b/src/lib/ngsiNotify/Notifier.cpp @@ -292,9 +292,14 @@ static bool setNgsiPayload for (unsigned int ix = 0; ix < orderedNgsiAttrs.size(); ix++) { cer.entity.attributeVector.push_back(new ContextAttribute(orderedNgsiAttrs[ix], false, true)); - TIME_EXPR_CTXBLD_START(); - exprContextObjectP->add(orderedNgsiAttrs[ix]->name, orderedNgsiAttrs[ix]->toJsonValue(exprContextObjectP), true); - TIME_EXPR_CTXBLD_STOP(); + + // Avoid to add context if an attribute with the same name exists in the entity + if (cer.entity.attributeVector.get(orderedNgsiAttrs[ix]->name) < 0) + { + TIME_EXPR_CTXBLD_START(); + exprContextObjectP->add(orderedNgsiAttrs[ix]->name, orderedNgsiAttrs[ix]->toJsonValue(exprContextObjectP), true); + TIME_EXPR_CTXBLD_STOP(); + } } // Next, other attributes in the original entity not already added for (unsigned int ix = 0; ix < en.attributeVector.size(); ix++)