node-red-contrib-homekit-bridged 1.7.3 → 2.0.0-dev.1

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 (44) hide show
  1. package/build/lib/HAPHostNode.js +11 -41
  2. package/build/lib/HAPServiceNode.js +6 -6
  3. package/build/lib/HAPServiceNode2.js +6 -6
  4. package/build/lib/Storage.d.ts +1 -1
  5. package/build/lib/api.js +20 -18
  6. package/build/lib/hap/HAPCharacteristic.d.ts +1 -1
  7. package/build/lib/hap/HAPCharacteristic.js +1 -1
  8. package/build/lib/hap/HAPService.d.ts +1 -1
  9. package/build/lib/hap/HAPService.js +1 -1
  10. package/build/lib/hap/eve-app/EveCharacteristics.js +10 -10
  11. package/build/lib/types/CustomCharacteristicType.d.ts +1 -1
  12. package/build/lib/types/HAPHostConfigType.d.ts +1 -9
  13. package/build/lib/types/HAPHostNodeType.d.ts +1 -3
  14. package/build/lib/types/HAPServiceConfigType.d.ts +1 -1
  15. package/build/lib/types/HAPServiceNodeType.d.ts +5 -4
  16. package/build/lib/types/storage/SerializedHostType.d.ts +1 -1
  17. package/build/lib/utils/AccessoryUtils.js +8 -6
  18. package/build/lib/utils/BridgeUtils.js +2 -2
  19. package/build/lib/utils/CharacteristicUtils.js +2 -2
  20. package/build/lib/utils/CharacteristicUtils2.js +2 -2
  21. package/build/lib/utils/ServiceUtils.js +21 -26
  22. package/build/lib/utils/ServiceUtils2.js +17 -20
  23. package/build/lib/utils/index.js +1 -3
  24. package/build/nodes/nrchkb.js +1 -1
  25. package/build/nodes/status.js +4 -4
  26. package/examples/demo/01 - ALL Demos single import.json +64 -318
  27. package/examples/demo/02 - Air Purifier.json +279 -328
  28. package/examples/demo/03 - Air Quality sensor with Battery.json +254 -282
  29. package/examples/demo/04 - Dimmable Bulb.json +172 -189
  30. package/examples/demo/05 - Color Bulb (HSV).json +195 -216
  31. package/examples/demo/06 - Fan (simple, 3 speeds).json +240 -265
  32. package/examples/demo/07 - Fan (with speed, oscillate, rotation direction).json +175 -192
  33. package/examples/demo/08 - CO2 detector.json +224 -255
  34. package/examples/demo/09 - CO (carbon monoxide) example.json +255 -290
  35. package/examples/demo/10 - Door window contact sensor.json +234 -265
  36. package/examples/demos (advanced)/01 - Television with inputs and speaker.json +541 -607
  37. package/examples/switch/01 - Plain Switch.json +7 -27
  38. package/package.json +82 -81
  39. package/build/lib/cameraSource/index.d.ts +0 -1
  40. package/build/lib/cameraSource/index.js +0 -477
  41. package/build/lib/types/hap-nodejs/BonjourMulticastOptions.d.ts +0 -10
  42. package/build/lib/types/hap-nodejs/BonjourMulticastOptions.js +0 -2
  43. package/build/lib/utils/MdnsUtils.d.ts +0 -1
  44. package/build/lib/utils/MdnsUtils.js +0 -93
@@ -37,15 +37,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const util = __importStar(require("node:util"));
40
+ const hap_nodejs_1 = require("@homebridge/hap-nodejs");
40
41
  const logger_1 = require("@nrchkb/logger");
41
- const hap_nodejs_1 = require("hap-nodejs");
42
42
  const NRCHKBError_1 = __importDefault(require("../NRCHKBError"));
