node-red-contrib-homekit-bridged 1.5.0-dev.13 → 1.5.0-dev.15

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.
@@ -8,6 +8,7 @@ const hap_nodejs_1 = require("hap-nodejs");
8
8
  const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
9
9
  const FlowType_1 = require("./types/FlowType");
10
10
  const HostType_1 = __importDefault(require("./types/HostType"));
11
+ const NodeStatusUtils_1 = require("./utils/NodeStatusUtils");
11
12
  module.exports = (RED) => {
12
13
  const nrchkbConfigCompatibilityOverride = function () {
13
14
  const self = this;
@@ -23,17 +24,7 @@ module.exports = (RED) => {
23
24
  };
24
25
  const preInit = function (config) {
25
26
  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
- };
27
+ self.nodeStatusUtils = new NodeStatusUtils_1.NodeStatusUtils(self);
37
28
  self.config = config;
38
29
  self.name = self.config.name;
39
30
  const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode', self.config.name, self);
@@ -46,7 +37,7 @@ module.exports = (RED) => {
46
37
  if (self.config.waitForSetupMsg) {
47
38
  log.debug('Waiting for Setup message. It should be of format {"payload":{"nrchkb":{"setup":{}}}}');
48
39
  self.setupDone = false;
49
- self.setStatus({
40
+ self.nodeStatusUtils.setStatus({
50
41
  fill: 'blue',
51
42
  shape: 'dot',
52
43
  text: 'Waiting for Setup',
@@ -90,6 +81,7 @@ module.exports = (RED) => {
90
81
  }
91
82
  };
92
83
  const configure = function () {
84
+ var _a;
93
85
  const self = this;
94
86
  const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode', self.config.name, self);
95
87
  const Utils = require('./utils')(self);
@@ -123,7 +115,7 @@ module.exports = (RED) => {
123
115
  throw new NRCHKBError_1.default('Parent Service not assigned');
124
116
  }
125
117
  self.hostNode = self.parentNode.hostNode;
126
- self.parentNode.childNodes.push(self);
118
+ (_a = self.parentNode.childNodes) === null || _a === void 0 ? void 0 : _a.push(self);
127
119
  self.accessory = self.parentNode.accessory;
128
120
  }
129
121
  self.name = self.config.name;
@@ -171,9 +163,9 @@ module.exports = (RED) => {
171
163
  }, self.parentService);
172
164
  self.characteristicProperties = CharacteristicUtils.load(self.service, self.config);
173
165
  if (self.config.isParent) {
174
- self.publishTimers = BridgeUtils.delayedPublish(self);
166
+ BridgeUtils.delayedPublish(self);
175
167
  }
176
- self.setStatus({
168
+ self.nodeStatusUtils.setStatus({
177
169
  fill: 'yellow',
178
170
  shape: 'ring',
179
171
  text: self.hostNode.config.pinCode,
@@ -8,6 +8,7 @@ const hap_nodejs_1 = require("hap-nodejs");
8
8
  const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
9
9
  const FlowType_1 = require("./types/FlowType");
10
10
  const HostType_1 = __importDefault(require("./types/HostType"));
11
+ const NodeStatusUtils_1 = require("./utils/NodeStatusUtils");
11
12
  module.exports = (RED) => {
12
13
  const nrchkbConfigCompatibilityOverride = function () {
13
14
  const self = this;
@@ -23,17 +24,7 @@ module.exports = (RED) => {
23
24
  };
24
25
  const preInit = function (config) {
25
26
  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
- };
27
+ self.nodeStatusUtils = new NodeStatusUtils_1.NodeStatusUtils(self);
37
28
  self.config = config;
38
29
  self.name = self.config.name;
39
30
  const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', self.config.name, self);
@@ -46,7 +37,7 @@ module.exports = (RED) => {
46
37
  if (self.config.waitForSetupMsg) {
47
38
  log.debug('Waiting for Setup message. It should be of format {"payload":{"nrchkb":{"setup":{}}}}');
48
39
  self.setupDone = false;
49
- self.setStatus({
40
+ self.nodeStatusUtils.setStatus({
50
41
  fill: 'blue',
51
42
  shape: 'dot',
52
43
  text: 'Waiting for Setup',
@@ -90,6 +81,7 @@ module.exports = (RED) => {
90
81
  }
91
82
  };
92
83
  const configure = function () {
84
+ var _a;
93
85
  const self = this;
94
86
  const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', self.config.name, self);
95
87
  const Utils = require('./utils')(self);
@@ -123,7 +115,7 @@ module.exports = (RED) => {
123
115
  throw new NRCHKBError_1.default('Parent Service not assigned');
124
116
  }
125
117
  self.hostNode = self.parentNode.hostNode;
126
- self.parentNode.childNodes.push(self);
118
+ (_a = self.parentNode.childNodes) === null || _a === void 0 ? void 0 : _a.push(self);
127
119
  self.accessory = self.parentNode.accessory;
128
120
  }
129
121
  self.name = self.config.name;
@@ -173,7 +165,7 @@ module.exports = (RED) => {
173
165
  if (self.config.isParent) {
174
166
  BridgeUtils.delayedPublish(self);
175
167
  }
176
- self.setStatus({
168
+ self.nodeStatusUtils.setStatus({
177
169
  fill: 'yellow',
178
170
  shape: 'ring',
179
171
  text: self.hostNode.config.pinCode,
@@ -2,7 +2,7 @@ import { CharacteristicEventTypes, SerializedAccessory, SerializedService } from
2
2
  import storage, { InitOptions } from 'node-persist';
3
3
  import { SerializedHostType } from './types/storage/SerializedHostType';
4
4
  import { StorageType } from './types/storage/StorageType';
5
- declare type EventCallback = {
5
+ type EventCallback = {
6
6
  event: CharacteristicEventTypes;
7
7
  callback: (value?: any) => void;
8
8
  };
@@ -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
  };
@@ -2,7 +2,7 @@ declare enum FlowTypeType {
2
2
  Subflow = "subflow",
3
3
  Flow = "flow"
4
4
  }
5
- declare type FlowType = {
5
+ type FlowType = {
6
6
  TYPE: FlowTypeType;
7
7
  path: string;
8
8
  };
@@ -2,7 +2,7 @@ import { MDNSAdvertiser } from 'hap-nodejs';
2
2
  import { NodeDef } from 'node-red';
3
3
  import { SemVer } from 'semver';
4
4
  import HapCategories from './HapCategories';
5
- declare type HAPHostConfigType = NodeDef & {
5
+ type HAPHostConfigType = NodeDef & {
6
6
  bridgeName: string;
7
7
  pinCode: string;
8
8
  port?: number;
@@ -3,7 +3,7 @@ import { Accessory, Categories } from 'hap-nodejs';
3
3
  import HAPHostConfigType from './HAPHostConfigType';
4
4
  import HostType from './HostType';
5
5
  import NodeType from './NodeType';
6
- declare type HAPHostNodeType = 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
1
  import { Accessory, Characteristic, CharacteristicChange, CharacteristicGetCallback, CharacteristicProps, CharacteristicSetCallback, CharacteristicValue, Service } from 'hap-nodejs';
2
2
  import { HAPConnection } from 'hap-nodejs/dist/lib/util/eventedhttp';
3
3
  import { NodeAPI } from 'node-red';
4
+ import { NodeStatusUtils } from '../utils/NodeStatusUtils';
4
5
  import HAPHostNodeType from './HAPHostNodeType';
5
6
  import HAPService2ConfigType from './HAPService2ConfigType';
6
7
  import HAPServiceNodeType from './HAPServiceNodeType';
7
8
  import NodeType from './NodeType';
8
9
  import PublishTimersType from './PublishTimersType';
9
- import StatusUtilType from './StatusUtilType';
10
- declare type HAPService2NodeType = NodeType & {
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
1
  import { Accessory, Characteristic, CharacteristicChange, CharacteristicGetCallback, CharacteristicProps, CharacteristicSetCallback, CharacteristicValue, Service } from 'hap-nodejs';
2
2
  import { HAPConnection } from 'hap-nodejs/dist/lib/util/eventedhttp';
3
3
  import { NodeAPI } from 'node-red';
4
+ import { NodeStatusUtils } from '../utils/NodeStatusUtils';
4
5
  import HAPHostNodeType from './HAPHostNodeType';
5
6
  import HAPService2NodeType from './HAPService2NodeType';
6
7
  import HAPServiceConfigType from './HAPServiceConfigType';
7
8
  import NodeType from './NodeType';
8
9
  import PublishTimersType from './PublishTimersType';
9
- import StatusUtilType from './StatusUtilType';
10
- declare type HAPServiceNodeType = NodeType & {
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
1
  import { NodeAPI } from 'node-red';
2
+ import { NodeStatusUtils } from '../utils/NodeStatusUtils';
2
3
  import HAPServiceNodeType from './HAPServiceNodeType';
3
4
  import HAPStatusConfigType from './HAPStatusConfigType';
4
5
  import NodeType from './NodeType';
5
- import StatusUtilType from './StatusUtilType';
6
- declare type HAPStatusNodeType = 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,6 +1,6 @@
1
1
  import { Node } from 'node-red';
2
2
  import { FlowType } from './FlowType';
3
- declare type NodeType = Node & {
3
+ type NodeType = Node & {
4
4
  _flow: FlowType;
5
5
  _alias: string;
6
6
  };
@@ -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 };
@@ -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
  }
@@ -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,
@@ -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;
@@ -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,22 +57,25 @@ module.exports = function (node) {
56
57
  if (oldValue !== undefined) {
57
58
  msg.hap.oldValue = oldValue;
58
59
  }
59
- if (!node.reachable) {
60
- msg.hap.reachable = false;
61
- node.setStatus({
62
- fill: 'yellow',
63
- shape: 'dot',
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',
64
66
  text: 'Not reachable',
65
- }, 3000);
67
+ type: 'NO_RESPONSE',
68
+ }));
66
69
  }
67
70
  else {
68
- msg.hap.reachable = true;
69
71
  msg.hap.newValue = newValue;
70
- node.setStatus({
72
+ node.nodeStatusUtils.setStatus({
71
73
  fill: 'yellow',
72
74
  shape: 'dot',
73
75
  text: key + ': ' + newValue,
74
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');
75
79
  }
76
80
  log.debug(`${node.name} received ${key} : ${newValue}`);
77
81
  if (connection ||
@@ -234,7 +238,7 @@ module.exports = function (node) {
234
238
  const waitForParent = () => {
235
239
  log.debug('Waiting for Parent Service');
236
240
  return new Promise((resolve) => {
237
- node.setStatus({
241
+ node.nodeStatusUtils.setStatus({
238
242
  fill: 'blue',
239
243
  shape: 'dot',
240
244
  text: 'Waiting for Parent Service',
@@ -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 = {
@@ -32,22 +33,25 @@ module.exports = function (node) {
32
33
  oldValue,
33
34
  };
34
35
  const key = this.constructor.name;
35
- if (!node.reachable) {
36
- msg.hap.reachable = false;
37
- node.setStatus({
38
- fill: 'yellow',
39
- shape: 'dot',
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',
40
42
  text: 'Not reachable',
41
- }, 3000);
43
+ type: 'NO_RESPONSE',
44
+ }));
42
45
  }
43
46
  else {
44
- msg.hap.reachable = true;
45
47
  msg.hap.newValue = newValue;
46
- node.setStatus({
48
+ node.nodeStatusUtils.setStatus({
47
49
  fill: 'yellow',
48
50
  shape: 'dot',
49
51
  text: `[${eventObject.name}] ${key}${newValue != undefined ? `: ${newValue}` : ''}`,
50
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');
51
55
  }
52
56
  msg.payload[key] = newValue;
53
57
  if (connection) {
@@ -257,7 +261,7 @@ module.exports = function (node) {
257
261
  const waitForParent = () => {
258
262
  log.debug('Waiting for Parent Service');
259
263
  return new Promise((resolve) => {
260
- node.setStatus({
264
+ node.nodeStatusUtils.setStatus({
261
265
  fill: 'blue',
262
266
  shape: 'dot',
263
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
  },
@@ -21,6 +21,7 @@
21
21
  <option value="bonjour-hap" selected="selected">BONJOUR</option>
22
22
  <option value="ciao">CIAO</option>
23
23
  <option value="avahi">AVAHI</option>
24
+ <option value="resolved">RESOLVED</option>
24
25
  </select>
25
26
  </div>
26
27
  <div class="form-row">
@@ -106,7 +107,7 @@
106
107
  <li><strong>Accessory Category</strong>: What kind of category is this Accessory, default <em>OTHER</em></li>
107
108
  <li><strong>Pin Code</strong>: Specify the Pin for the pairing process.</li>
108
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>
109
- <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>
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>
110
111
  <li><strong>Allow Insecure Request</strong>: Should we allow insecure request? Default false.</li>
111
112
  <li><strong>Manufacturer, Model, Serial Number</strong>: Can be anything you want.</li>
112
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>
@@ -158,7 +159,7 @@
158
159
  value: 'bonjour-hap',
159
160
  required: false,
160
161
  validate: function (value) {
161
- if (value) return value === 'bonjour-hap' || value === 'ciao' || value === 'avahi'
162
+ if (value) return value === 'bonjour-hap' || value === 'ciao' || value === 'avahi' || value === 'resolved'
162
163
  else return true
163
164
  },
164
165
  },
@@ -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,14 +1,14 @@
1
1
  {
2
2
  "name": "node-red-contrib-homekit-bridged",
3
- "version": "1.5.0-dev.13",
3
+ "version": "1.5.0-dev.15",
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 --timeout 30000",
9
+ "test": "mocha -r ts-node/register './src/**/*.test.[tj]s' --exit --timeout 30000",
10
10
  "prettier": "prettier --write \"**/*.{js,ts}\"",
11
- "eslint": "eslint \"**/*.ts\"",
11
+ "eslint": "eslint \"src/**/*.ts\"",
12
12
  "prepare": "husky install"
13
13
  },
14
14
  "repository": {
@@ -47,36 +47,36 @@
47
47
  "homepage": "https://github.com/NRCHKB/node-red-contrib-homekit-bridged#readme",
48
48
  "dependencies": {
49
49
  "@nrchkb/logger": "^1.3.3",
50
- "hap-nodejs": "0.10.4",
50
+ "hap-nodejs": "0.11.0",
51
51
  "node-persist": "^3.1.0",
52
- "semver": "^7.3.7",
52
+ "semver": "^7.3.8",
53
53
  "uuid": "^9.0.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@homebridge/ciao": "^1.1.5",
57
57
  "@node-red/registry": "^2.2.3",
58
- "@types/mocha": "^9.1.1",
58
+ "@types/mocha": "^10.0.0",
59
59
  "@types/node": "^10.17.60",
60
60
  "@types/node-persist": "^3.1.3",
61
61
  "@types/node-red": "^1.2.1",
62
62
  "@types/node-red-node-test-helper": "^0.2.2",
63
- "@types/semver": "^7.3.12",
63
+ "@types/semver": "^7.3.13",
64
64
  "@types/uuid": "^8.3.4",
65
- "@typescript-eslint/eslint-plugin": "^5.38.1",
66
- "@typescript-eslint/parser": "^5.38.1",
65
+ "@typescript-eslint/eslint-plugin": "^5.43.0",
66
+ "@typescript-eslint/parser": "^5.43.0",
67
67
  "babel-eslint": "^10.1.0",
68
- "eslint": "^8.24.0",
68
+ "eslint": "^8.28.0",
69
69
  "eslint-config-prettier": "^8.5.0",
70
70
  "eslint-plugin-prettier": "^4.2.1",
71
71
  "eslint-plugin-simple-import-sort": "^8.0.0",
72
- "husky": "^8.0.1",
73
- "mocha": "^10.0.0",
72
+ "husky": "^8.0.2",
73
+ "mocha": "^10.1.0",
74
74
  "node-red": "^2.2.3",
75
75
  "node-red-node-test-helper": "^0.3.0",
76
76
  "prettier": "^2.7.1",
77
77
  "rimraf": "^3.0.2",
78
78
  "ts-node": "^10.9.1",
79
- "typescript": "^4.8.4"
79
+ "typescript": "^4.9.3"
80
80
  },
81
81
  "engines": {
82
82
  "node": ">=10.22.1"
@@ -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 });