iotagent-node-lib 4.9.0 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/.github/workflows/ci.yml +6 -8
  2. package/CHANGES_NEXT_RELEASE +0 -1
  3. package/Changelog +14 -0
  4. package/config.js +2 -1
  5. package/doc/admin.md +17 -20
  6. package/doc/api.md +87 -50
  7. package/doc/deprecated.md +18 -0
  8. package/doc/devel/northboundinteractions.md +213 -113
  9. package/lib/commonConfig.js +12 -1
  10. package/lib/jexlTranformsMap.js +15 -0
  11. package/lib/model/Device.js +3 -1
  12. package/lib/model/Group.js +2 -1
  13. package/lib/model/dbConn.js +57 -58
  14. package/lib/services/common/iotManagerService.js +2 -1
  15. package/lib/services/devices/deviceRegistryMongoDB.js +5 -1
  16. package/lib/services/devices/deviceService.js +17 -1
  17. package/lib/services/devices/devices-NGSI-LD.js +3 -2
  18. package/lib/services/devices/devices-NGSI-mixed.js +16 -0
  19. package/lib/services/devices/devices-NGSI-v2.js +122 -8
  20. package/lib/services/devices/registrationUtils.js +97 -30
  21. package/lib/services/groups/groupRegistryMongoDB.js +2 -1
  22. package/lib/services/ngsi/subscription-NGSI-LD.js +2 -2
  23. package/lib/services/ngsi/subscription-NGSI-mixed.js +3 -3
  24. package/lib/services/ngsi/subscription-NGSI-v2.js +20 -6
  25. package/lib/services/ngsi/subscriptionService.js +2 -2
  26. package/lib/services/northBound/contextServer-NGSI-v2.js +4 -2
  27. package/lib/services/northBound/deviceProvisioningServer.js +6 -3
  28. package/lib/templates/updateDevice.json +12 -0
  29. package/lib/templates/updateDeviceLax.json +4 -0
  30. package/package.json +2 -2
  31. package/test/unit/expressions/jexlExpression-test.js +30 -0
  32. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -2
  33. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -1
  34. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
  35. package/test/unit/ngsi-ld/general/https-support-test.js +1 -1
  36. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +6 -6
  37. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/subscribeIoTAgentCommands.json +24 -0
  38. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/subscribeIoTAgentCommands2.json +24 -0
  39. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/subscribeIoTAgentCommands3.json +24 -0
  40. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/subscribeIoTAgentCommands4.json +24 -0
  41. package/test/unit/ngsiv2/examples/contextRequests/updateEntity.json +5 -0
  42. package/test/unit/ngsiv2/examples/contextRequests/updateEntity2.json +5 -0
  43. package/test/unit/ngsiv2/examples/contextRequests/updateEntity2b.json +7 -0
  44. package/test/unit/ngsiv2/examples/contextRequests/updateEntity3.json +5 -0
  45. package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest.json +4 -2
  46. package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest2.json +4 -2
  47. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
  48. package/test/unit/ngsiv2/general/https-support-test.js +1 -1
  49. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +245 -2
@@ -63,7 +63,8 @@ const attributeList = [
63
63
  'entityNameExp',
64
64
  'payloadType',
65
65
  'useCBflowControl',
66
- 'storeLastMeasure'
66
+ 'storeLastMeasure',
67
+ 'cmdMode'
67
68
  ];
68
69
 
