Skip to content

Commit

Permalink
Merge pull request #1029 from telefonicaid/fix/use_expressionLanguage…
Browse files Browse the repository at this point in the history
…_from_group

use expresionLanguage from group if not defined
  • Loading branch information
fgalan authored May 5, 2021
2 parents 211670a + 4052cc5 commit 440e0f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fix: use expressionLanguage defined in group is not defined at device level (#1027)
- Fix: ensure service of groups, device and commands is stored in mongo in lowercase (#1023)
- Add: add getTypeSilently for device group and use in device registration to avoid false mongo alarm
- Fix: group command is not provisioned in device when entity_type is different (#1011)
Expand Down
6 changes: 6 additions & 0 deletions lib/services/devices/deviceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ function mergeDeviceWithConfiguration(fields, defaults, deviceData, configuratio
if (configuration && configuration.ngsiVersion) {
deviceData.ngsiVersion = configuration.ngsiVersion;
}
if (configuration && configuration.expressionLanguage && deviceData.expressionLanguage === undefined) {
deviceData.expressionLanguage = configuration.expressionLanguage;
}

logger.debug(context, 'deviceData after merge with conf: %j', deviceData);
callback(null, deviceData);
Expand Down Expand Up @@ -562,6 +565,9 @@ function findOrCreate(deviceId, group, callback) {
if ('ngsiVersion' in group && group.ngsiVersion !== undefined) {
newDevice.ngsiVersion = group.ngsiVersion;
}
if ('expressionLanguage' in group && group.expressionLanguage !== undefined) {
newDevice.expressionLanguage = group.expressionLanguage;
}
registerDevice(newDevice, function (error, device) {
callback(error, device, group);
});
Expand Down
3 changes: 3 additions & 0 deletions lib/services/devices/devices-NGSI-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ function updateRegisterDeviceNgsi2(deviceObj, entityInfoUpdated, callback) {
if ('explicitAttrs' in newDevice && newDevice.explicitAttrs !== undefined) {
oldDevice.explicitAttrs = newDevice.explicitAttrs;
}
if ('expressionLanguage' in newDevice && newDevice.expressionLanguage !== undefined) {
oldDevice.expressionLanguage = newDevice.expressionLanguage;
}

oldDevice.endpoint = newDevice.endpoint || oldDevice.endpoint;

Expand Down

0 comments on commit 440e0f2

Please sign in to comment.