Skip to content

Commit d9e6fdf

Browse files
GuillaumeOdGuillaumeOdile
authored and
GuillaumeOdile
committed
fix: attribute loss when updating entity
1 parent 518d322 commit d9e6fdf

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

lib/services/ngsi/entities-NGSI-v2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation,
463463
}
464464
//remove measures that has been shadowed by an alias (some may be left and managed later)
465465
//Maybe we must filter object_id if there is name == object_id
466-
measures = measures.filter((item) => item.name !== currentAttr.object_id && item.name !== currentAttr.name);
466+
measures = measures.filter((item) => item.name !== currentAttr.object_id);
467467

468468
if (
469469
currentAttr.expression !== undefined &&

test/functional/testCases.js

+40
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,11 @@ const testCases = [
542542
object_id: '.1.0.0.1',
543543
name: 'psBatteryVoltage',
544544
type: 'Number'
545+
},
546+
{
547+
object_id: 'f_dt',
548+
name: 'fireDetectionThreshold',
549+
type: 'Number'
545550
}
546551
],
547552
static_attributes: []
@@ -588,6 +593,41 @@ const testCases = [
588593
value: 23.5
589594
}
590595
}
596+
},
597+
{
598+
shouldName:
599+
'A - WHEN sending defined measures by attribute names through http IT should send measures to Context Broker preserving value types, name mappings and metadatas',
600+
type: 'single',
601+
measure: {
602+
url: 'http://localhost:' + config.http.port + '/iot/json',
603+
method: 'POST',
604+
qs: {
605+
i: globalEnv.deviceId,
606+
k: globalEnv.apikey
607+
},
608+
json: {
609+
a: false,
610+
fireDetectionThreshold: 10
611+
}
612+
},
613+
expectation: {
614+
id: globalEnv.entity_name,
615+
type: globalEnv.entity_type,
616+
attr_a: {
617+
value: false,
618+
type: 'Boolean',
619+
metadata: {
620+
accuracy: {
621+
value: 0.8,
622+
type: 'Float'
623+
}
624+
}
625+
},
626+
fireDetectionThreshold: {
627+
type: 'Number',
628+
value: 10
629+
}
630+
}
591631
}
592632
]
593633
},

0 commit comments

Comments
 (0)