43
43
  module.exports = function (node) {
44
44
  const log = (0, logger_1.logger)('NRCHKB', 'ServiceUtils', node.config.name, node);
45
- const HapNodeJS = require('hap-nodejs');
45
+ const HapNodeJS = require('@homebridge/hap-nodejs');
46
46
  const Service = HapNodeJS.Service;
47
47
  const Characteristic = HapNodeJS.Characteristic;
48
- const CameraSource = require('../cameraSource').Camera;
49
48
  const NO_RESPONSE_MSG = 'NO_RESPONSE';
50
49
  const prepareHapData = (context, connection) => {
51
50
  const hap = {};
@@ -55,7 +54,7 @@ module.exports = function (node) {
55
54
  username: connection.username,
56
55
  remoteAddress: connection.remoteAddress,
57
56
  localAddress: connection.localAddress,
58
- httpPort: connection.remotePort,
57
+ httpPort: connection.remotePort
59
58
  };
60
59
  hap.context = {};
61
60
  }
@@ -98,7 +97,7 @@ module.exports = function (node) {
98
97
  fill: 'red',
99
98
  shape: 'ring',
100
99
  text: 'Not reachable',
101
- type: 'NO_RESPONSE',
100
+ type: 'NO_RESPONSE'
102
101
  }));
103
102
  }
