node-red-contrib-homekit-bridged 1.5.0-dev.9 → 1.5.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.
- package/build/lib/HAPHostNode.js +24 -11
- package/build/lib/HAPServiceNode.js +10 -18
- package/build/lib/HAPServiceNode2.js +9 -17
- package/build/lib/Storage.d.ts +3 -3
- package/build/lib/Storage.js +3 -3
- package/build/lib/api.js +18 -9
- package/build/lib/types/AccessoryInformationType.d.ts +1 -1
- package/build/lib/types/CameraConfigType.d.ts +1 -1
- package/build/lib/types/CustomCharacteristicType.d.ts +1 -1
- package/build/lib/types/FlowType.d.ts +1 -1
- package/build/lib/types/HAPHostConfigType.d.ts +2 -2
- package/build/lib/types/HAPHostNodeType.d.ts +4 -4
- package/build/lib/types/HAPService2ConfigType.d.ts +1 -1
- package/build/lib/types/HAPService2NodeType.d.ts +10 -9
- package/build/lib/types/HAPServiceConfigType.d.ts +1 -1
- package/build/lib/types/HAPServiceNodeType.d.ts +10 -9
- package/build/lib/types/HAPStatusConfigType.d.ts +1 -1
- package/build/lib/types/HAPStatusNodeType.d.ts +5 -4
- package/build/lib/types/NodeType.d.ts +1 -1
- package/build/lib/types/PublishTimersType.d.ts +1 -1
- package/build/lib/types/storage/SerializedHostType.d.ts +1 -1
- package/build/lib/utils/AccessoryUtils.js +4 -3
- package/build/lib/utils/BridgeUtils.js +2 -2
- package/build/lib/utils/CharacteristicUtils.js +1 -1
- package/build/lib/utils/CharacteristicUtils2.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 +23 -11
- package/build/lib/utils/ServiceUtils2.js +25 -12
- package/build/nodes/bridge.html +3 -2
- package/build/nodes/bridge.js +1 -1
- package/build/nodes/nrchkb.js +2 -2
- package/build/nodes/standalone.html +4 -2
- package/build/nodes/standalone.js +1 -1
- package/build/nodes/status.js +5 -24
- package/package.json +15 -12
- package/build/lib/types/StatusUtilType.d.ts +0 -8
- package/build/lib/types/StatusUtilType.js +0 -2
package/build/lib/HAPHostNode.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
121
|
+
done();
|
|
122
|
+
});
|
|
110
123
|
});
|
|
111
124
|
self.host.on('identify', function (paired, callback) {
|
|
112
125
|
if (paired) {
|
|
@@ -3,11 +3,12 @@ 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
|
|
7
|
+
const hap_nodejs_1 = require("hap-nodejs");
|
|
10
8
|
const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
|
|
9
|
+
const FlowType_1 = require("./types/FlowType");
|
|
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,
|
|
@@ -3,11 +3,12 @@ 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
|
|
7
|
+
const hap_nodejs_1 = require("hap-nodejs");
|
|
10
8
|
const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
|
|
9
|
+
const FlowType_1 = require("./types/FlowType");
|
|
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,
|
package/build/lib/Storage.d.ts
CHANGED
|
@@ -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
|
-
|
|
4
|
+
import { StorageType } from './types/storage/StorageType';
|
|
5
|
+
type EventCallback = {
|
|
6
6
|
event: CharacteristicEventTypes;
|
|
7
7
|
callback: (value?: any) => void;
|
|
8
8
|
};
|
package/build/lib/Storage.js
CHANGED
|
@@ -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
|
|
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
|
|
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(
|
|
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
|
|
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,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
|
-
|
|
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
|
|
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
|
|
6
|
-
|
|
5
|
+
import NodeType from './NodeType';
|
|
6
|
+
type HAPHostNodeType = NodeType & {
|
|
7
7
|
config: HAPHostConfigType;
|
|
8
8
|
mdnsConfig: MulticastOptions;
|
|
9
9
|
accessoryCategory: Categories;
|
|
@@ -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
|
|
7
|
-
import StatusUtilType from './StatusUtilType';
|
|
6
|
+
import HAPService2ConfigType from './HAPService2ConfigType';
|
|
8
7
|
import HAPServiceNodeType from './HAPServiceNodeType';
|
|
9
|
-
import
|
|
10
|
-
|
|
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
|
|
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,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
|
|
10
|
-
|
|
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
|
|
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
|
-
import NodeType from './NodeType';
|
|
2
1
|
import { NodeAPI } from 'node-red';
|
|
3
|
-
import
|
|
2
|
+
import { NodeStatusUtils } from '../utils/NodeStatusUtils';
|
|
4
3
|
import HAPServiceNodeType from './HAPServiceNodeType';
|
|
5
4
|
import HAPStatusConfigType from './HAPStatusConfigType';
|
|
6
|
-
|
|
5
|
+
import NodeType from './NodeType';
|
|
6
|
+
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
|
}
|
|
@@ -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.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
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',
|
package/build/nodes/bridge.html
CHANGED
|
@@ -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
|
},
|
package/build/nodes/bridge.js
CHANGED
|
@@ -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);
|
package/build/nodes/nrchkb.js
CHANGED
|
@@ -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);
|
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,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-homekit-bridged",
|
|
3
|
-
"version": "1.5.0
|
|
3
|
+
"version": "1.5.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": "
|
|
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": {
|
|
@@ -46,34 +47,36 @@
|
|
|
46
47
|
"homepage": "https://github.com/NRCHKB/node-red-contrib-homekit-bridged#readme",
|
|
47
48
|
"dependencies": {
|
|
48
49
|
"@nrchkb/logger": "^1.3.3",
|
|
49
|
-
"hap-nodejs": "0.
|
|
50
|
+
"hap-nodejs": "0.11.0",
|
|
50
51
|
"node-persist": "^3.1.0",
|
|
51
|
-
"semver": "^7.3.
|
|
52
|
+
"semver": "^7.3.8",
|
|
52
53
|
"uuid": "^9.0.0"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@homebridge/ciao": "^1.1.5",
|
|
56
57
|
"@node-red/registry": "^2.2.3",
|
|
57
|
-
"@types/mocha": "^
|
|
58
|
+
"@types/mocha": "^10.0.0",
|
|
58
59
|
"@types/node": "^10.17.60",
|
|
59
60
|
"@types/node-persist": "^3.1.3",
|
|
60
61
|
"@types/node-red": "^1.2.1",
|
|
61
|
-
"@types/
|
|
62
|
+
"@types/node-red-node-test-helper": "^0.2.2",
|
|
63
|
+
"@types/semver": "^7.3.13",
|
|
62
64
|
"@types/uuid": "^8.3.4",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
64
|
-
"@typescript-eslint/parser": "^5.
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^5.43.0",
|
|
66
|
+
"@typescript-eslint/parser": "^5.43.0",
|
|
65
67
|
"babel-eslint": "^10.1.0",
|
|
66
|
-
"eslint": "^8.
|
|
68
|
+
"eslint": "^8.28.0",
|
|
67
69
|
"eslint-config-prettier": "^8.5.0",
|
|
68
70
|
"eslint-plugin-prettier": "^4.2.1",
|
|
69
|
-
"
|
|
71
|
+
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
72
|
+
"husky": "^8.0.2",
|
|
73
|
+
"mocha": "^10.1.0",
|
|
70
74
|
"node-red": "^2.2.3",
|
|
71
75
|
"node-red-node-test-helper": "^0.3.0",
|
|
72
76
|
"prettier": "^2.7.1",
|
|
73
77
|
"rimraf": "^3.0.2",
|
|
74
78
|
"ts-node": "^10.9.1",
|
|
75
|
-
"typescript": "^4.
|
|
76
|
-
"husky": "^8.0.1"
|
|
79
|
+
"typescript": "^4.9.3"
|
|
77
80
|
},
|
|
78
81
|
"engines": {
|
|
79
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;
|