node-red-contrib-homekit-bridged 1.5.0-dev.12 → 1.5.0-dev.14
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.
- package/build/lib/HAPServiceNode.js +7 -15
- package/build/lib/HAPServiceNode2.js +6 -14
- package/build/lib/types/HAPService2NodeType.d.ts +4 -3
- package/build/lib/types/HAPServiceNodeType.d.ts +4 -3
- package/build/lib/types/HAPStatusNodeType.d.ts +3 -2
- package/build/lib/utils/AccessoryUtils.js +4 -3
- package/build/lib/utils/BridgeUtils.js +1 -1
- package/build/lib/utils/NodeStatusUtils.d.ts +18 -0
- package/build/lib/utils/NodeStatusUtils.js +48 -0
- package/build/lib/utils/ServiceUtils.js +13 -9
- package/build/lib/utils/ServiceUtils2.js +13 -9
- package/build/nodes/standalone.html +3 -2
- package/build/nodes/status.js +5 -24
- package/package.json +4 -4
- package/build/lib/types/StatusUtilType.d.ts +0 -8
- package/build/lib/types/StatusUtilType.js +0 -2
|
@@ -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.
|
|
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
|
-
|
|
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.
|
|
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,
|
|
@@ -1,12 +1,12 @@
|
|
|
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
10
|
declare type HAPService2NodeType = NodeType & {
|
|
11
11
|
config: HAPService2ConfigType;
|
|
12
12
|
RED: NodeAPI;
|
|
@@ -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
|
|
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
|
-
|
|
34
|
+
nodeStatusUtils: NodeStatusUtils;
|
|
35
|
+
};
|
|
35
36
|
export default HAPService2NodeType;
|
|
@@ -1,12 +1,12 @@
|
|
|
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
10
|
declare type HAPServiceNodeType = NodeType & {
|
|
11
11
|
config: HAPServiceConfigType;
|
|
12
12
|
RED: NodeAPI;
|
|
@@ -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
|
|
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
|
-
|
|
34
|
+
nodeStatusUtils: NodeStatusUtils;
|
|
35
|
+
};
|
|
35
36
|
export default HAPServiceNodeType;
|
|
@@ -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
6
|
declare type HAPStatusNodeType = NodeType & {
|
|
7
7
|
config: HAPStatusConfigType;
|
|
8
8
|
RED: NodeAPI;
|
|
9
9
|
serviceNode?: HAPServiceNodeType;
|
|
10
|
-
|
|
10
|
+
nodeStatusUtils: NodeStatusUtils;
|
|
11
|
+
};
|
|
11
12
|
export default HAPStatusNodeType;
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node-red__registry" />
|
|
2
|
+
import { NodeStatus } from '@node-red/registry';
|
|
3
|
+
import NodeType from '../types/NodeType';
|
|
4
|
+
declare type StatusType = 'NO_RESPONSE' | 'MSG';
|
|
5
|
+
declare type NodeStatusWithType = NodeStatus & {
|
|
6
|
+
type?: StatusType;
|
|
7
|
+
};
|
|
8
|
+
declare 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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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',
|
|
@@ -20,6 +20,7 @@
|
|
|
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>
|
|
23
24
|
</select>
|
|
24
25
|
</div>
|
|
25
26
|
<div class="form-row">
|
|
@@ -105,7 +106,7 @@
|
|
|
105
106
|
<li><strong>Accessory Category</strong>: What kind of category is this Accessory, default <em>OTHER</em></li>
|
|
106
107
|
<li><strong>Pin Code</strong>: Specify the Pin for the pairing process.</li>
|
|
107
108
|
<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>
|
|
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>
|
|
109
110
|
<li><strong>Allow Insecure Request</strong>: Should we allow insecure request? Default false.</li>
|
|
110
111
|
<li><strong>Manufacturer, Model, Serial Number</strong>: Can be anything you want.</li>
|
|
111
112
|
<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 +158,7 @@
|
|
|
157
158
|
value: 'bonjour-hap',
|
|
158
159
|
required: false,
|
|
159
160
|
validate: function (value) {
|
|
160
|
-
if (value) return value === 'bonjour-hap' || value === 'ciao'
|
|
161
|
+
if (value) return value === 'bonjour-hap' || value === 'ciao' || value === 'avahi'
|
|
161
162
|
else return true
|
|
162
163
|
},
|
|
163
164
|
},
|
package/build/nodes/status.js
CHANGED
|
@@ -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.
|
|
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
|
-
}
|
|
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.
|
|
3
|
+
"version": "1.5.0-dev.14",
|
|
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": "
|
|
9
|
+
"test": "mocha -r ts-node/register './src/**/*.test.[tj]s' --exit --timeout 30000",
|
|
10
10
|
"prettier": "prettier --write \"**/*.{js,ts}\"",
|
|
11
|
-
"eslint": "eslint \"
|
|
11
|
+
"eslint": "eslint \"src/**/*.ts\"",
|
|
12
12
|
"prepare": "husky install"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@homebridge/ciao": "^1.1.5",
|
|
57
57
|
"@node-red/registry": "^2.2.3",
|
|
58
|
-
"@types/mocha": "^
|
|
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",
|
|
@@ -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;
|