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

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 (32) hide show
  1. package/build/lib/HAPHostNode.js +59 -62
  2. package/build/lib/HAPServiceNode.js +89 -93
  3. package/build/lib/HAPServiceNode2.js +91 -95
  4. package/build/lib/Storage.d.ts +3 -3
  5. package/build/lib/Storage.js +2 -2
  6. package/build/lib/api.js +9 -11
  7. package/build/lib/hap/HAPCharacteristic.d.ts +1 -1
  8. package/build/lib/hap/HAPService.d.ts +1 -1
  9. package/build/lib/hap/eve-app/EveCharacteristics.d.ts +1 -1
  10. package/build/lib/types/CustomCharacteristicType.d.ts +1 -1
  11. package/build/lib/types/HAPHostConfigType.d.ts +4 -4
  12. package/build/lib/types/HAPHostNodeType.d.ts +4 -4
  13. package/build/lib/types/HAPService2ConfigType.d.ts +2 -2
  14. package/build/lib/types/HAPService2NodeType.d.ts +3 -3
  15. package/build/lib/types/HAPServiceConfigType.d.ts +3 -3
  16. package/build/lib/types/HAPServiceNodeType.d.ts +10 -10
  17. package/build/lib/types/HAPStatusConfigType.d.ts +1 -1
  18. package/build/lib/types/HAPStatusNodeType.d.ts +5 -5
  19. package/build/lib/types/NodeType.d.ts +1 -1
  20. package/build/lib/types/storage/SerializedHostType.d.ts +2 -2
  21. package/build/lib/utils/AccessoryUtils.js +8 -10
  22. package/build/lib/utils/BridgeUtils.js +4 -4
  23. package/build/lib/utils/CharacteristicUtils.js +5 -5
  24. package/build/lib/utils/CharacteristicUtils2.js +5 -5
  25. package/build/lib/utils/NodeStatusUtils.d.ts +2 -2
  26. package/build/lib/utils/NodeStatusUtils.js +2 -2
  27. package/build/lib/utils/ServiceUtils.js +24 -20
  28. package/build/lib/utils/ServiceUtils2.js +28 -25
  29. package/build/lib/utils/index.js +1 -1
  30. package/build/nodes/nrchkb.js +2 -2
  31. package/build/nodes/status.js +12 -13
  32. package/package.json +3 -2
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const hap_nodejs_1 = require("@homebridge/hap-nodejs");
4
4
  const logger_1 = require("@nrchkb/logger");