104
103
  else {
@@ -106,15 +105,13 @@ module.exports = function (node) {
106
105
  node.nodeStatusUtils.setStatus({
107
106
  fill: 'yellow',
108
107
  shape: 'dot',
109
- text: key + ': ' + newValue,
108
+ text: key + ': ' + newValue
110
109
  }, 3000);
111
110
  (_d = node.childNodes) === null || _d === void 0 ? void 0 : _d.forEach((n) => n.nodeStatusUtils.clearStatusByType('NO_RESPONSE'));
112
111
  (_e = node.parentNode) === null || _e === void 0 ? void 0 : _e.nodeStatusUtils.clearStatusByType('NO_RESPONSE');
113
112
  }
114
113
  log.debug(`${node.name} received ${key} : ${newValue}`);
115
- if (connection ||
116
- context ||
117
- node.hostNode.config.allowMessagePassthrough) {
114
+ if (connection || context || node.hostNode.config.allowMessagePassthrough) {
118
115
  if (outputNumber === 0) {
119
116
  node.send(msg);
120
117
  }
@@ -137,7 +134,7 @@ module.exports = function (node) {
137
134
  catch (_) { }
138
135
  onValueChange.call(this, allCharacteristics, 1, {
139
136
  newValue,
140
- context,
137
+ context
141
138
  }, connection);
142
139
  };
143
140
  const onCharacteristicChange = (allCharacteristics) => function (change) {
@@ -149,7 +146,7 @@ module.exports = function (node) {
149
146
  onValueChange.call(this, allCharacteristics, 0, {
150
147
  oldValue,
151
148
  newValue,
152
- context,
149
+ context
153
150
  }, originator);
154
151
  }
155
152
  };
@@ -198,7 +195,7 @@ module.exports = function (node) {
198
195
  parentNode.reachable = value !== NO_RESPONSE_MSG;
199
196
  const characteristic = node.service.getCharacteristic(Characteristic[key]);
200
197
  if (context !== null) {
201
- characteristic.setValue(value, undefined, context);
198
+ characteristic.setValue(value, context);
202
199
  }
203
200
  else {
204
201
  characteristic.setValue(value);
@@ -266,14 +263,13 @@ module.exports = function (node) {
266
263
  }
267
264
  return service;
268
265
  };
269
- const configureCameraSource = function (accessory, service, config) {
266
+ const configureCameraSource = function (_accessory, _service, config) {
270
267
  if (config.cameraConfigSource) {
271
268
  log.debug('Configuring Camera Source');
272
269
  if (!config.cameraConfigVideoProcessor) {
273
270
  log.error('Missing configuration for CameraControl: videoProcessor cannot be empty!');
274
271
  }
275
272
  else {
276
- accessory.configureCameraSource(new CameraSource(service, config, node));
277
273
  }
278
274
  }
279
275
  else {
@@ -286,7 +282,7 @@ module.exports = function (node) {
286
282
  node.nodeStatusUtils.setStatus({
287
283
  fill: 'blue',
288
284
  shape: 'dot',
289
- text: 'Waiting for Parent Service',
285
+ text: 'Waiting for Parent Service'
290
286
  });
291
287
  const checkAndWait = () => {
292
288
  const parentNode = node.RED.nodes.getNode(node.config.parentService);
@@ -331,9 +327,8 @@ module.exports = function (node) {
331
327
  : 1,
332
328
  customTemperatureAdjustment: node.config
333
329
  .adaptiveLightingOptionsCustomTemperatureAdjustment
334
- ? +node.config
335
- .adaptiveLightingOptionsCustomTemperatureAdjustment
336
- : undefined,
330
+ ? +node.config.adaptiveLightingOptionsCustomTemperatureAdjustment
331
+ : undefined
337
332
  };
338
333
  log.trace(`Configuring Adaptive Lighting with options: ${options}`);
339
334
  const adaptiveLightingController = new hap_nodejs_1.AdaptiveLightingController(node.service, options);
@@ -344,24 +339,24 @@ module.exports = function (node) {
344
339
  transitionCurve: adaptiveLightingController.getAdaptiveLightingTransitionCurve(),
345
340
  brightnessAdjustmentRange: adaptiveLightingController.getAdaptiveLightingBrightnessMultiplierRange(),
346
341
  updateInterval: adaptiveLightingController.getAdaptiveLightingUpdateInterval(),
347
- notifyIntervalThreshold: adaptiveLightingController.getAdaptiveLightingNotifyIntervalThreshold(),
342
+ notifyIntervalThreshold: adaptiveLightingController.getAdaptiveLightingNotifyIntervalThreshold()
348
343
  };
349
344
  node.send({
350
345
  payload: {
351
346
  AdaptiveLightingController: {
352
347
  event: 'update',
353
- data: activeAdaptiveLightingTransition,
354
- },
355
- },
348
+ data: activeAdaptiveLightingTransition
349
+ }
350
+ }
356
351
  });
357
352
  });
358
353
  adaptiveLightingController.on('disable', () => {
359
354
  node.send({
360
355
  payload: {
361
356
  AdaptiveLightingController: {
362
- event: 'disable',
363
- },
364
- },
357
+ event: 'disable'
358
+ }
359
+ }
365
360
  });
366
361
  });
367
362
  node.accessory.configureController(adaptiveLightingController);
@@ -381,6 +376,6 @@ module.exports = function (node) {
381
376
  onClose,
382
377
  waitForParent,
383
378
  handleWaitForSetup,
384
- configureAdaptiveLightning,
379
+ configureAdaptiveLightning
385
380
  };
386
381
  };
@@ -3,17 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const hap_nodejs_1 = require("@homebridge/hap-nodejs");
6
7
  const logger_1 = require("@nrchkb/logger");
7
- const hap_nodejs_1 = require("hap-nodejs");
8
8
  const NRCHKBError_1 = __importDefault(require("../NRCHKBError"));
9
9
  const Storage_1 = require("../Storage");
10
10
  module.exports = function (node) {
11
11
  const log = (0, logger_1.logger)('NRCHKB', 'ServiceUtils2', node.config.name, node);
12
12
  const ServiceUtilsLegacy = require('./ServiceUtils')(node);
13
- const HapNodeJS = require('hap-nodejs');
13
+ const HapNodeJS = require('@homebridge/hap-nodejs');
14
14
  const Service = HapNodeJS.Service;
15
15
  const Characteristic = HapNodeJS.Characteristic;
16
- const CameraSource = require('../cameraSource').Camera;
17
16
  const NO_RESPONSE_MSG = 'NO_RESPONSE';
18
17
  const output = function (allCharacteristics, event, { oldValue, newValue }, connection) {
19
18
  var _a, _b, _c, _d, _e;
@@ -21,7 +20,7 @@ module.exports = function (node) {
21
20
  log.debug(`${eventObject.name} event, oldValue: ${oldValue}, newValue: ${newValue}, connection ${connection === null || connection === void 0 ? void 0 : connection.sessionID}`);
22
21
  const msg = {
23
22
  name: node.name,
24
- topic: node.config.topic ? node.config.topic : node.topic_in,
23
+ topic: node.config.topic ? node.config.topic : node.topic_in
25
24
  };
26
25
  msg.payload = {};
27
26
  msg.hap = {
@@ -31,7 +30,7 @@ module.exports = function (node) {
31
30
  allChars[cKey] = singleChar.value;
32
31
  return allChars;
33
32
  }, {}),
34
- oldValue,
33
+ oldValue
35
34
  };
36
35
  const key = this.constructor.name;
37
36
  msg.hap.reachable = (_a = node.reachable) !== null && _a !== void 0 ? _a : (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.reachable;
@@ -41,7 +40,7 @@ module.exports = function (node) {
41
40
  fill: 'red',
42
41
  shape: 'ring',
43
42
  text: 'Not reachable',
44
- type: 'NO_RESPONSE',
43
+ type: 'NO_RESPONSE'
45
44
  }));
46
45
  }
47
46
  else {
@@ -49,7 +48,7 @@ module.exports = function (node) {
49
48
  node.nodeStatusUtils.setStatus({
50
49
  fill: 'yellow',
51
50
  shape: 'dot',
52
- text: `[${eventObject.name}] ${key}${newValue != undefined ? `: ${newValue}` : ''}`,
51
+ text: `[${eventObject.name}] ${key}${newValue != undefined ? `: ${newValue}` : ''}`
53
52
  }, 3000);
54
53
  (_d = node.childNodes) === null || _d === void 0 ? void 0 : _d.forEach((n) => n.nodeStatusUtils.clearStatusByType('NO_RESPONSE'));
55
54
  (_e = node.parentNode) === null || _e === void 0 ? void 0 : _e.nodeStatusUtils.clearStatusByType('NO_RESPONSE');
@@ -61,7 +60,7 @@ module.exports = function (node) {
61
60
  username: connection.username,
62
61
  remoteAddress: connection.remoteAddress,
63
62
  localAddress: connection.localAddress,
64
- httpPort: connection.remotePort,
63
+ httpPort: connection.remotePort
65
64
  };
66
65
  }
67
66
  log.debug(`${node.name} received ${eventObject.name} ${key}: ${newValue}`);
@@ -85,18 +84,18 @@ module.exports = function (node) {
85
84
  }
86
85
  output.call(characteristic, allCharacteristics, {
87
86
  name: "get",
88
- context: { key: this.displayName },
87
+ context: { key: this.displayName }
89
88
  }, { oldValue, newValue }, connection);
90
89
  };
91
90
  if (node.config.useEventCallback) {
92
91
  const callbackID = Storage_1.Storage.saveCallback({
93
92
  event: "get",
94
- callback: delayedCallback,
93
+ callback: delayedCallback
95
94
  });
96
95
  log.debug(`Registered callback ${callbackID} for Characteristic ${characteristic.displayName}`);
97
96
  output.call(this, allCharacteristics, {
98
97
  name: "get",
99
- context: { callbackID, key: this.displayName },
98
+ context: { callbackID, key: this.displayName }
100
99
  }, { oldValue }, connection);
101
100
  }
102
101
  else {
@@ -115,7 +114,7 @@ module.exports = function (node) {
115
114
  catch (_) { }
116
115
  output.call(this, allCharacteristics, {
117
116
  name: "set",
118
- context: { key: this.displayName },
117
+ context: { key: this.displayName }
119
118
  }, { newValue }, connection);
120
119
  };
121
120
  const onCharacteristicChange = (allCharacteristics) => function (change) {
@@ -123,7 +122,7 @@ module.exports = function (node) {
123
122
  if (oldValue != newValue) {
124
123
  output.call(this, allCharacteristics, {
125
124
  name: "change",
126
- context: { reason, key: this.displayName },
125
+ context: { reason, key: this.displayName }
127
126
  }, { oldValue, newValue, context }, originator);
128
127
  }
129
128
  };
@@ -154,8 +153,7 @@ module.exports = function (node) {
154
153
  Object.keys(msg.payload).map((key) => {
155
154
  var _a, _b, _c, _d, _e;
156
155
  if (node.supported.indexOf(key) < 0) {
157
- if (node.config.useEventCallback &&
158
- Storage_1.Storage.uuid4Validate(key)) {
156
+ if (node.config.useEventCallback && Storage_1.Storage.uuid4Validate(key)) {
159
157
  const callbackID = key;
160
158
  const callbackValue = (_a = msg.payload) === null || _a === void 0 ? void 0 : _a[key];
161
159
  const eventCallback = Storage_1.Storage.loadCallback(callbackID);
@@ -185,7 +183,7 @@ module.exports = function (node) {
185
183
  parentNode.reachable = value !== NO_RESPONSE_MSG;
186
184
  const characteristic = node.service.getCharacteristic(Characteristic[key]);
187
185
  if (context !== null) {
188
- characteristic.setValue(value, undefined, context);
186
+ characteristic.setValue(value, context);
189
187
  }
190
188
  else {
191
189
  characteristic.setValue(value);
@@ -253,14 +251,13 @@ module.exports = function (node) {
253
251
  }
254
252
  return service;
255
253
  };
256
- const configureCameraSource = function (accessory, service, config) {
254
+ const configureCameraSource = function (_accessory, _service, config) {
257
255
  if (config.cameraConfigSource) {
258
256
  log.debug('Configuring Camera Source');
259
257
  if (!config.cameraConfigVideoProcessor) {
260
258
  log.error('Missing configuration for CameraControl: videoProcessor cannot be empty!');
261
259
  }
262
260
  else {
263
- accessory.configureCameraSource(new CameraSource(service, config, node));
264
261
  }
265
262
  }
266
263
  else {
@@ -273,7 +270,7 @@ module.exports = function (node) {
273
270
  node.nodeStatusUtils.setStatus({
274
271
  fill: 'blue',
275
272
  shape: 'dot',
276
- text: 'Waiting for Parent Service',
273
+ text: 'Waiting for Parent Service'
277
274
  });
278
275
  const checkAndWait = () => {
279
276
  const parentNode = node.RED.nodes.getNode(node.config.parentService);
@@ -315,6 +312,6 @@ module.exports = function (node) {
315
312
  onClose,
316
313
  waitForParent,
317
314
  handleWaitForSetup,
318
- configureAdaptiveLightning: ServiceUtilsLegacy.configureAdaptiveLightning,
315
+ configureAdaptiveLightning: ServiceUtilsLegacy.configureAdaptiveLightning
319
316
  };
320
317
  };
@@ -5,12 +5,10 @@ module.exports = function (node) {
5
5
  const BridgeUtils = require('./BridgeUtils')();
6
6
  const AccessoryUtils = require('./AccessoryUtils')(node);
7
7
  const CharacteristicUtils = require('./CharacteristicUtils')(node);
8
- const MdnsUtils = require('./MdnsUtils')();
9
8
  return {
10
9
  ServiceUtils,
11
10
  BridgeUtils,
12
11
  AccessoryUtils,
13
- CharacteristicUtils,
14
- MdnsUtils,
12
+ CharacteristicUtils
15
13
  };
16
14
  };
@@ -36,8 +36,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ const hap_nodejs_1 = require("@homebridge/hap-nodejs");
39
40
  const logger_1 = require("@nrchkb/logger");
40
- const hap_nodejs_1 = require("hap-nodejs");
41
41
  const path = __importStar(require("path"));
42
42
  const semver_1 = __importDefault(require("semver"));
43
43
  const Storage_1 = require("../lib/Storage");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hap_nodejs_1 = require("@homebridge/hap-nodejs");
3
4
  const logger_1 = require("@nrchkb/logger");
4
- const hap_nodejs_1 = require("hap-nodejs");
5
5
  const NodeStatusUtils_1 = require("../lib/utils/NodeStatusUtils");
6
6
  const log = (0, logger_1.logger)('NRCHKB', 'HAPStatusNode');
7
7
  module.exports = (RED) => {
@@ -22,18 +22,18 @@ module.exports = (RED) => {
22
22
  self.nodeStatusUtils.setStatus({
23
23
  fill: 'green',
24
24
  shape: 'dot',
25
- text: 'Done',
25
+ text: 'Done'
26
26
  }, 3000);
27
27
  const serializedService = hap_nodejs_1.Service.serialize(self.serviceNode.service);
28
28
  self.send({
29
- payload: serializedService,
29
+ payload: serializedService
30
30
  });
31
31
  }
32
32
  else {
33
33
  self.nodeStatusUtils.setStatus({
34
34
  fill: 'red',
35
35
  shape: 'dot',
36
- text: 'Check your config',
36
+ text: 'Check your config'
37
37
  });
38
38
  }
39
39
  });