node-red-contrib-homekit-bridged 1.5.0-dev.9 → 1.6.0-dev.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 (40) hide show
  1. package/build/lib/HAPHostNode.js +24 -11
  2. package/build/lib/HAPServiceNode.js +11 -20
  3. package/build/lib/HAPServiceNode2.js +10 -19
  4. package/build/lib/Storage.d.ts +3 -3
  5. package/build/lib/Storage.js +3 -3
  6. package/build/lib/api.js +18 -9
  7. package/build/lib/types/AccessoryInformationType.d.ts +1 -1
  8. package/build/lib/types/CameraConfigType.d.ts +1 -1
  9. package/build/lib/types/CustomCharacteristicType.d.ts +1 -1
  10. package/build/lib/types/HAPHostConfigType.d.ts +2 -2
  11. package/build/lib/types/HAPHostNodeType.d.ts +4 -4
  12. package/build/lib/types/HAPService2ConfigType.d.ts +1 -1
  13. package/build/lib/types/HAPService2NodeType.d.ts +10 -9
  14. package/build/lib/types/HAPServiceConfigType.d.ts +1 -1
  15. package/build/lib/types/HAPServiceNodeType.d.ts +10 -9
  16. package/build/lib/types/HAPStatusConfigType.d.ts +1 -1
  17. package/build/lib/types/HAPStatusNodeType.d.ts +5 -4
  18. package/build/lib/types/NodeType.d.ts +1 -5
  19. package/build/lib/types/PublishTimersType.d.ts +1 -1
  20. package/build/lib/types/storage/SerializedHostType.d.ts +1 -1
  21. package/build/lib/types/storage/StorageType.js +1 -2
  22. package/build/lib/utils/AccessoryUtils.js +4 -3
  23. package/build/lib/utils/BridgeUtils.js +2 -2
  24. package/build/lib/utils/CharacteristicUtils.js +1 -1
  25. package/build/lib/utils/CharacteristicUtils2.js +1 -1
  26. package/build/lib/utils/NodeStatusUtils.d.ts +18 -0
  27. package/build/lib/utils/NodeStatusUtils.js +48 -0
  28. package/build/lib/utils/ServiceUtils.js +23 -11
  29. package/build/lib/utils/ServiceUtils2.js +25 -12
  30. package/build/nodes/bridge.html +3 -2
  31. package/build/nodes/bridge.js +1 -1
  32. package/build/nodes/nrchkb.js +2 -2
  33. package/build/nodes/standalone.html +4 -2
  34. package/build/nodes/standalone.js +1 -1
  35. package/build/nodes/status.js +5 -24
  36. package/package.json +27 -22
  37. package/build/lib/types/FlowType.d.ts +0 -9
  38. package/build/lib/types/FlowType.js +0 -9
  39. package/build/lib/types/StatusUtilType.d.ts +0 -8
  40. package/build/lib/types/StatusUtilType.js +0 -2
@@ -1,15 +1,24 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const HostType_1 = __importDefault(require("./types/HostType"));
7
- const preload_1 = __importDefault(require("semver/preload"));
15
+ const logger_1 = require("@nrchkb/logger");
8
16
  const hap_nodejs_1 = require("hap-nodejs");
9
- const HapCategories_1 = __importDefault(require("./types/HapCategories"));
10
17
  const semver_1 = require("semver");
11
- const logger_1 = require("@nrchkb/logger");
18
+ const preload_1 = __importDefault(require("semver/preload"));
12
19
  const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
20
+ const HapCategories_1 = __importDefault(require("./types/HapCategories"));
21
+ const HostType_1 = __importDefault(require("./types/HostType"));
13
22
  module.exports = (RED, hostType) => {
14
23
  const MdnsUtils = require('./utils/MdnsUtils')();
15
24
  const init = function (config) {
@@ -99,14 +108,18 @@ module.exports = (RED, hostType) => {
99
108
  return true;
100
109
  };
101
110
  self.on('close', function (removed, done) {
102
- if (removed) {
103
- self.host.destroy();
104
- }
105
- else {
106
- self.host.unpublish();
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ if (removed) {
113
+ log.debug('This node has been deleted');
114
+ yield self.host.destroy();
115
+ }
116
+ else {
117
+ log.debug('This node is being restarted');
118
+ yield self.host.unpublish();
119
+ }
107
120
  self.published = false;
108
- }
109
- done();
121
+ done();
122
+ });
110
123
  });