5
- module.exports = function (node) {
5
+ module.exports = (node) => {
6
6
  const log = (0, logger_1.logger)('NRCHKB', 'CharacteristicUtils', node.config.name, node);
7
7
  const ServiceUtils = require('./ServiceUtils')(node);
8
- const load = function (service, config) {
8
+ const load = (service, config) => {
9
9
  let characteristicProperties = {};
10
10
  if (config.characteristicProperties &&
11
11
  config.characteristicProperties.length > 0) {
@@ -15,7 +15,7 @@ module.exports = function (node) {
15
15
  log.trace('Evaluated as:');
16
16
  log.trace(JSON.stringify(characteristicProperties));
17
17
  for (const key in characteristicProperties) {
18
- if (!characteristicProperties.hasOwnProperty(key))
18
+ if (!Object.hasOwn(characteristicProperties, key))
19
19
  continue;
20
20
  const characteristic = service.getCharacteristic(hap_nodejs_1.Characteristic[key]);
21
21
  if (characteristic && characteristicProperties[key]) {
@@ -26,13 +26,13 @@ module.exports = function (node) {
26
26
  }
27
27
  return characteristicProperties;
28
28
  };
29
- const subscribeAndGetSupported = function (service) {
29
+ const subscribeAndGetSupported = (service) => {
30
30
  const supported = [];
31
31
  const allCharacteristics = service.characteristics.concat(service.optionalCharacteristics);
32
32
  node.onCharacteristicGet = ServiceUtils.onCharacteristicGet;
33
33
  node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(service.characteristics);
34
34
  node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(service.characteristics);
35
- allCharacteristics.map((characteristic) => {
35
+ allCharacteristics.forEach((characteristic) => {
36
36
  const cKey = characteristic.constructor.name;
37
37
  supported.push(cKey);
38
38
  characteristic.on('get', node.onCharacteristicGet);
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const hap_nodejs_1 = require("@homebridge/hap-nodejs");
4
4
  const logger_1 = require("@nrchkb/logger");
5
- module.exports = function (node) {
5
+ module.exports = (node) => {
6
6
  const log = (0, logger_1.logger)('NRCHKB', 'CharacteristicUtils', node.config.name, node);
7
7
  const ServiceUtils = require('./ServiceUtils2')(node);
8
- const load = function (service, config) {
8
+ const load = (service, config) => {
9
9
  let characteristicProperties = {};
10
10
  if (config.characteristicProperties &&
11
11
  config.characteristicProperties.length > 0) {
@@ -15,7 +15,7 @@ module.exports = function (node) {
15
15
  log.trace('Evaluated as:');
16
16
  log.trace(JSON.stringify(characteristicProperties));
17
17
  for (const key in characteristicProperties) {
18
- if (!characteristicProperties.hasOwnProperty(key))
18
+ if (!Object.hasOwn(characteristicProperties, key))
19
19
  continue;
20
20
  const characteristic = service.getCharacteristic(hap_nodejs_1.Characteristic[key]);
21
21
  if (characteristic && characteristicProperties[key]) {
@@ -26,13 +26,13 @@ module.exports = function (node) {
26
26
  }
27
27
  return characteristicProperties;
28
28
  };
29
- const subscribeAndGetSupported = function (service) {
29
+ const subscribeAndGetSupported = (service) => {
30
30
  const supported = [];
31
31
  const allCharacteristics = service.characteristics.concat(service.optionalCharacteristics);
32
32
  node.onCharacteristicGet = ServiceUtils.onCharacteristicGet(service.characteristics);
33
33
  node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(service.characteristics);
34
34
  node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(service.characteristics);
35
- allCharacteristics.map((characteristic) => {
35
+ allCharacteristics.forEach((characteristic) => {
36
36
  const cKey = characteristic.constructor.name;
37
37
  supported.push(cKey);
38
38
  characteristic.on('get', node.onCharacteristicGet);
@@ -1,5 +1,5 @@
1
- import { NodeStatus } from '@node-red/registry';
2
- import NodeType from '../types/NodeType';
1
+ import type { NodeStatus } from '@node-red/registry';
2
+ import type NodeType from '../types/NodeType';
3
3
  type StatusType = 'NO_RESPONSE' | 'MSG';
4
4
  type NodeStatusWithType = NodeStatus & {
5
5
  type?: StatusType;
@@ -9,7 +9,7 @@ class NodeStatusUtils {
9
9
  setStatus(status, timeout) {
10
10
  var _a;
11
11
  this.node.status(status);
12
- const newStatusId = new Date().getTime();
12
+ const newStatusId = Date.now();
13
13
  this.lastStatusId = newStatusId;
14
14
  if (typeof status !== 'string') {
15
15
  this.lastStatusType = (_a = status.type) !== null && _a !== void 0 ? _a : DEFAULT_STATUS_TYPE;
@@ -31,7 +31,7 @@ class NodeStatusUtils {
31
31
  if (statusId !== undefined) {
32
32
  if (statusId === this.lastStatusId) {
33
33
  if (timeout) {
34
- setTimeout(function (nodeStatusUtil) {
34
+ setTimeout((nodeStatusUtil) => {
35
35
  nodeStatusUtil.clearStatus(statusId);
36
36
  }, timeout, this);
37
37
  }
@@ -40,7 +40,7 @@ const util = __importStar(require("node:util"));
40
40
  const hap_nodejs_1 = require("@homebridge/hap-nodejs");
41
41
  const logger_1 = require("@nrchkb/logger");
42
42
  const NRCHKBError_1 = __importDefault(require("../NRCHKBError"));
43
- module.exports = function (node) {
43
+ module.exports = (node) => {
44
44
  const log = (0, logger_1.logger)('NRCHKB', 'ServiceUtils', node.config.name, node);
45
45
  const HapNodeJS = require('@homebridge/hap-nodejs');
46
46
  const Service = HapNodeJS.Service;
@@ -93,21 +93,25 @@ module.exports = function (node) {
93
93
  msg.hap.reachable = (_a = node.reachable) !== null && _a !== void 0 ? _a : (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.reachable;
94
94
  if (msg.hap.reachable === false) {
95
95
  ;
96
- [node, ...((_c = node.childNodes) !== null && _c !== void 0 ? _c : [])].forEach((n) => n.nodeStatusUtils.setStatus({
97
- fill: 'red',
98
- shape: 'ring',
99
- text: 'Not reachable',
100
- type: 'NO_RESPONSE'
101
- }));
96
+ [node, ...((_c = node.childNodes) !== null && _c !== void 0 ? _c : [])].forEach((n) => {
97
+ n.nodeStatusUtils.setStatus({
98
+ fill: 'red',
99
+ shape: 'ring',
100
+ text: 'Not reachable',
101
+ type: 'NO_RESPONSE'
102
+ });
103
+ });
102
104
  }
103
105
  else {
104
106
  msg.hap.newValue = newValue;
105
107
  node.nodeStatusUtils.setStatus({
106
108
  fill: 'yellow',
107
109
  shape: 'dot',
108
- text: key + ': ' + newValue
110
+ text: `${key}: ${newValue}`
109
111
  }, 3000);
110
- (_d = node.childNodes) === null || _d === void 0 ? void 0 : _d.forEach((n) => n.nodeStatusUtils.clearStatusByType('NO_RESPONSE'));
112
+ (_d = node.childNodes) === null || _d === void 0 ? void 0 : _d.forEach((n) => {
113
+ n.nodeStatusUtils.clearStatusByType('NO_RESPONSE');
114
+ });
111
115
  (_e = node.parentNode) === null || _e === void 0 ? void 0 : _e.nodeStatusUtils.clearStatusByType('NO_RESPONSE');
112
116
  }
113
117
  log.debug(`${node.name} received ${key} : ${newValue}`);
@@ -142,7 +146,7 @@ module.exports = function (node) {
142
146
  const { oldValue, newValue, context, originator, reason } = change;
143
147
  log.debug(`onCharacteristicChange with reason: ${reason}, oldValue: ${oldValue}, newValue: ${newValue}, reachability is ${((_a = node.parentNode) !== null && _a !== void 0 ? _a : node).reachable}
144
148
  with context ${util.inspect(context)} on connection ${originator === null || originator === void 0 ? void 0 : originator.sessionID}`);
145
- if (oldValue != newValue) {
149
+ if (oldValue !== newValue) {
146
150
  onValueChange.call(this, allCharacteristics, 0, {
147
151
  oldValue,
148
152
  newValue,
@@ -150,7 +154,7 @@ module.exports = function (node) {
150
154
  }, originator);
151
155
  }
152
156
  };
153
- const onInput = function (msg) {
157
+ const onInput = (msg) => {
154
158
  var _a, _b;
155
159
  if (msg.payload) {
156
160
  const type = typeof msg.payload;
@@ -174,7 +178,7 @@ module.exports = function (node) {
174
178
  delete msg.payload.Context;
175
179
  }
176
180
  node.topic_in = (_b = msg.topic) !== null && _b !== void 0 ? _b : '';
177
- Object.keys(msg.payload).map((key) => {
181
+ Object.keys(msg.payload).forEach((key) => {
178
182
  var _a, _b, _c, _d;
179
183
  if (node.supported.indexOf(key) < 0) {
180
184
  if (key === 'AdaptiveLightingController' &&
@@ -203,9 +207,9 @@ module.exports = function (node) {
203
207
  }
204
208
  });
205
209
  };
206
- const onClose = function (removed, done) {
210
+ const onClose = (removed, done) => {
207
211
  const characteristics = node.service.characteristics.concat(node.service.optionalCharacteristics);
208
- characteristics.forEach(function (characteristic) {
212
+ characteristics.forEach((characteristic) => {
209
213
  characteristic.removeListener('get', node.onCharacteristicGet);
210
214
  characteristic.removeListener('set', node.onCharacteristicSet);
211
215
  characteristic.removeListener('change', node.onCharacteristicChange);
@@ -225,7 +229,7 @@ module.exports = function (node) {
225
229
  }
226
230
  done();
227
231
  };
228
- const getOrCreate = function (accessory, serviceInformation, parentService) {
232
+ const getOrCreate = (accessory, serviceInformation, parentService) => {
229
233
  const newService = new Service[serviceInformation.serviceName](serviceInformation.name, serviceInformation.UUID);
230
234
  log.debug(`Looking for service with UUID ${serviceInformation.UUID} ...`);
231
235
  let service = accessory.services.find((service) => {
@@ -263,7 +267,7 @@ module.exports = function (node) {
263
267
  }
264
268
  return service;
265
269
  };
266
- const configureCameraSource = function (_accessory, _service, config) {
270
+ const configureCameraSource = (_accessory, _service, config) => {
267
271
  if (config.cameraConfigSource) {
268
272
  log.debug('Configuring Camera Source');
269
273
  if (!config.cameraConfigVideoProcessor) {
@@ -286,7 +290,7 @@ module.exports = function (node) {
286
290
  });
287
291
  const checkAndWait = () => {
288
292
  const parentNode = node.RED.nodes.getNode(node.config.parentService);
289
- if (parentNode && parentNode.configured) {
293
+ if (parentNode === null || parentNode === void 0 ? void 0 : parentNode.configured) {
290
294
  resolve(parentNode);
291
295
  }
292
296
  else {
@@ -303,9 +307,9 @@ module.exports = function (node) {
303
307
  if (node.setupDone) {
304
308
  return;
305
309
  }
306
- if (msg.hasOwnProperty('payload') &&
307
- msg.payload.hasOwnProperty('nrchkb') &&
308
- msg.payload.nrchkb.hasOwnProperty('setup')) {
310
+ if (Object.hasOwn(msg, 'payload') &&
311
+ Object.hasOwn(msg.payload, 'nrchkb') &&
312
+ Object.hasOwn(msg.payload.nrchkb, 'setup')) {
309
313
  node.setupDone = true;
310
314
  const newConfig = Object.assign(Object.assign({}, config), msg.payload.nrchkb.setup);
311
315
  node.removeListener('input', node.handleWaitForSetup);
@@ -7,7 +7,7 @@ const hap_nodejs_1 = require("@homebridge/hap-nodejs");
7
7
  const logger_1 = require("@nrchkb/logger");
8
8
  const NRCHKBError_1 = __importDefault(require("../NRCHKBError"));
9
9
  const Storage_1 = require("../Storage");
10
- module.exports = function (node) {
10
+ module.exports = (node) => {
11
11
  const log = (0, logger_1.logger)('NRCHKB', 'ServiceUtils2', node.config.name, node);
12
12
  const ServiceUtilsLegacy = require('./ServiceUtils')(node);
13
13
  const HapNodeJS = require('@homebridge/hap-nodejs');
@@ -36,21 +36,25 @@ module.exports = function (node) {
36
36
  msg.hap.reachable = (_a = node.reachable) !== null && _a !== void 0 ? _a : (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.reachable;
37
37
  if (msg.hap.reachable === false) {
38
38
  ;
39
- [node, ...((_c = node.childNodes) !== null && _c !== void 0 ? _c : [])].forEach((n) => n.nodeStatusUtils.setStatus({
40
- fill: 'red',
41
- shape: 'ring',
42
- text: 'Not reachable',
43
- type: 'NO_RESPONSE'
44
- }));
39
+ [node, ...((_c = node.childNodes) !== null && _c !== void 0 ? _c : [])].forEach((n) => {
40
+ n.nodeStatusUtils.setStatus({
41
+ fill: 'red',
42
+ shape: 'ring',
43
+ text: 'Not reachable',
44
+ type: 'NO_RESPONSE'
45
+ });
46
+ });
45
47
  }
46
48
  else {
47
49
  msg.hap.newValue = newValue;
48
50
  node.nodeStatusUtils.setStatus({
49
51
  fill: 'yellow',
50
52
  shape: 'dot',
51
- text: `[${eventObject.name}] ${key}${newValue != undefined ? `: ${newValue}` : ''}`
53
+ text: `[${eventObject.name}] ${key}${newValue !== undefined ? `: ${newValue}` : ''}`
52
54
  }, 3000);
53
- (_d = node.childNodes) === null || _d === void 0 ? void 0 : _d.forEach((n) => n.nodeStatusUtils.clearStatusByType('NO_RESPONSE'));
55
+ (_d = node.childNodes) === null || _d === void 0 ? void 0 : _d.forEach((n) => {
56
+ n.nodeStatusUtils.clearStatusByType('NO_RESPONSE');
57
+ });
54
58
  (_e = node.parentNode) === null || _e === void 0 ? void 0 : _e.nodeStatusUtils.clearStatusByType('NO_RESPONSE');
55
59
  }
56
60
  msg.payload[key] = newValue;
@@ -69,11 +73,10 @@ module.exports = function (node) {
69
73
  }
70
74
  };
71
75
  const onCharacteristicGet = (allCharacteristics) => function (callback, _context, connection) {
72
- const characteristic = this;
73
- const oldValue = characteristic.value;
76
+ const oldValue = this.value;
74
77
  const delayedCallback = (value) => {
75
78
  var _a;
76
- const newValue = value !== null && value !== void 0 ? value : characteristic.value;
79
+ const newValue = value !== null && value !== void 0 ? value : this.value;
77
80
  if (callback) {
78
81
  try {
79
82
  callback(((_a = node.parentNode) !== null && _a !== void 0 ? _a : node).reachable
@@ -82,7 +85,7 @@ module.exports = function (node) {
82
85
  }
83
86
  catch (_) { }
84
87
  }
85
- output.call(characteristic, allCharacteristics, {
88
+ output.call(this, allCharacteristics, {
86
89
  name: "get",
87
90
  context: { key: this.displayName }
88
91
  }, { oldValue, newValue }, connection);
@@ -92,7 +95,7 @@ module.exports = function (node) {
92
95
  event: "get",
93
96
  callback: delayedCallback
94
97
  });
95
- log.debug(`Registered callback ${callbackID} for Characteristic ${characteristic.displayName}`);
98
+ log.debug(`Registered callback ${callbackID} for Characteristic ${this.displayName}`);
96
99
  output.call(this, allCharacteristics, {
97
100
  name: "get",
98
101
  context: { callbackID, key: this.displayName }
@@ -119,14 +122,14 @@ module.exports = function (node) {
119
122
  };
120
123
  const onCharacteristicChange = (allCharacteristics) => function (change) {
121
124
  const { oldValue, newValue, context, originator, reason } = change;
122
- if (oldValue != newValue) {
125
+ if (oldValue !== newValue) {
123
126
  output.call(this, allCharacteristics, {
124
127
  name: "change",
125
128
  context: { reason, key: this.displayName }
126
129
  }, { oldValue, newValue, context }, originator);
127
130
  }
128
131
  };
129
- const onInput = function (msg) {
132
+ const onInput = (msg) => {
130
133
  var _a, _b;
131
134
  if (msg.payload) {
132
135
  const type = typeof msg.payload;
@@ -150,7 +153,7 @@ module.exports = function (node) {
150
153
  delete msg.payload.Context;
151
154
  }
152
155
  node.topic_in = (_b = msg.topic) !== null && _b !== void 0 ? _b : '';
153
- Object.keys(msg.payload).map((key) => {
156
+ Object.keys(msg.payload).forEach((key) => {
154
157
  var _a, _b, _c, _d, _e;
155
158
  if (node.supported.indexOf(key) < 0) {
156
159
  if (node.config.useEventCallback && Storage_1.Storage.uuid4Validate(key)) {
@@ -191,9 +194,9 @@ module.exports = function (node) {
191
194
  }
192
195
  });
193
196
  };
194
- const onClose = function (removed, done) {
197
+ const onClose = (removed, done) => {
195
198
  const characteristics = node.service.characteristics.concat(node.service.optionalCharacteristics);
196
- characteristics.forEach(function (characteristic) {
199
+ characteristics.forEach((characteristic) => {
197
200
  characteristic.removeListener('get', node.onCharacteristicGet);
198
201
  characteristic.removeListener('set', node.onCharacteristicSet);
199
202
  characteristic.removeListener('change', node.onCharacteristicChange);
@@ -213,7 +216,7 @@ module.exports = function (node) {
213
216
  }
214
217
  done();
215
218
  };
216
- const getOrCreate = function (accessory, serviceInformation, parentService) {
219
+ const getOrCreate = (accessory, serviceInformation, parentService) => {
217
220
  const newService = new Service[serviceInformation.serviceName](serviceInformation.name, serviceInformation.UUID);
218
221
  log.debug(`Looking for service with UUID ${serviceInformation.UUID} ...`);
219
222
  let service = accessory.services.find((service) => {
@@ -251,7 +254,7 @@ module.exports = function (node) {
251
254
  }
252
255
  return service;
253
256
  };
254
- const configureCameraSource = function (_accessory, _service, config) {
257
+ const configureCameraSource = (_accessory, _service, config) => {
255
258
  if (config.cameraConfigSource) {
256
259
  log.debug('Configuring Camera Source');
257
260
  if (!config.cameraConfigVideoProcessor) {
@@ -274,7 +277,7 @@ module.exports = function (node) {
274
277
  });
275
278
  const checkAndWait = () => {
276
279
  const parentNode = node.RED.nodes.getNode(node.config.parentService);
277
- if (parentNode && parentNode.configured) {
280
+ if (parentNode === null || parentNode === void 0 ? void 0 : parentNode.configured) {
278
281
  resolve(parentNode);
279
282
  }
280
283
  else {
@@ -291,9 +294,9 @@ module.exports = function (node) {
291
294
  if (node.setupDone) {
292
295
  return;
293
296
  }
294
- if (msg.hasOwnProperty('payload') &&
295
- msg.payload.hasOwnProperty('nrchkb') &&
296
- msg.payload.nrchkb.hasOwnProperty('setup')) {
297
+ if (Object.hasOwn(msg, 'payload') &&
298
+ Object.hasOwn(msg.payload, 'nrchkb') &&
299
+ Object.hasOwn(msg.payload.nrchkb, 'setup')) {
297
300
  node.setupDone = true;
298
301
  const newConfig = Object.assign(Object.assign({}, config), msg.payload.nrchkb.setup);
299
302
  node.removeListener('input', node.handleWaitForSetup);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- module.exports = function (node) {
3
+ module.exports = (node) => {
4
4
  const ServiceUtils = require('./ServiceUtils')(node);
5
5
  const BridgeUtils = require('./BridgeUtils')();
6
6
  const AccessoryUtils = require('./AccessoryUtils')(node);
@@ -36,9 +36,9 @@ 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 path = __importStar(require("node:path"));
39
40
  const hap_nodejs_1 = require("@homebridge/hap-nodejs");
40
41
  const logger_1 = require("@nrchkb/logger");
41
- const path = __importStar(require("path"));
42
42
  const semver_1 = __importDefault(require("semver"));
43
43
  const Storage_1 = require("../lib/Storage");
44
44
  (0, logger_1.loggerSetup)({ timestampEnabled: 'NRCHKB' });
@@ -68,7 +68,7 @@ module.exports = (RED) => {
68
68
  }
69
69
  else {
70
70
  log.error('RED settings not available');
71
- rootFolder = path.join(require('os').homedir(), '.node-red');
71
+ rootFolder = path.join(require('node:os').homedir(), '.node-red');
72
72
  }
73
73
  Storage_1.Storage.init(rootFolder, 'nrchkb').then(() => {
74
74
  log.debug(`nrchkb storage path set to ${Storage_1.Storage.storagePath()}`);
@@ -7,38 +7,37 @@ const log = (0, logger_1.logger)('NRCHKB', 'HAPStatusNode');
7
7
  module.exports = (RED) => {
8
8
  log.debug('Registering homekit-status type');
9
9
  RED.nodes.registerType('homekit-status', function (config) {
10
- const self = this;
11
- self.config = config;
12
- RED.nodes.createNode(self, config);
13
- self.nodeStatusUtils = new NodeStatusUtils_1.NodeStatusUtils(self);
10
+ this.config = config;
11
+ RED.nodes.createNode(this, config);
12
+ this.nodeStatusUtils = new NodeStatusUtils_1.NodeStatusUtils(this);
14
13
  try {
15
- self.serviceNode = RED.nodes.getNode(self.config.serviceNodeId);
14
+ this.serviceNode = RED.nodes.getNode(this.config.serviceNodeId);
16
15
  }
17
16
  catch (error) {
18
17
  log.error(error);
19
18
  }
20
- self.on('input', (_) => {
21
- if (self.serviceNode) {
22
- self.nodeStatusUtils.setStatus({
19
+ this.on('input', (_) => {
20
+ if (this.serviceNode) {
21
+ this.nodeStatusUtils.setStatus({
23
22
  fill: 'green',
24
23
  shape: 'dot',
25
24
  text: 'Done'
26
25
  }, 3000);
27
- const serializedService = hap_nodejs_1.Service.serialize(self.serviceNode.service);
28
- self.send({
26
+ const serializedService = hap_nodejs_1.Service.serialize(this.serviceNode.service);
27
+ this.send({
29
28
  payload: serializedService
30
29
  });
31
30
  }
32
31
  else {
33
- self.nodeStatusUtils.setStatus({
32
+ this.nodeStatusUtils.setStatus({
34
33
  fill: 'red',
35
34
  shape: 'dot',
36
35
  text: 'Check your config'
37
36
  });
38
37
  }
39
38
  });
40
- self.on('close', (_, done) => {
41
- self.serviceNode = undefined;
39
+ this.on('close', (_, done) => {
40
+ this.serviceNode = undefined;
42
41
  done();
43
42
  });
44
43
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-homekit-bridged",
3
- "version": "2.0.0-dev.1",
3
+ "version": "2.0.0-dev.2",
4
4
  "description": "Node-RED nodes to simulate Apple HomeKit devices.",
5
5
  "main": "build/nodes/nrchkb.js",
6
6
  "scripts": {
@@ -8,7 +8,8 @@
8
8
  "clean": "del-cli \"build/lib\" \"build/**/*.js\"",
9
9
  "test": "vitest run",
10
10
  "test:watch": "vitest",
11
- "format": "biome format --write",
11
+ "format": "npx @biomejs/biome check --write",
12
+ "lint": "npx @biomejs/biome check",
12
13
  "prepare": "husky install"
13
14
  },
14
15
  "repository": {