69
70
  function createGroup(group, callback) {
@@ -105,7 +105,7 @@ function createSubscriptionHandlerNgsiLD(device, triggers, store, callback) {
105
105
  * @param {Object} triggers Array with the names of the attributes that would trigger the subscription
106
106
  * @param {Object} content Array with the names of the attributes to retrieve in the notification.
107
107
  */
108
- function subscribeNgsiLD(device, triggers, content, callback) {
108
+ function subscribeNgsiLD(device, triggers, content, attrsFormat, callback) {
109
109
  const options = {
110
110
  method: 'POST',
111
111
  headers: {
@@ -132,7 +132,7 @@ function subscribeNgsiLD(device, triggers, content, callback) {
132
132
  accept: 'application/json'
133
133
  },
134
134
  attributes: content || [],
135
- format: 'normalized'
135
+ format: attrsFormat
136
136
  }
137
137
  }
138
138
  };
@@ -36,11 +36,11 @@ const subscriptionHandlerV2 = require('./subscription-NGSI-v2');
36
36
  * @param {Object} triggers Array with the names of the attributes that would trigger the subscription
37
37
  * @param {Object} content Array with the names of the attributes to retrieve in the notification.
38
38
  */
39
- function subscribeNgsiMixed(device, triggers, content, callback) {
39
+ function subscribeNgsiMixed(device, triggers, content, attrsFormat, callback) {
40
40
  if (config.checkNgsiLD(device)) {
41
- subscriptionHandlerLD.subscribe(device, triggers, content, callback);
41
+ subscriptionHandlerLD.subscribe(device, triggers, content, attrsFormat, callback);
42
42
  } else {
43
- subscriptionHandlerV2.subscribe(device, triggers, content, callback);
43
+ subscriptionHandlerV2.subscribe(device, triggers, content, attrsFormat, callback);
44
44
  }
45
45
  }
46
46
 
@@ -93,7 +93,9 @@ function createSubscriptionHandlerNgsi2(device, triggers, store, callback) {
93
93
 
94
94
  config.getRegistry().update(device, device, callback);
95
95
  } else {
96
- callback(null, response.headers.location);
96
+ callback(null, {
97
+ subscriptionId: response.headers.location.substr(response.headers.location.lastIndexOf('/') + 1)
98
+ });
97
99
  }
98
100
  };
99
101
  }
@@ -107,7 +109,7 @@ function createSubscriptionHandlerNgsi2(device, triggers, store, callback) {
107
109
  * @param {Object} triggers Array with the names of the attributes that would trigger the subscription
108
110
  * @param {Object} content Array with the names of the attributes to retrieve in the notification.
109
111
  */
110
- function subscribeNgsi2(device, triggers, content, callback) {
112
+ function subscribeNgsi2(device, triggers, content, attrsFormat, callback) {
111
113
  const options = {
112
114
  method: 'POST',
113
115
  headers: {
@@ -115,6 +117,7 @@ function subscribeNgsi2(device, triggers, content, callback) {
115
117
  'fiware-servicepath': device.subservice
116
118
  },
117
119
  json: {
120
+ description: 'Managed by IOTA: ' + device.name + ' ' + device.type + ' ' + triggers.join(','),
118
121
  subject: {
119
122
  entities: [
120
123
  {
@@ -132,7 +135,8 @@ function subscribeNgsi2(device, triggers, content, callback) {
132
135
  url: config.getConfig().providerUrl + '/notify'
133
136
  },
134
137
  attrs: content || [],
135
- attrsFormat: 'normalized'
138
+ attrsFormat: attrsFormat,
139
+ onlyChangedAttrs: true
136
140
  }
137
141
  }
138
142
  };
@@ -167,7 +171,7 @@ function createUnsubscribeHandlerNgsi2(device, id, callback) {
167
171
  if (error) {
168
172
  logger.debug(
169
173
  context,
170
- 'Transport error found subscribing device with id [%s] to entity [%s]',
174
+ 'Transport error found unsubscribing device with id [%s] to entity [%s]',
171
175
  device.id,
172
176
  device.name
173
177
  );
@@ -176,7 +180,9 @@ function createUnsubscribeHandlerNgsi2(device, id, callback) {
176
180
  } else if (response.statusCode !== 204) {
177
181
  logger.debug(
178
182
  context,
179
- 'Unknown error subscribing device with id [%s] to entity [%s]: $s',
183
+ 'Unknown error unsubscribing device with id [%s] to entity [%s]: %s',
184
+ device.id,
185
+ device.name,
180
186
  response.statusCode
181
187
  );
182
188
 
@@ -202,7 +208,15 @@ function createUnsubscribeHandlerNgsi2(device, id, callback) {
202
208
 
203
209
  callback(new errors.BadRequest(body.orionError.details));
204
210
  } else {
205
- device.subscriptions.splice(device.subscriptions.indexOf(id), 1);
211
+ logger.debug(context, 'removing subscription %s from device %j', id, device);
212
+ if (device.subscriptions) {
213
+ // check before try to eliminates
214
+ const index = device.subscriptions.indexOf(id);
215
+ if (index !== -1) {
216
+ // only eliminates if exits
217
+ device.subscriptions.splice(index, 1);
218
+ }
219
+ }
206
220
  config.getRegistry().update(device, device, callback);
207
221
  }
208
222
  };
@@ -57,8 +57,8 @@ function init() {
57
57
  * @param {Object} triggers Array with the names of the attributes that would trigger the subscription
58
58
  * @param {Object} content Array with the names of the attributes to retrieve in the notification.
59
59
  */
60
- function subscribe(device, triggers, content, callback) {
61
- subscriptionHandler.subscribe(device, triggers, content, callback);
60
+ function subscribe(device, triggers, content, attrsFormat, callback) {
61
+ subscriptionHandler.subscribe(device, triggers, content, attrsFormat, callback);
62
62
  }
63
63
 
64
64
  /**
@@ -293,8 +293,10 @@ function handleNotificationNgsi2(req, res, next) {
293
293
  }
294
294
  }
295
295
  logger.debug(context, 'extracted atts %j from dataElement %j', atts, dataElement);
296
- var id = null;
297
- var type = null;
296
+ // FIXME: command execution entity for advancedNotification is still not implemented
297
+ var id = dataElement.id;
298
+ var type = dataElement.type;
299
+
298
300
  if (dataElement.targetEntityId && dataElement.targetEntityId.value) {
299
301
  id = dataElement.targetEntityId.value;
300
302
  }
@@ -67,7 +67,8 @@ const provisioningAPITranslation = {
67
67
  payloadType: 'payloadType',
68
68
  useCBflowControl: 'useCBflowControl',
69
69
  storeLastMeasure: 'storeLastMeasure',
70
- lastMeasure: 'lastMeasure'
70
+ lastMeasure: 'lastMeasure',
71
+ cmdMode: 'cmdMode'
71
72
  };
72
73
 
73
74
  /**
@@ -149,7 +150,8 @@ function handleProvision(req, res, next) {
149
150
  payloadType: body.payloadType,
150
151
  useCBflowControl: body.useCBflowControl,
151
152
  storeLastMeasure: body.storeLastMeasure,
152
- lastMeasure: body.lastMeasure
153
+ lastMeasure: body.lastMeasure,
154
+ cmdMode: body.cmdMode
153
155
  });
154
156
  }
155
157
 
@@ -229,7 +231,8 @@ function toProvisioningAPIFormat(device) {
229
231
  payloadType: device.payloadType,
230
232
  useCBflowControl: device.useCBflowControl,
231
233
  storeLastMeasure: device.storeLastMeasure,
232
- lastMeasure: device.lastMeasure
234
+ lastMeasure: device.lastMeasure,
235
+ cmdMode: device.cmdMode
233
236
  };
234
237
  }
235
238
 
@@ -157,6 +157,10 @@
157
157
  "description": "use CB flowControl option",
158
158
  "type": "boolean"
159
159
  },
160
+ "cmdMode": {
161
+ "description": "CB commands mode",
162
+ "type": "string"
163
+ },
160
164
  "contentType": {
161
165
  "description": "Content type",
162
166
  "type": "string"
@@ -203,6 +207,10 @@
203
207
  "description": "Payload type allowed for measures for this device",
204
208
  "type": "string"
205
209
  },
210
+ "useCBflowControl": {
211
+ "description": "use CB flowControl option",
212
+ "type": "boolean"
213
+ },
206
214
  "storeLastMeasure": {
207
215
  "description": "Store last measure",
208
216
  "type": "boolean"
@@ -210,6 +218,10 @@
210
218
  "lastMeasure": {
211
219
  "description": "last measure",
212
220
  "type": "object"
221
+ },
222
+ "cmdMode": {
223
+ "description": "CB commands mode",
224
+ "type": "string"
213
225
  }
214
226
  }
215
227
  }
@@ -158,6 +158,10 @@
158
158
  "lastMeasure": {
159
159
  "description": "last measure",
160
160
  "type": "object"
161
+ },
162
+ "cmdMode": {
163
+ "description": "CB commands mode",
164
+ "type": "string"
161
165
  }
162
166
  }
163
167
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "iotagent-node-lib",
3
3
  "license": "AGPL-3.0-only",
4
4
  "description": "IoT Agent library to interface with NGSI Context Broker",
5
- "version": "4.9.0",
5
+ "version": "4.11.0",
6
6
  "homepage": "https://github.com/telefonicaid/iotagent-node-lib",
7
7
  "keywords": [
8
8
  "fiware",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "main": "lib/fiware-iotagent-lib",
25
25
  "engines": {
26
- "node": ">=16"
26
+ "node": ">=20"
27
27
  },
28
28
  "scripts": {
29
29
  "clean": "rm -rf package-lock.json && rm -rf node_modules && rm -rf coverage",
@@ -398,6 +398,36 @@ describe('Jexl expression interpreter', function () {
398
398
  });
399
399
  });
400
400
 
401
+ describe('When number localization functions are executed', function () {
402
+ it('should return the localized string representation of the number', function (done) {
403
+ const scope = {
404
+ theNumber: 1234567.89,
405
+ locale: 'es-ES',
406
+ options: { minimumFractionDigits: 2, maximumFractionDigits: 2 }
407
+ };
408
+
409
+ expressionParser.parse('theNumber|localestringnumber(locale, options)', scope, function (error, result) {
410
+ should.not.exist(error);
411
+ result.should.equal('1.234.567,89');
412
+ done();
413
+ });
414
+ });
415
+
416
+ it('should return null for invalid number input', function (done) {
417
+ const scope = {
418
+ theNumber: 'not_a_number',
419
+ locale: 'en-US',
420
+ options: {}
421
+ };
422
+
423
+ expressionParser.parse('theNumber|localestringnumber(locale, options)', scope, function (error, result) {
424
+ should.not.exist(error);
425
+ should.equal(result, null);
426
+ done();
427
+ });
428
+ });
429
+ });
430
+
401
431
  // Check errors
402
432
  describe('When invalid inputs are used', function () {
403
433
  describe('When an invalid JSON string is parsed', function () {
@@ -295,7 +295,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with Keystone', functio
295
295
 
296
296
  it('subscribe requests use auth header', function (done) {
297
297
  iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
298
- iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
298
+ iotAgentLib.subscribe(device, ['dimming'], null, 'normalized', function (error) {
299
299
  should.not.exist(error);
300
300
 
301
301
  contextBrokerMock.done();
@@ -316,7 +316,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with Keystone', functio
316
316
  });
317
317
 
318
318
  iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
319
- iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
319
+ iotAgentLib.subscribe(device, ['dimming'], null, 'normalized', function (error) {
320
320
  iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
321
321
  contextBrokerMock.done();
322
322
  done();
@@ -243,7 +243,7 @@ describe('NGSI-v2 - In memory device registry', function () {
243
243
  should.exist(device.type);
244
244
  device.name.should.equal('name5');
245
245
  device.type.should.equal('Light5');
246
- Object.keys(device).length.should.equal(12);
246
+ Object.keys(device).length.should.equal(13);
247
247
  done();
248
248
  });
249
249
  });
@@ -309,7 +309,7 @@ describe('NGSI-LD - Secured access to the Context Broker with OAuth2 provider',
309
309
 
310
310
  it('subscribe requests use auth header', function (done) {
311
311
  iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
312
- iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
312
+ iotAgentLib.subscribe(device, ['dimming'], null, 'normalized', function (error) {
313
313
  should.not.exist(error);
314
314
 
315
315
  contextBrokerMock.done();
@@ -330,7 +330,7 @@ describe('NGSI-LD - Secured access to the Context Broker with OAuth2 provider',
330
330
  contextBrokerMock.delete('/ngsi-ld/v1/subscriptions/51c0ac9ed714fb3b37d7d5a8', '').reply(204);
331
331
 
332
332
  iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
333
- iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
333
+ iotAgentLib.subscribe(device, ['dimming'], null, 'normalized', function (error) {
334
334
  iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
335
335
  contextBrokerMock.done();
336
336
  done();
@@ -214,7 +214,7 @@ describe('NGSI-LD - HTTPS support tests', function () {
214
214
 
215
215
  it('should send the appropriate request to the Context Broker', function (done) {
216
216
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
217
- iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
217
+ iotAgentLib.subscribe(device, ['attr_name'], null, 'normalized', function (error) {
218
218
  should.not.exist(error);
219
219
 
220
220
  contextBrokerMock.done();
@@ -94,7 +94,7 @@ describe('NGSI-LD - Subscription tests', function () {
94
94
  describe('When a client invokes the subscribe() function for device', function () {
95
95
  it('should send the appropriate request to the Context Broker', function (done) {
96
96
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
97
- iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
97
+ iotAgentLib.subscribe(device, ['attr_name'], null, 'normalized', function (error) {
98
98
  should.not.exist(error);
99
99
 
100
100
  contextBrokerMock.done();
@@ -105,7 +105,7 @@ describe('NGSI-LD - Subscription tests', function () {
105
105
  });
106
106
  it('should store the subscription ID in the Device Registry', function (done) {
107
107
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
108
- iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
108
+ iotAgentLib.subscribe(device, ['attr_name'], null, 'normalized', function (error) {
109
109
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
110
110
  should.not.exist(error);
111
111
  should.exist(device);
@@ -131,7 +131,7 @@ describe('NGSI-LD - Subscription tests', function () {
131
131
 
132
132
  it('should delete the subscription from the CB', function (done) {
133
133
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
134
- iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
134
+ iotAgentLib.subscribe(device, ['attr_name'], null, 'normalized', function (error) {
135
135
  iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
136
136
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
137
137
  contextBrokerMock.done();
@@ -143,7 +143,7 @@ describe('NGSI-LD - Subscription tests', function () {
143
143
  });
144
144
  it('should remove the id from the subscriptions array', function (done) {
145
145
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
146
- iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
146
+ iotAgentLib.subscribe(device, ['attr_name'], null, 'normalized', function (error) {
147
147
  iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
148
148
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
149
149
  should.not.exist(error);
@@ -169,7 +169,7 @@ describe('NGSI-LD - Subscription tests', function () {
169
169
 
170
170
  it('should delete the subscription from the CB', function (done) {
171
171
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
172
- iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
172
+ iotAgentLib.subscribe(device, ['attr_name'], null, 'normalized', function (error) {
173
173
  iotAgentLib.unregister(device.id, null, 'smartgondor', '/gardens', function (error) {
174
174
  contextBrokerMock.done();
175
175
  done();
@@ -181,7 +181,7 @@ describe('NGSI-LD - Subscription tests', function () {
181
181
  describe('When a new notification comes to the IoTAgent', function () {
182
182
  beforeEach(function (done) {
183
183
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
184
- iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
184
+ iotAgentLib.subscribe(device, ['attr_name'], null, 'normalized', function (error) {
185
185
  done();
186
186
  });
187
187
  });
@@ -0,0 +1,24 @@
1
+ {
2
+ "description": "Managed by IOTA: Robot:r2d2 Robot position",
3
+ "subject": {
4
+ "entities":[
5
+ {
6
+ "id":"Robot:r2d2","type":"Robot"
7
+ }
8
+ ],
9
+ "condition": {
10
+ "attrs":["position"]
11
+ }
12
+ },
13
+ "notification":{
14
+ "http":{
15
+ "url":"http://smartgondor.com/notify"
16
+ },
17
+ "attrs":["position"],
18
+ "attrsFormat":"normalized",
19
+ "onlyChangedAttrs":true
20
+ }
21
+ }
22
+
23
+
24
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "description": "Managed by IOTA: RobotT:r2d3 RobotT position",
3
+ "subject": {
4
+ "entities":[
5
+ {
6
+ "id":"RobotT:r2d3","type":"RobotT"
7
+ }
8
+ ],
9
+ "condition": {
10
+ "attrs":["position"]
11
+ }
12
+ },
13
+ "notification":{
14
+ "http":{
15
+ "url":"http://smartgondor.com/notify"
16
+ },
17
+ "attrs":["position"],
18
+ "attrsFormat":"normalized",
19
+ "onlyChangedAttrs":true
20
+ }
21
+ }
22
+
23
+
24
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "description": "Managed by IOTA: RobotT:r2d4 RobotT position",
3
+ "subject": {
4
+ "entities":[
5
+ {
6
+ "id":"RobotT:r2d4","type":"RobotT"
7
+ }
8
+ ],
9
+ "condition": {
10
+ "attrs":["position"]
11
+ }
12
+ },
13
+ "notification":{
14
+ "http":{
15
+ "url":"http://smartgondor.com/notify"
16
+ },
17
+ "attrs":["position"],
18
+ "attrsFormat":"normalized",
19
+ "onlyChangedAttrs":true
20
+ }
21
+ }
22
+
23
+
24
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "description": "Managed by IOTA: RobotT:r2d3 RobotT reset",
3
+ "subject": {
4
+ "entities":[
5
+ {
6
+ "id":"RobotT:r2d3","type":"RobotT"
7
+ }
8
+ ],
9
+ "condition": {
10
+ "attrs":["reset"]
11
+ }
12
+ },
13
+ "notification":{
14
+ "http":{
15
+ "url":"http://smartgondor.com/notify"
16
+ },
17
+ "attrs":["reset"],
18
+ "attrsFormat":"normalized",
19
+ "onlyChangedAttrs":true
20
+ }
21
+ }
22
+
23
+
24
+
@@ -0,0 +1,5 @@
1
+ {
2
+ "id":"Robot:r2d2",
3
+ "type":"Robot",
4
+ "position":{"type":"command","value":null}
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "id":"RobotT:r2d3",
3
+ "type":"RobotT",
4
+ "position":{"type":"command","value":null}
5
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "pressure":{"type":"Hgmm","value":null},
3
+ "reset": {
4
+ "type": "command",
5
+ "value": null
6
+ }
7
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "id":"RobotT:r2d4",
3
+ "type":"RobotT",
4
+ "position":{"type":"command","value":null}
5
+ }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "description": "Managed by IOTA: FirstMicroLight MicroLights attr_name",
2
3
  "subject": {
3
4
  "entities": [
4
5
  {
@@ -17,6 +18,7 @@
17
18
  "url": "http://smartgondor.com/notify"
18
19
  },
19
20
  "attrs": [],
20
- "attrsFormat": "normalized"
21
+ "attrsFormat": "normalized",
22
+ "onlyChangedAttrs": true
21
23
  }
22
- }
24
+ }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "description": "Managed by IOTA: light1 Light dimming",
2
3
  "subject": {
3
4
  "entities": [
4
5
  {
@@ -17,6 +18,7 @@
17
18
  "url": "http://smartgondor.com/notify"
18
19
  },
19
20
  "attrs": [],
20
- "attrsFormat": "normalized"
21
+ "attrsFormat": "normalized",
22
+ "onlyChangedAttrs": true
21
23
  }
22
- }
24
+ }
@@ -312,7 +312,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider',
312
312
 
313
313
  it('subscribe requests use auth header', function (done) {
314
314
  iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
315
- iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
315
+ iotAgentLib.subscribe(device, ['dimming'], null, 'normalized', function (error) {
316
316
  should.not.exist(error);
317
317
 
318
318
  contextBrokerMock.done();
@@ -333,7 +333,7 @@ describe('NGSI-v2 - Secured access to the Context Broker with OAuth2 provider',
333
333
  contextBrokerMock.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8', '').reply(204);
334
334
 
335
335
  iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
336
- iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
336
+ iotAgentLib.subscribe(device, ['dimming'], null, 'normalized', function (error) {
337
337
  iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
338
338
  contextBrokerMock.done();
339
339
  done();
@@ -211,7 +211,7 @@ describe('NGSI-v2 - HTTPS support tests', function () {
211
211
 
212
212
  it('should send the appropriate request to the Context Broker', function (done) {
213
213
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
214
- iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
214
+ iotAgentLib.subscribe(device, ['attr_name'], null, 'normalized', function (error) {
215
215
  should.not.exist(error);
216
216
 
217
217
  contextBrokerMock.done();