111
124
  self.host.on('identify', function (paired, callback) {
112
125
  if (paired) {
@@ -3,11 +3,11 @@ 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 HostType_1 = __importDefault(require("./types/HostType"));
7
- const hap_nodejs_1 = require("hap-nodejs");
8
6
  const logger_1 = require("@nrchkb/logger");
9
- const FlowType_1 = require("./types/FlowType");
7
+ const hap_nodejs_1 = require("hap-nodejs");
10
8
  const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
9
+ const HostType_1 = __importDefault(require("./types/HostType"));
10
+ const NodeStatusUtils_1 = require("./utils/NodeStatusUtils");
11
11
  module.exports = (RED) => {
12
12
  const nrchkbConfigCompatibilityOverride = function () {
13
13
  const self = this;
@@ -23,17 +23,7 @@ module.exports = (RED) => {
23
23
  };
24
24
  const preInit = function (config) {
25
25
  const self = this;
26
- self.lastStatusId = 0;
27
- self.setStatus = (status) => {
28
- self.status(status);
29
- self.lastStatusId = new Date().getTime();
30
- return self.lastStatusId;
31
- };
32
- self.clearStatus = (statusId) => {
33
- if (statusId === self.lastStatusId) {
34
- self.setStatus({});
35
- }
36
- };
26
+ self.nodeStatusUtils = new NodeStatusUtils_1.NodeStatusUtils(self);
37
27
  self.config = config;
38
28
  self.name = self.config.name;
39
29
  const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode', self.config.name, self);
@@ -46,7 +36,7 @@ module.exports = (RED) => {
46
36
  if (self.config.waitForSetupMsg) {
47
37
  log.debug('Waiting for Setup message. It should be of format {"payload":{"nrchkb":{"setup":{}}}}');
48
38
  self.setupDone = false;
49
- self.setStatus({
39
+ self.nodeStatusUtils.setStatus({
50
40
  fill: 'blue',
51
41
  shape: 'dot',
52
42
  text: 'Waiting for Setup',
@@ -90,6 +80,7 @@ module.exports = (RED) => {
90
80
  }
91
81
  };
92
82
  const configure = function () {
83
+ var _a, _b;
93
84
  const self = this;
94
85
  const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode', self.config.name, self);
95
86
  const Utils = require('./utils')(self);
@@ -123,14 +114,14 @@ module.exports = (RED) => {
123
114
  throw new NRCHKBError_1.default('Parent Service not assigned');
124
115
  }
125
116
  self.hostNode = self.parentNode.hostNode;
126
- self.parentNode.childNodes.push(self);
117
+ (_a = self.parentNode.childNodes) === null || _a === void 0 ? void 0 : _a.push(self);
127
118
  self.accessory = self.parentNode.accessory;
128
119
  }
129
120
  self.name = self.config.name;
130
121
  if (self.hasOwnProperty('_flow') &&
131
122
  self.hasOwnProperty('_alias') &&
132
- self._flow.hasOwnProperty('TYPE') &&
133
- FlowType_1.FlowTypeType.Subflow == self._flow.TYPE) {
123
+ ((_b = self._flow) === null || _b === void 0 ? void 0 : _b.hasOwnProperty('TYPE')) &&
124
+ self._flow.TYPE === 'subflow') {
134
125
  self.uniqueIdentifier = self._alias + '/' + self._flow.path;
135
126
  }
136
127
  else {
@@ -171,9 +162,9 @@ module.exports = (RED) => {
171
162
  }, self.parentService);
172
163
  self.characteristicProperties = CharacteristicUtils.load(self.service, self.config);
173
164
  if (self.config.isParent) {
174
- self.publishTimers = BridgeUtils.delayedPublish(self);
165
+ BridgeUtils.delayedPublish(self);
175
166
  }
176
- self.setStatus({
167
+ self.nodeStatusUtils.setStatus({
177
168
  fill: 'yellow',
178
169
  shape: 'ring',
179
170
  text: self.hostNode.config.pinCode,
@@ -3,11 +3,11 @@ 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 HostType_1 = __importDefault(require("./types/HostType"));
7
- const hap_nodejs_1 = require("hap-nodejs");
8
6
  const logger_1 = require("@nrchkb/logger");
9
- const FlowType_1 = require("./types/FlowType");
7
+ const hap_nodejs_1 = require("hap-nodejs");
10
8
  const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
9
+ const HostType_1 = __importDefault(require("./types/HostType"));
10
+ const NodeStatusUtils_1 = require("./utils/NodeStatusUtils");
11
11
  module.exports = (RED) => {
12
12
  const nrchkbConfigCompatibilityOverride = function () {
13
13
  const self = this;
@@ -23,17 +23,7 @@ module.exports = (RED) => {
23
23
  };
24
24
  const preInit = function (config) {
25
25
  const self = this;
26
- self.lastStatusId = 0;
27
- self.setStatus = (status) => {
28
- self.status(status);
29
- self.lastStatusId = new Date().getTime();
30
- return self.lastStatusId;
31
- };
32
- self.clearStatus = (statusId) => {
33
- if (statusId === self.lastStatusId) {
34
- self.setStatus({});
35
- }
36
- };
26
+ self.nodeStatusUtils = new NodeStatusUtils_1.NodeStatusUtils(self);
37
27
  self.config = config;
38
28
  self.name = self.config.name;
39
29
  const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', self.config.name, self);
@@ -46,7 +36,7 @@ module.exports = (RED) => {
46
36
  if (self.config.waitForSetupMsg) {
47
37
  log.debug('Waiting for Setup message. It should be of format {"payload":{"nrchkb":{"setup":{}}}}');
48
38
  self.setupDone = false;
49
- self.setStatus({
39
+ self.nodeStatusUtils.setStatus({
50
40
  fill: 'blue',
51
41
  shape: 'dot',
52
42
  text: 'Waiting for Setup',
@@ -90,6 +80,7 @@ module.exports = (RED) => {
90
80
  }
91
81
  };
92
82
  const configure = function () {
83
+ var _a, _b;
93
84
  const self = this;
94
85
  const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', self.config.name, self);
95
86
  const Utils = require('./utils')(self);
@@ -123,14 +114,14 @@ module.exports = (RED) => {
123
114
  throw new NRCHKBError_1.default('Parent Service not assigned');
124
115
  }
125
116
  self.hostNode = self.parentNode.hostNode;
126
- self.parentNode.childNodes.push(self);
117
+ (_a = self.parentNode.childNodes) === null || _a === void 0 ? void 0 : _a.push(self);
127
118
  self.accessory = self.parentNode.accessory;
128
119
  }
129
120
  self.name = self.config.name;
130
121
  if (self.hasOwnProperty('_flow') &&
131
122
  self.hasOwnProperty('_alias') &&
132
- self._flow.hasOwnProperty('TYPE') &&
133
- FlowType_1.FlowTypeType.Subflow == self._flow.TYPE) {
123
+ ((_b = self._flow) === null || _b === void 0 ? void 0 : _b.hasOwnProperty('TYPE')) &&
124
+ self._flow.TYPE === 'subflow') {
134
125
  self.uniqueIdentifier = self._alias + '/' + self._flow.path;
135
126
  }
136
127
  else {
@@ -173,7 +164,7 @@ module.exports = (RED) => {
173
164
  if (self.config.isParent) {
174
165
  BridgeUtils.delayedPublish(self);
175
166
  }
176
- self.setStatus({
167
+ self.nodeStatusUtils.setStatus({
177
168
  fill: 'yellow',
178
169
  shape: 'ring',
179
170
  text: self.hostNode.config.pinCode,
@@ -1,8 +1,8 @@
1
- import storage, { InitOptions } from 'node-persist';
2
- import { StorageType } from './types/storage/StorageType';
3
1
  import { CharacteristicEventTypes, SerializedAccessory, SerializedService } from 'hap-nodejs';
2
+ import storage, { InitOptions } from 'node-persist';
4
3
  import { SerializedHostType } from './types/storage/SerializedHostType';
5
- declare type EventCallback = {
4
+ import { StorageType } from './types/storage/StorageType';
5
+ type EventCallback = {
6
6
  event: CharacteristicEventTypes;
7
7
  callback: (value?: any) => void;
8
8
  };
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Storage = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const node_persist_1 = __importDefault(require("node-persist"));
9
- const StorageType_1 = require("./types/storage/StorageType");
10
7
  const logger_1 = require("@nrchkb/logger");
8
+ const node_persist_1 = __importDefault(require("node-persist"));
9
+ const path_1 = __importDefault(require("path"));
11
10
  const uuid_1 = require("uuid");
12
11
  const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
12
+ const StorageType_1 = require("./types/storage/StorageType");
13
13
  class Storage {
14
14
  static storagePath() {
15
15
  if (!Storage.storageInitialized) {
package/build/lib/api.js CHANGED
@@ -23,15 +23,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const HapCategories_1 = __importDefault(require("./types/HapCategories"));
27
- const hap_nodejs_1 = require("hap-nodejs");
28
26
  const logger_1 = require("@nrchkb/logger");
27
+ const hap_nodejs_1 = require("hap-nodejs");
29
28
  const Storage_1 = require("./Storage");
29
+ const HapCategories_1 = __importDefault(require("./types/HapCategories"));
30
30
  const version = require('../../package.json').version.trim();
31
31
  module.exports = function (RED) {
32
32
  const log = (0, logger_1.logger)('NRCHKB', 'API');
33
33
  const _initServiceAPI = () => {
34
- log.debug('Initialize ServiceAPI');
34
+ log.debug('Initialize Service API');
35
35
  const serviceData = {
36
36
  BatteryService: {
37
37
  nrchkbDisabledText: 'BatteryService (deprecated, replaced by Battery)',
@@ -42,6 +42,9 @@ module.exports = function (RED) {
42
42
  BridgingState: {
43
43
  nrchkbDisabledText: 'BridgingState (deprecated, unused)',
44
44
  },
45
+ CameraEventRecordingManagement: {
46
+ nrchkbDisabledText: 'CameraEventRecordingManagement (deprecated, replaced by CameraRecordingManagement)',
47
+ },
45
48
  Relay: {
46
49
  nrchkbDisabledText: 'Relay (deprecated, replaced by CloudRelay)',
47
50
  },
@@ -69,9 +72,7 @@ module.exports = function (RED) {
69
72
  res.json(serviceData);
70
73
  });
71
74
  };
72
- const _initNRCHKBInfoAPI = () => {
73
- log.debug('Initialize NRCHKB Info API');
74
- log.debug(`Running version: ${version}`);
75
+ const stringifyVersion = (version) => {
75
76
  const releaseVersionRegex = /(\d+)\.(\d+)\.(\d+)/;
76
77
  const devVersionRegex = /(\d+)\.(\d+)\.(\d+)-dev\.(\d+)/;
77
78
  const releaseVersionFound = releaseVersionRegex.test(version);
@@ -109,6 +110,12 @@ module.exports = function (RED) {
109
110
  log.debug('Bad version format');
110
111
  xyzVersion = '0.0.0';
111
112
  }
113
+ return xyzVersion;
114
+ };
115
+ const _initNRCHKBInfoAPI = () => {
116
+ log.debug('Initialize NRCHKB Info API');
117
+ log.debug(`Running version: ${version}`);
118
+ const xyzVersion = stringifyVersion(version);
112
119
  log.debug(`Evaluated as: ${xyzVersion}`);
113
120
  const experimental = process.env.NRCHKB_EXPERIMENTAL === 'true';
114
121
  log.debug(`Running experimental: ${experimental}`);
@@ -123,7 +130,7 @@ module.exports = function (RED) {
123
130
  const getCustomCharacteristics = () => {
124
131
  return Storage_1.Storage.loadCustomCharacteristics()
125
132
  .then((value) => {
126
- log.trace(`loadCustomCharacteristics()`);
133
+ log.trace('loadCustomCharacteristics()');
127
134
  log.trace(value);
128
135
  if (Array.isArray(value)) {
129
136
  return value;
@@ -221,7 +228,8 @@ module.exports = function (RED) {
221
228
  isRedInitialized();
222
229
  }).then(() => {
223
230
  RED.nodes.eachNode((node) => {
224
- if (node.type === 'homekit-service') {
231
+ if (node.type === 'homekit-service' ||
232
+ node.type === 'homekit-service2') {
225
233
  const serviceNodeConfig = node;
226
234
  const serviceNode = RED.nodes.getNode(serviceNodeConfig.id);
227
235
  if (serviceNode &&
@@ -265,7 +273,7 @@ module.exports = function (RED) {
265
273
  }));
266
274
  });
267
275
  const _initAccessoryAPI = function () {
268
- log.debug('Initialize AccessoryAPI');
276
+ log.debug('Initialize Accessory API');
269
277
  const accessoryCategoriesData = {};
270
278
  Object.keys(HapCategories_1.default)
271
279
  .sort()
@@ -288,5 +296,6 @@ module.exports = function (RED) {
288
296
  };
289
297
  return {
290
298
  init,
299
+ stringifyVersion,
291
300
  };
292
301
  };
@@ -1,4 +1,4 @@
1
- declare type AccessoryInformationType = {
1
+ type AccessoryInformationType = {
2
2
  UUID: string;
3
3
  name: string;
4
4
  manufacturer: string;
@@ -1,4 +1,4 @@
1
- declare type CameraConfigType = {
1
+ type CameraConfigType = {
2
2
  cameraConfigVideoProcessor: string;
3
3
  cameraConfigSource: string;
4
4
  cameraConfigStillImageSource?: string;
@@ -1,5 +1,5 @@
1
1
  import { CharacteristicProps } from 'hap-nodejs';
2
- declare type CustomCharacteristicType = CharacteristicProps & {
2
+ type CustomCharacteristicType = CharacteristicProps & {
3
3
  UUID?: string;
4
4
  name?: string;
5
5
  };
@@ -1,8 +1,8 @@
1
+ import { MDNSAdvertiser } from 'hap-nodejs';
1
2
  import { NodeDef } from 'node-red';
2
3
  import { SemVer } from 'semver';
3
4
  import HapCategories from './HapCategories';
4
- import { MDNSAdvertiser } from 'hap-nodejs';
5
- declare type HAPHostConfigType = NodeDef & {
5
+ type HAPHostConfigType = NodeDef & {
6
6
  bridgeName: string;
7
7
  pinCode: string;
8
8
  port?: number;
@@ -1,9 +1,9 @@
1
- import NodeType from './NodeType';
2
- import HAPHostConfigType from './HAPHostConfigType';
1
+ import { MulticastOptions } from 'bonjour-hap';
3
2
  import { Accessory, Categories } from 'hap-nodejs';
3
+ import HAPHostConfigType from './HAPHostConfigType';
4
4
  import HostType from './HostType';
5
- import { MulticastOptions } from 'bonjour-hap';
6
- declare type HAPHostNodeType = NodeType & {
5
+ import NodeType from './NodeType';
6
+ type HAPHostNodeType = NodeType & {
7
7
  config: HAPHostConfigType;
8
8
  mdnsConfig: MulticastOptions;
9
9
  accessoryCategory: Categories;
@@ -1,6 +1,6 @@
1
1
  import { NodeDef } from 'node-red';
2
2
  import CameraConfigType from './CameraConfigType';
3
- declare type HAPService2ConfigType = NodeDef & {
3
+ type HAPService2ConfigType = NodeDef & {
4
4
  isParent: boolean;
5
5
  hostType: number;
6
6
  bridge: string;
@@ -1,13 +1,13 @@
1
- import NodeType from './NodeType';
2
- import { NodeAPI } from 'node-red';
3
- import HAPService2ConfigType from './HAPService2ConfigType';
4
1
  import { Accessory, Characteristic, CharacteristicChange, CharacteristicGetCallback, CharacteristicProps, CharacteristicSetCallback, CharacteristicValue, Service } from 'hap-nodejs';
2
+ import { HAPConnection } from 'hap-nodejs/dist/lib/util/eventedhttp';
3
+ import { NodeAPI } from 'node-red';
4
+ import { NodeStatusUtils } from '../utils/NodeStatusUtils';
5
5
  import HAPHostNodeType from './HAPHostNodeType';
6
- import PublishTimersType from './PublishTimersType';
7
- import StatusUtilType from './StatusUtilType';
6
+ import HAPService2ConfigType from './HAPService2ConfigType';
8
7
  import HAPServiceNodeType from './HAPServiceNodeType';
9
- import { HAPConnection } from 'hap-nodejs/dist/lib/util/eventedhttp';
10
- declare type HAPService2NodeType = NodeType & {
8
+ import NodeType from './NodeType';
9
+ import PublishTimersType from './PublishTimersType';
10
+ type HAPService2NodeType = NodeType & {
11
11
  config: HAPService2ConfigType;
12
12
  RED: NodeAPI;
13
13
  setupDone: boolean;
@@ -15,7 +15,7 @@ declare type HAPService2NodeType = NodeType & {
15
15
  handleWaitForSetup: (msg: any) => any;
16
16
  onIdentify: (paired: boolean, callback: () => any) => void;
17
17
  hostNode: HAPHostNodeType;
18
- childNodes: (HAPService2NodeType | HAPServiceNodeType)[];
18
+ childNodes?: (HAPService2NodeType | HAPServiceNodeType)[];
19
19
  service: Service;
20
20
  parentService: Service;
21
21
  parentNode?: HAPService2NodeType | HAPServiceNodeType;
@@ -31,5 +31,6 @@ declare type HAPService2NodeType = NodeType & {
31
31
  onCharacteristicChange: (this: Characteristic, change: CharacteristicChange) => void;
32
32
  uniqueIdentifier: string;
33
33
  reachable?: boolean;
34
- } & StatusUtilType;
34
+ nodeStatusUtils: NodeStatusUtils;
35
+ };
35
36
  export default HAPService2NodeType;
@@ -1,6 +1,6 @@
1
1
  import { NodeDef } from 'node-red';
2
2
  import CameraConfigType from './CameraConfigType';
3
- declare type HAPServiceConfigType = NodeDef & {
3
+ type HAPServiceConfigType = NodeDef & {
4
4
  isParent: boolean;
5
5
  hostType: number;
6
6
  bridge: string;
@@ -1,13 +1,13 @@
1
- import NodeType from './NodeType';
2
- import { NodeAPI } from 'node-red';
3
1
  import { Accessory, Characteristic, CharacteristicChange, CharacteristicGetCallback, CharacteristicProps, CharacteristicSetCallback, CharacteristicValue, Service } from 'hap-nodejs';
2
+ import { HAPConnection } from 'hap-nodejs/dist/lib/util/eventedhttp';
3
+ import { NodeAPI } from 'node-red';
4
+ import { NodeStatusUtils } from '../utils/NodeStatusUtils';
4
5
  import HAPHostNodeType from './HAPHostNodeType';
5
- import PublishTimersType from './PublishTimersType';
6
- import StatusUtilType from './StatusUtilType';
7
- import HAPServiceConfigType from './HAPServiceConfigType';
8
6
  import HAPService2NodeType from './HAPService2NodeType';
9
- import { HAPConnection } from 'hap-nodejs/dist/lib/util/eventedhttp';
10
- declare type HAPServiceNodeType = NodeType & {
7
+ import HAPServiceConfigType from './HAPServiceConfigType';
8
+ import NodeType from './NodeType';
9
+ import PublishTimersType from './PublishTimersType';
10
+ type HAPServiceNodeType = NodeType & {
11
11
  config: HAPServiceConfigType;
12
12
  RED: NodeAPI;
13
13
  setupDone: boolean;
@@ -15,7 +15,7 @@ declare type HAPServiceNodeType = NodeType & {
15
15
  handleWaitForSetup: (msg: any) => any;
16
16
  onIdentify: (paired: boolean, callback: () => any) => void;
17
17
  hostNode: HAPHostNodeType;
18
- childNodes: (HAPService2NodeType | HAPServiceNodeType)[];
18
+ childNodes?: (HAPService2NodeType | HAPServiceNodeType)[];
19
19
  service: Service;
20
20
  parentService: Service;
21
21
  parentNode?: HAPService2NodeType | HAPServiceNodeType;
@@ -31,5 +31,6 @@ declare type HAPServiceNodeType = NodeType & {
31
31
  onCharacteristicChange: (this: Characteristic, change: CharacteristicChange) => void;
32
32
  uniqueIdentifier: string;
33
33
  reachable?: boolean;
34
- } & StatusUtilType;
34
+ nodeStatusUtils: NodeStatusUtils;
35
+ };
35
36
  export default HAPServiceNodeType;
@@ -1,5 +1,5 @@
1
1
  import { NodeDef } from 'node-red';
2
- declare type HAPStatusConfigType = NodeDef & {
2
+ type HAPStatusConfigType = NodeDef & {
3
3
  serviceNodeId: string;
4
4
  };
5
5
  export default HAPStatusConfigType;
@@ -1,11 +1,12 @@
1
- import NodeType from './NodeType';
2
1
  import { NodeAPI } from 'node-red';
3
- import StatusUtilType from './StatusUtilType';
2
+ import { NodeStatusUtils } from '../utils/NodeStatusUtils';
4
3
  import HAPServiceNodeType from './HAPServiceNodeType';
5
4
  import HAPStatusConfigType from './HAPStatusConfigType';
6
- declare type HAPStatusNodeType = NodeType & {
5
+ import NodeType from './NodeType';
6
+ type HAPStatusNodeType = NodeType & {
7
7
  config: HAPStatusConfigType;
8
8
  RED: NodeAPI;
9
9
  serviceNode?: HAPServiceNodeType;
10
- } & StatusUtilType;
10
+ nodeStatusUtils: NodeStatusUtils;
11
+ };
11
12
  export default HAPStatusNodeType;
@@ -1,7 +1,3 @@
1
1
  import { Node } from 'node-red';
2
- import { FlowType } from './FlowType';
3
- declare type NodeType = Node & {
4
- _flow: FlowType;
5
- _alias: string;
6
- };
2
+ type NodeType = Node;
7
3
  export default NodeType;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- declare type PublishTimersType = {
2
+ type PublishTimersType = {
3
3
  [key: string]: NodeJS.Timeout;
4
4
  };
5
5
  export default PublishTimersType;
@@ -1,5 +1,5 @@
1
1
  import { SerializedAccessory } from 'hap-nodejs';
2
- declare type SerializedHostType = {
2
+ type SerializedHostType = {
3
3
  _isBridge: boolean;
4
4
  } & SerializedAccessory;
5
5
  export { SerializedHostType };
@@ -8,5 +8,4 @@ var StorageType;
8
8
  StorageType["HOST"] = "host";
9
9
  StorageType["CUSTOM_CHARACTERISTICS"] = "customCharacteristics";
10
10
  StorageType["OTHER"] = "other";
11
- })(StorageType || (StorageType = {}));
12
- exports.StorageType = StorageType;
11
+ })(StorageType || (exports.StorageType = StorageType = {}));
@@ -77,13 +77,14 @@ module.exports = function (node) {
77
77
  return accessory;
78
78
  };
79
79
  const onIdentify = function (paired, callback) {
80
+ var _a;
80
81
  if (paired) {
81
82
  log.debug(`Identify called on paired Accessory ${node.accessory.displayName}`);
82
83
  }
83
84
  else {
84
85
  log.debug(`Identify called on unpaired Accessory ${node.accessory.displayName}`);
85
86
  }
86
- const nodes = node.childNodes;
87
+ const nodes = (_a = node.childNodes) !== null && _a !== void 0 ? _a : [];
87
88
  for (let i = 0, len = nodes.length; i < len; i++) {
88
89
  const topic = nodes[i].config.topic
89
90
  ? nodes[i].config.topic
@@ -93,13 +94,13 @@ module.exports = function (node) {
93
94
  name: nodes[i].name,
94
95
  topic: topic,
95
96
  };
96
- const statusId = nodes[i].setStatus({
97
+ const statusId = nodes[i].nodeStatusUtils.setStatus({
97
98
  fill: 'yellow',
98
99
  shape: 'dot',
99
100
  text: 'Identify : 1',
100
101
  });
101
102
  setTimeout(function () {
102
- nodes[i].clearStatus(statusId);
103
+ nodes[i].nodeStatusUtils.clearStatus(statusId);
103
104
  }, 3000);
104
105
  nodes[i].send([msg, msg]);
105
106
  }
@@ -3,8 +3,8 @@ 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 HostType_1 = __importDefault(require("../types/HostType"));
7
6
  const logger_1 = require("@nrchkb/logger");
7
+ const HostType_1 = __importDefault(require("../types/HostType"));
8
8
  module.exports = function () {
9
9
  const delayedPublish = function (node) {
10
10
  const log = (0, logger_1.logger)('NRCHKB', 'BridgeUtils', node.config.name, node);
@@ -29,7 +29,7 @@ module.exports = function () {
29
29
  }
30
30
  catch (error) {
31
31
  log.error(`${hostTypeName} publish failed due to ${error}`);
32
- node.setStatus({
32
+ node.nodeStatusUtils.setStatus({
33
33
  fill: 'red',
34
34
  shape: 'ring',
35
35
  text: 'Error while publishing ' + hostTypeName,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const hap_nodejs_1 = require("hap-nodejs");
4
3
  const logger_1 = require("@nrchkb/logger");
4
+ const hap_nodejs_1 = require("hap-nodejs");
5
5
  module.exports = function (node) {
6
6
  const log = (0, logger_1.logger)('NRCHKB', 'CharacteristicUtils', node.config.name, node);
7
7
  const ServiceUtils = require('./ServiceUtils')(node);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const hap_nodejs_1 = require("hap-nodejs");
4
3
  const logger_1 = require("@nrchkb/logger");
4
+ const hap_nodejs_1 = require("hap-nodejs");
5
5
  module.exports = function (node) {
6
6
  const log = (0, logger_1.logger)('NRCHKB', 'CharacteristicUtils', node.config.name, node);
7
7
  const ServiceUtils = require('./ServiceUtils2')(node);
@@ -0,0 +1,18 @@
1
+ /// <reference types="node-red__registry" />
2
+ import { NodeStatus } from '@node-red/registry';
3
+ import NodeType from '../types/NodeType';
4
+ type StatusType = 'NO_RESPONSE' | 'MSG';
5
+ type NodeStatusWithType = NodeStatus & {
6
+ type?: StatusType;
7
+ };
8
+ type Status = string | NodeStatusWithType;
9
+ export declare class NodeStatusUtils {
10
+ private node;
11
+ protected lastStatusId?: number;
12
+ protected lastStatusType?: StatusType;
13
+ constructor(node: Pick<NodeType, 'status'>);
14
+ setStatus(status: Status, timeout?: number): number;
15
+ clearStatusByType(type: StatusType): void;
16
+ clearStatus(statusId?: number, timeout?: number): void;
17
+ }
18
+ export {};
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeStatusUtils = void 0;
4
+ const DEFAULT_STATUS_TYPE = 'MSG';
5
+ class NodeStatusUtils {
6
+ constructor(node) {
7
+ this.node = node;
8
+ }
9
+ setStatus(status, timeout) {
10
+ var _a;
11
+ this.node.status(status);
12
+ const newStatusId = new Date().getTime();
13
+ this.lastStatusId = newStatusId;
14
+ if (typeof status !== 'string') {
15
+ this.lastStatusType = (_a = status.type) !== null && _a !== void 0 ? _a : DEFAULT_STATUS_TYPE;
16
+ }
17
+ else {
18
+ this.lastStatusType = DEFAULT_STATUS_TYPE;
19
+ }
20
+ if (timeout) {
21
+ this.clearStatus(newStatusId, timeout);
22
+ }
23
+ return newStatusId;
24
+ }
25
+ clearStatusByType(type) {
26
+ if (this.lastStatusType === type) {
27
+ this.clearStatus();
28
+ }
29
+ }
30
+ clearStatus(statusId, timeout) {
31
+ if (statusId !== undefined) {
32
+ if (statusId === this.lastStatusId) {
33
+ if (timeout) {
34
+ setTimeout(function (nodeStatusUtil) {
35
+ nodeStatusUtil.clearStatus(statusId);
36
+ }, timeout, this);
37
+ }
38
+ else {
39
+ this.setStatus('');
40
+ }
41
+ }
42
+ }
43
+ else {
44
+ this.setStatus('');
45
+ }
46
+ }
47
+ }
48
+ exports.NodeStatusUtils = NodeStatusUtils;
@@ -3,8 +3,8 @@ 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("hap-nodejs");
7
6
  const logger_1 = require("@nrchkb/logger");
7
+ const hap_nodejs_1 = require("hap-nodejs");
8
8
  const NRCHKBError_1 = __importDefault(require("../NRCHKBError"));
9
9
  module.exports = function (node) {
10
10
  const log = (0, logger_1.logger)('NRCHKB', 'ServiceUtils', node.config.name, node);
@@ -43,6 +43,7 @@ module.exports = function (node) {
43
43
  }
44
44
  };
45
45
  const onValueChange = function (allCharacteristics, outputNumber, { oldValue, newValue, context }, connection) {
46
+ var _a, _b, _c, _d, _e;
46
47
  const topic = node.config.topic ? node.config.topic : node.topic_in;
47
48
  const msg = { payload: {}, hap: {}, name: node.name, topic: topic };
48
49
  const key = this.constructor.name;
@@ -56,15 +57,26 @@ module.exports = function (node) {
56
57
  if (oldValue !== undefined) {
57
58
  msg.hap.oldValue = oldValue;
58
59
  }
59
- msg.hap.newValue = newValue;
60
- const statusId = node.setStatus({
61
- fill: 'yellow',
62
- shape: 'dot',
63
- text: key + ': ' + newValue,
64
- });
65
- setTimeout(function () {
66
- node.clearStatus(statusId);
67
- }, 3000);
60
+ msg.hap.reachable = (_a = node.reachable) !== null && _a !== void 0 ? _a : (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.reachable;
61
+ if (msg.hap.reachable === false) {
62
+ ;
63
+ [node, ...((_c = node.childNodes) !== null && _c !== void 0 ? _c : [])].forEach((n) => n.nodeStatusUtils.setStatus({
64
+ fill: 'red',
65
+ shape: 'ring',
66
+ text: 'Not reachable',
67
+ type: 'NO_RESPONSE',
68
+ }));
69
+ }
70
+ else {
71
+ msg.hap.newValue = newValue;
72
+ node.nodeStatusUtils.setStatus({
73
+ fill: 'yellow',
74
+ shape: 'dot',
75
+ text: key + ': ' + newValue,
76
+ }, 3000);
77
+ (_d = node.childNodes) === null || _d === void 0 ? void 0 : _d.forEach((n) => n.nodeStatusUtils.clearStatusByType('NO_RESPONSE'));
78
+ (_e = node.parentNode) === null || _e === void 0 ? void 0 : _e.nodeStatusUtils.clearStatusByType('NO_RESPONSE');
79
+ }
68
80
  log.debug(`${node.name} received ${key} : ${newValue}`);
69
81
  if (connection ||
70
82
  context ||
@@ -226,7 +238,7 @@ module.exports = function (node) {
226
238
  const waitForParent = () => {
227
239
  log.debug('Waiting for Parent Service');
228
240
  return new Promise((resolve) => {
229
- node.setStatus({
241
+ node.nodeStatusUtils.setStatus({
230
242
  fill: 'blue',
231
243
  shape: 'dot',
232
244
  text: 'Waiting for Parent Service',
@@ -3,10 +3,10 @@ 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("hap-nodejs");
7
6
  const logger_1 = require("@nrchkb/logger");
8
- const Storage_1 = require("../Storage");
7
+ const hap_nodejs_1 = require("hap-nodejs");
9
8
  const NRCHKBError_1 = __importDefault(require("../NRCHKBError"));
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 HapNodeJS = require('hap-nodejs');
@@ -15,6 +15,7 @@ module.exports = function (node) {
15
15
  const CameraSource = require('../cameraSource').Camera;
16
16
  const NO_RESPONSE_MSG = 'NO_RESPONSE';
17
17
  const output = function (allCharacteristics, event, { oldValue, newValue }, connection) {
18
+ var _a, _b, _c, _d, _e;
18
19
  const eventObject = typeof event === 'object' ? event : { name: event };
19
20
  log.debug(`${eventObject.name} event, oldValue: ${oldValue}, newValue: ${newValue}, connection ${connection === null || connection === void 0 ? void 0 : connection.sessionID}`);
20
21
  const msg = {
@@ -23,18 +24,35 @@ module.exports = function (node) {
23
24
  };
24
25
  msg.payload = {};
25
26
  msg.hap = {
26
- newValue,
27
27
  event: eventObject,
28
28
  allChars: allCharacteristics.reduce((allChars, singleChar) => {
29
29
  const cKey = singleChar.constructor.name;
30
30
  allChars[cKey] = singleChar.value;
31
31
  return allChars;
32
32
  }, {}),
33
+ oldValue,
33
34
  };
34
- if (oldValue !== undefined) {
35
- msg.hap.oldValue = oldValue;
36
- }
37
35
  const key = this.constructor.name;
36
+ msg.hap.reachable = (_a = node.reachable) !== null && _a !== void 0 ? _a : (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.reachable;
37
+ if (msg.hap.reachable === false) {
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
+ }));
45
+ }
46
+ else {
47
+ msg.hap.newValue = newValue;
48
+ node.nodeStatusUtils.setStatus({
49
+ fill: 'yellow',
50
+ shape: 'dot',
51
+ text: `[${eventObject.name}] ${key}${newValue != undefined ? `: ${newValue}` : ''}`,
52
+ }, 3000);
53
+ (_d = node.childNodes) === null || _d === void 0 ? void 0 : _d.forEach((n) => n.nodeStatusUtils.clearStatusByType('NO_RESPONSE'));
54
+ (_e = node.parentNode) === null || _e === void 0 ? void 0 : _e.nodeStatusUtils.clearStatusByType('NO_RESPONSE');
55
+ }
38
56
  msg.payload[key] = newValue;
39
57
  if (connection) {
40
58
  msg.hap.session = {
@@ -45,11 +63,6 @@ module.exports = function (node) {
45
63
  httpPort: connection.remotePort,
46
64
  };
47
65
  }
48
- node.setStatus({
49
- fill: 'yellow',
50
- shape: 'dot',
51
- text: `[${eventObject.name}] ${key}${newValue != undefined ? `: ${newValue}` : ''}`,
52
- }, 3000);
53
66
  log.debug(`${node.name} received ${eventObject.name} ${key}: ${newValue}`);
54
67
  if (connection || node.hostNode.config.allowMessagePassthrough) {
55
68
  node.send(msg);
@@ -248,7 +261,7 @@ module.exports = function (node) {
248
261
  const waitForParent = () => {
249
262
  log.debug('Waiting for Parent Service');
250
263
  return new Promise((resolve) => {
251
- node.setStatus({
264
+ node.nodeStatusUtils.setStatus({
252
265
  fill: 'blue',
253
266
  shape: 'dot',
254
267
  text: 'Waiting for Parent Service',
@@ -13,6 +13,7 @@
13
13
  <option value="bonjour-hap" selected="selected">BONJOUR</option>
14
14
  <option value="ciao">CIAO</option>
15
15
  <option value="avahi">AVAHI</option>
16
+ <option value="resolved">RESOLVED</option>
16
17
  </select>
17
18
  </div>
18
19
  <div class="form-row">
@@ -99,7 +100,7 @@
99
100
  <ul>
100
101
  <li><strong>Pin Code</strong>: Specify the Pin for the pairing process.</li>
101
102
  <li><strong>Port</strong>: If you are behind a Firewall, you may want to specify a port. Cannot be 1880 as it is reserved for node-red. Otherwise, leave empty.</li>
102
- <li><strong>Advertiser</strong>: Which MDNS advertiser to use <em>ciao</em> (new, improved but not yet proved) or (good old) <em>bonjour</em> or experimental <em>avahi</em>. Default <em>bonjour</em>.</li>
103
+ <li><strong>Advertiser</strong>: Which MDNS advertiser to use <em>ciao</em> (new, improved but not yet proved) or (good old) <em>bonjour</em> or experimental <em>avahi</em> and <em>resolved</em>. Default <em>bonjour</em>.</li>
103
104
  <li><strong>Allow Insecure Request</strong>: Should we allow insecure request? Default false.</li>
104
105
  <li><strong>Manufacturer, Model, Serial Number</strong>: Can be anything you want.</li>
105
106
  <li><strong>Firmware Revision</strong>: Should be a version number string in the form of <em>MAJOR.MINOR.REVISION</em> e.g. <em>1.2.0</em>. Other types of strings are ignored and won't be displayed.</li>
@@ -149,7 +150,7 @@
149
150
  value: 'bonjour-hap',
150
151
  required: false,
151
152
  validate: function (value) {
152
- if (value) return value === 'bonjour-hap' || value === 'ciao' || value === 'avahi'
153
+ if (value) return value === 'bonjour-hap' || value === 'ciao' || value === 'avahi' || value === 'resolved'
153
154
  else return true
154
155
  },
155
156
  },
@@ -3,8 +3,8 @@ 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 HostType_1 = __importDefault(require("../lib/types/HostType"));
7
6
  const logger_1 = require("@nrchkb/logger");
7
+ const HostType_1 = __importDefault(require("../lib/types/HostType"));
8
8
  const log = (0, logger_1.logger)('NRCHKB', 'HAPHostNode');
9
9
  module.exports = (RED) => {
10
10
  const HAPHostNode = require('../lib/HAPHostNode')(RED, HostType_1.default.BRIDGE);
@@ -26,10 +26,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ const logger_1 = require("@nrchkb/logger");
30
+ const hap_nodejs_1 = require("hap-nodejs");
29
31
  const path = __importStar(require("path"));
30
32
  const semver_1 = __importDefault(require("semver"));
31
- const hap_nodejs_1 = require("hap-nodejs");
32
- const logger_1 = require("@nrchkb/logger");
33
33
  const Storage_1 = require("../lib/Storage");
34
34
  (0, logger_1.loggerSetup)({ timestampEnabled: 'NRCHKB' });
35
35
  const log = (0, logger_1.logger)('NRCHKB');
@@ -20,6 +20,8 @@
20
20
  <select id="node-config-input-advertiser">
21
21
  <option value="bonjour-hap" selected="selected">BONJOUR</option>
22
22
  <option value="ciao">CIAO</option>
23
+ <option value="avahi">AVAHI</option>
24
+ <option value="resolved">RESOLVED</option>
23
25
  </select>
24
26
  </div>
25
27
  <div class="form-row">
@@ -105,7 +107,7 @@
105
107
  <li><strong>Accessory Category</strong>: What kind of category is this Accessory, default <em>OTHER</em></li>
106
108
  <li><strong>Pin Code</strong>: Specify the Pin for the pairing process.</li>
107
109
  <li><strong>Port</strong>: If you are behind a Firewall, you may want to specify a port. Cannot be 1880 as it is reserved for node-red. Otherwise, leave empty.</li>
108
- <li><strong>Advertiser</strong>: Which MDNS advertiser to use <em>ciao</em> (new, improved but not yet proved) or (good old) <em>bonjour</em>. Default <em>bonjour</em>.</li>
110
+ <li><strong>Advertiser</strong>: Which MDNS advertiser to use <em>ciao</em> (new, improved but not yet proved) or (good old) <em>bonjour</em> or experimental <em>avahi</em> and <em>resolved</em>. Default <em>bonjour</em>.</li>
109
111
  <li><strong>Allow Insecure Request</strong>: Should we allow insecure request? Default false.</li>
110
112
  <li><strong>Manufacturer, Model, Serial Number</strong>: Can be anything you want.</li>
111
113
  <li><strong>Firmware Revision</strong>: Should be a version number string in the form of <em>MAJOR.MINOR.REVISION</em> e.g. <em>1.2.0</em>. Other types of strings are ignored and won't be displayed.</li>
@@ -157,7 +159,7 @@
157
159
  value: 'bonjour-hap',
158
160
  required: false,
159
161
  validate: function (value) {
160
- if (value) return value === 'bonjour-hap' || value === 'ciao'
162
+ if (value) return value === 'bonjour-hap' || value === 'ciao' || value === 'avahi' || value === 'resolved'
161
163
  else return true
162
164
  },
163
165
  },
@@ -3,8 +3,8 @@ 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 HostType_1 = __importDefault(require("../lib/types/HostType"));
7
6
  const logger_1 = require("@nrchkb/logger");
7
+ const HostType_1 = __importDefault(require("../lib/types/HostType"));
8
8
  const log = (0, logger_1.logger)('NRCHKB', 'HAPHostNode');
9
9
  module.exports = (RED) => {
10
10
  const HAPHostNode = require('../lib/HAPHostNode')(RED, HostType_1.default.STANDALONE);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const logger_1 = require("@nrchkb/logger");
4
4
  const hap_nodejs_1 = require("hap-nodejs");
5
+ const NodeStatusUtils_1 = require("../lib/utils/NodeStatusUtils");
5
6
  const log = (0, logger_1.logger)('NRCHKB', 'HAPStatusNode');
6
7
  module.exports = (RED) => {
7
8
  log.debug('Registering homekit-status type');
@@ -9,27 +10,7 @@ module.exports = (RED) => {
9
10
  const self = this;
10
11
  self.config = config;
11
12
  RED.nodes.createNode(self, config);
12
- self.lastStatusId = 0;
13
- self.setStatus = (status, timeout) => {
14
- self.status(status);
15
- self.lastStatusId = new Date().getTime();
16
- if (timeout) {
17
- self.clearStatus(self.lastStatusId, timeout);
18
- }
19
- return self.lastStatusId;
20
- };
21
- self.clearStatus = (statusId, delay) => {
22
- if (statusId === self.lastStatusId) {
23
- if (delay) {
24
- setTimeout(function () {
25
- self.setStatus({});
26
- }, delay);
27
- }
28
- else {
29
- self.setStatus({});
30
- }
31
- }
32
- };
13
+ self.nodeStatusUtils = new NodeStatusUtils_1.NodeStatusUtils(self);
33
14
  try {
34
15
  self.serviceNode = RED.nodes.getNode(self.config.serviceNodeId);
35
16
  }
@@ -38,7 +19,7 @@ module.exports = (RED) => {
38
19
  }
39
20
  self.on('input', (_) => {
40
21
  if (self.serviceNode) {
41
- self.setStatus({
22
+ self.nodeStatusUtils.setStatus({
42
23
  fill: 'green',
43
24
  shape: 'dot',
44
25
  text: 'Done',
@@ -49,11 +30,11 @@ module.exports = (RED) => {
49
30
  });
50
31
  }
51
32
  else {
52
- self.setStatus({
33
+ self.nodeStatusUtils.setStatus({
53
34
  fill: 'red',
54
35
  shape: 'dot',
55
36
  text: 'Check your config',
56
- }, 3000);
37
+ });
57
38
  }
58
39
  });
59
40
  self.on('close', (_, done) => {
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "node-red-contrib-homekit-bridged",
3
- "version": "1.5.0-dev.9",
3
+ "version": "1.6.0-dev.0",
4
4
  "description": "Node-RED nodes to simulate Apple HomeKit devices.",
5
5
  "main": "build/nodes/nrchkb.js",
6
6
  "scripts": {
7
7
  "build": "npm run clean && tsc",
8
8
  "clean": "rimraf build/lib build/**/*.js",
9
- "test": "npm run build && mocha -r ts-node/register './src/**/*.test.[tj]s' --exit",
9
+ "test": "mocha -r ts-node/register './src/**/*.test.[tj]s' --exit --timeout 30000",
10
10
  "prettier": "prettier --write \"**/*.{js,ts}\"",
11
+ "eslint": "eslint \"src/**/*.ts\"",
11
12
  "prepare": "husky install"
12
13
  },
13
14
  "repository": {
@@ -45,35 +46,39 @@
45
46
  },
46
47
  "homepage": "https://github.com/NRCHKB/node-red-contrib-homekit-bridged#readme",
47
48
  "dependencies": {
48
- "@nrchkb/logger": "^1.3.3",
49
- "hap-nodejs": "0.10.4",
50
- "node-persist": "^3.1.0",
51
- "semver": "^7.3.7",
49
+ "@nrchkb/logger": "^2.0.0",
50
+ "hap-nodejs": "0.11.1",
51
+ "node-persist": "^3.1.3",
52
+ "react": "^18.2.0",
53
+ "react-dom": "^18.2.0",
54
+ "semver": "^7.5.4",
52
55
  "uuid": "^9.0.0"
53
56
  },
54
57
  "devDependencies": {
55
- "@homebridge/ciao": "^1.1.5",
58
+ "@homebridge/ciao": "^1.1.7",
56
59
  "@node-red/registry": "^2.2.3",
57
- "@types/mocha": "^9.1.1",
60
+ "@types/mocha": "^10.0.1",
58
61
  "@types/node": "^10.17.60",
59
62
  "@types/node-persist": "^3.1.3",
60
- "@types/node-red": "^1.2.1",
61
- "@types/semver": "^7.3.12",
62
- "@types/uuid": "^8.3.4",
63
- "@typescript-eslint/eslint-plugin": "^5.37.0",
64
- "@typescript-eslint/parser": "^5.37.0",
63
+ "@types/node-red": "^1.3.1",
64
+ "@types/node-red-node-test-helper": "^0.3.0",
65
+ "@types/semver": "^7.5.0",
66
+ "@types/uuid": "^9.0.2",
67
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
68
+ "@typescript-eslint/parser": "^6.4.0",
65
69
  "babel-eslint": "^10.1.0",
66
- "eslint": "^8.23.1",
67
- "eslint-config-prettier": "^8.5.0",
68
- "eslint-plugin-prettier": "^4.2.1",
69
- "mocha": "^10.0.0",
70
+ "eslint": "^8.47.0",
71
+ "eslint-config-prettier": "^9.0.0",
72
+ "eslint-plugin-prettier": "^5.0.0",
73
+ "eslint-plugin-simple-import-sort": "^10.0.0",
74
+ "husky": "^8.0.3",
75
+ "mocha": "^10.2.0",
70
76
  "node-red": "^2.2.3",
71
- "node-red-node-test-helper": "^0.3.0",
72
- "prettier": "^2.7.1",
73
- "rimraf": "^3.0.2",
77
+ "node-red-node-test-helper": "^0.3.2",
78
+ "prettier": "^3.0.2",
79
+ "rimraf": "^5.0.1",
74
80
  "ts-node": "^10.9.1",
75
- "typescript": "^4.8.3",
76
- "husky": "^8.0.1"
81
+ "typescript": "^5.1.6"
77
82
  },
78
83
  "engines": {
79
84
  "node": ">=10.22.1"
@@ -1,9 +0,0 @@
1
- declare enum FlowTypeType {
2
- Subflow = "subflow",
3
- Flow = "flow"
4
- }
5
- declare type FlowType = {
6
- TYPE: FlowTypeType;
7
- path: string;
8
- };
9
- export { FlowType, FlowTypeType };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlowTypeType = void 0;
4
- var FlowTypeType;
5
- (function (FlowTypeType) {
6
- FlowTypeType["Subflow"] = "subflow";
7
- FlowTypeType["Flow"] = "flow";
8
- })(FlowTypeType || (FlowTypeType = {}));
9
- exports.FlowTypeType = FlowTypeType;
@@ -1,8 +0,0 @@
1
- /// <reference types="node-red__registry" />
2
- import { NodeStatus } from '@node-red/registry';
3
- declare type StatusUtilType = {
4
- lastStatusId: number;
5
- setStatus: (status: string | NodeStatus, timeout?: number) => number;
6
- clearStatus: (statusId: number, delay?: number) => void;
7
- };
8
- export default StatusUtilType;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });