node-red-contrib-homekit-bridged 2.0.0-dev.1 → 2.0.0-dev.3
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 +59 -62
- package/build/lib/HAPServiceNode.js +89 -93
- package/build/lib/HAPServiceNode2.js +91 -95
- package/build/lib/Storage.d.ts +3 -3
- package/build/lib/Storage.js +2 -2
- package/build/lib/api.js +9 -11
- package/build/lib/hap/HAPCharacteristic.d.ts +1 -1
- package/build/lib/hap/HAPService.d.ts +1 -1
- package/build/lib/hap/eve-app/EveCharacteristics.d.ts +1 -1
- package/build/lib/types/CustomCharacteristicType.d.ts +1 -1
- package/build/lib/types/HAPHostConfigType.d.ts +4 -4
- package/build/lib/types/HAPHostNodeType.d.ts +4 -4
- package/build/lib/types/HAPService2ConfigType.d.ts +2 -2
- package/build/lib/types/HAPService2NodeType.d.ts +3 -3
- package/build/lib/types/HAPServiceConfigType.d.ts +3 -3
- package/build/lib/types/HAPServiceNodeType.d.ts +10 -10
- package/build/lib/types/HAPStatusConfigType.d.ts +1 -1
- package/build/lib/types/HAPStatusNodeType.d.ts +5 -5
- package/build/lib/types/NodeType.d.ts +1 -1
- package/build/lib/types/storage/SerializedHostType.d.ts +2 -2
- package/build/lib/utils/AccessoryUtils.js +8 -10
- package/build/lib/utils/BridgeUtils.js +4 -4
- package/build/lib/utils/CharacteristicUtils.js +5 -5
- package/build/lib/utils/CharacteristicUtils2.js +5 -5
- package/build/lib/utils/NodeStatusUtils.d.ts +2 -2
- package/build/lib/utils/NodeStatusUtils.js +2 -2
- package/build/lib/utils/ServiceUtils.js +26 -21
- package/build/lib/utils/ServiceUtils2.js +28 -25
- package/build/lib/utils/index.js +1 -1
- package/build/nodes/nrchkb.js +2 -2
- package/build/nodes/status.js +12 -13
- package/package.json +3 -2
|
@@ -10,69 +10,66 @@ const HostType_1 = __importDefault(require("./types/HostType"));
|
|
|
10
10
|
const NodeStatusUtils_1 = require("./utils/NodeStatusUtils");
|
|
11
11
|
module.exports = (RED) => {
|
|
12
12
|
const nrchkbConfigCompatibilityOverride = function () {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
self.config.isParent = true;
|
|
13
|
+
const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', this.config.name, this);
|
|
14
|
+
if (this.config.isParent === undefined) {
|
|
15
|
+
log.trace(`nrchkbConfigCompatibilityOverride => self.config.isParent=${this.config.isParent} value changed to true`);
|
|
16
|
+
this.config.isParent = true;
|
|
18
17
|
}
|
|
19
|
-
if (
|
|
20
|
-
log.trace(`nrchkbConfigCompatibilityOverride => self.config.hostType=${
|
|
21
|
-
|
|
18
|
+
if (this.config.hostType === undefined) {
|
|
19
|
+
log.trace(`nrchkbConfigCompatibilityOverride => self.config.hostType=${this.config.hostType} value changed to HostType.BRIDGE`);
|
|
20
|
+
this.config.hostType = HostType_1.default.BRIDGE;
|
|
22
21
|
}
|
|
23
22
|
};
|
|
24
23
|
const preInit = function (config) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const ServiceUtils = require('./utils/ServiceUtils2')(self);
|
|
24
|
+
this.nodeStatusUtils = new NodeStatusUtils_1.NodeStatusUtils(this);
|
|
25
|
+
this.config = config;
|
|
26
|
+
this.name = this.config.name;
|
|
27
|
+
const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', this.config.name, this);
|
|
28
|
+
this.RED = RED;
|
|
29
|
+
this.publishTimers = {};
|
|
30
|
+
nrchkbConfigCompatibilityOverride.call(this);
|
|
31
|
+
RED.nodes.createNode(this, this.config);
|
|
32
|
+
const ServiceUtils = require('./utils/ServiceUtils2')(this);
|
|
35
33
|
new Promise((resolve) => {
|
|
36
|
-
if (
|
|
34
|
+
if (this.config.waitForSetupMsg) {
|
|
37
35
|
log.debug('Waiting for Setup message. It should be of format {"payload":{"nrchkb":{"setup":{}}}}');
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
this.setupDone = false;
|
|
37
|
+
this.nodeStatusUtils.setStatus({
|
|
40
38
|
fill: 'blue',
|
|
41
39
|
shape: 'dot',
|
|
42
40
|
text: 'Waiting for Setup'
|
|
43
41
|
});
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
this.handleWaitForSetup = (msg) => ServiceUtils.handleWaitForSetup(this.config, msg, resolve);
|
|
43
|
+
this.on('input', this.handleWaitForSetup);
|
|
46
44
|
}
|
|
47
45
|
else {
|
|
48
|
-
resolve(
|
|
46
|
+
resolve(this.config);
|
|
49
47
|
}
|
|
50
48
|
})
|
|
51
49
|
.then((newConfig) => {
|
|
52
|
-
init.call(
|
|
50
|
+
init.call(this, newConfig);
|
|
53
51
|
})
|
|
54
52
|
.catch((error) => {
|
|
55
53
|
log.error(`Error while starting Service due to ${error}`);
|
|
56
54
|
});
|
|
57
55
|
};
|
|
58
56
|
const init = function (config) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
if (self.config.isParent) {
|
|
57
|
+
this.config = config;
|
|
58
|
+
const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', this.config.name, this);
|
|
59
|
+
const ServiceUtils = require('./utils/ServiceUtils2')(this);
|
|
60
|
+
if (this.config.isParent) {
|
|
64
61
|
log.debug('Starting Parent Service');
|
|
65
|
-
configure.call(
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
configure.call(this);
|
|
63
|
+
this.configured = true;
|
|
64
|
+
this.reachable = true;
|
|
68
65
|
}
|
|
69
66
|
else {
|
|
70
67
|
const serviceType = config.serviceName === 'CameraControl' ? 'Camera' : 'Linked';
|
|
71
68
|
ServiceUtils.waitForParent()
|
|
72
69
|
.then(() => {
|
|
73
70
|
log.debug(`Starting ${serviceType} Service`);
|
|
74
|
-
configure.call(
|
|
75
|
-
|
|
71
|
+
configure.call(this);
|
|
72
|
+
this.configured = true;
|
|
76
73
|
})
|
|
77
74
|
.catch((error) => {
|
|
78
75
|
log.error(`Error while starting ${serviceType} Service due to ${error}`);
|
|
@@ -81,99 +78,98 @@ module.exports = (RED) => {
|
|
|
81
78
|
};
|
|
82
79
|
const configure = function () {
|
|
83
80
|
var _a, _b;
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const Utils = require('./utils')(self);
|
|
81
|
+
const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', this.config.name, this);
|
|
82
|
+
const Utils = require('./utils')(this);
|
|
87
83
|
const AccessoryUtils = Utils.AccessoryUtils;
|
|
88
84
|
const BridgeUtils = Utils.BridgeUtils;
|
|
89
|
-
const CharacteristicUtils = require('./utils/CharacteristicUtils2')(
|
|
90
|
-
const ServiceUtils = require('./utils/ServiceUtils2')(
|
|
85
|
+
const CharacteristicUtils = require('./utils/CharacteristicUtils2')(this);
|
|
86
|
+
const ServiceUtils = require('./utils/ServiceUtils2')(this);
|
|
91
87
|
let parentNode;
|
|
92
|
-
if (
|
|
93
|
-
const hostId =
|
|
94
|
-
?
|
|
95
|
-
:
|
|
96
|
-
|
|
97
|
-
if (!
|
|
98
|
-
const message = `Host node ${
|
|
88
|
+
if (this.config.isParent) {
|
|
89
|
+
const hostId = this.config.hostType == HostType_1.default.BRIDGE
|
|
90
|
+
? this.config.bridge
|
|
91
|
+
: this.config.accessoryId;
|
|
92
|
+
this.hostNode = RED.nodes.getNode(hostId);
|
|
93
|
+
if (!this.hostNode) {
|
|
94
|
+
const message = `Host node ${this.config.hostType == HostType_1.default.BRIDGE ? 'Bridge' : 'Standalone Accessory'} ${hostId} not found`;
|
|
99
95
|
log.error(message, false);
|
|
100
96
|
throw new NRCHKBError_1.default(message);
|
|
101
97
|
}
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
this.childNodes = [];
|
|
99
|
+
this.childNodes.push(this);
|
|
104
100
|
}
|
|
105
101
|
else {
|
|
106
|
-
parentNode = RED.nodes.getNode(
|
|
102
|
+
parentNode = RED.nodes.getNode(this.config.parentService);
|
|
107
103
|
if (!parentNode) {
|
|
108
104
|
log.error('Parent Node not assigned', false);
|
|
109
105
|
throw new NRCHKBError_1.default('Parent Node not assigned');
|
|
110
106
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (!
|
|
107
|
+
this.parentNode = parentNode;
|
|
108
|
+
this.parentService = this.parentNode.service;
|
|
109
|
+
if (!this.parentService) {
|
|
114
110
|
log.error('Parent Service not assigned', false);
|
|
115
111
|
throw new NRCHKBError_1.default('Parent Service not assigned');
|
|
116
112
|
}
|
|
117
|
-
|
|
118
|
-
(_a =
|
|
119
|
-
|
|
113
|
+
this.hostNode = this.parentNode.hostNode;
|
|
114
|
+
(_a = this.parentNode.childNodes) === null || _a === void 0 ? void 0 : _a.push(this);
|
|
115
|
+
this.accessory = this.parentNode.accessory;
|
|
120
116
|
}
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
117
|
+
this.name = this.config.name;
|
|
118
|
+
if (Object.hasOwn(this, '_flow') &&
|
|
119
|
+
Object.hasOwn(this, '_alias') &&
|
|
120
|
+
(this._flow ? Object(this._flow).hasOwn('TYPE') : false) &&
|
|
121
|
+
((_b = this._flow) === null || _b === void 0 ? void 0 : _b.TYPE) === 'subflow') {
|
|
122
|
+
this.uniqueIdentifier = `${this._alias}/${this._flow.path}`;
|
|
127
123
|
}
|
|
128
124
|
else {
|
|
129
|
-
|
|
125
|
+
this.uniqueIdentifier = this.id;
|
|
130
126
|
}
|
|
131
|
-
const subtypeUUID = hap_nodejs_1.uuid.generate(
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
127
|
+
const subtypeUUID = hap_nodejs_1.uuid.generate(this.uniqueIdentifier);
|
|
128
|
+
if (this.config.hostType == HostType_1.default.BRIDGE) {
|
|
129
|
+
if (this.config.isParent) {
|
|
134
130
|
const accessoryUUID = hap_nodejs_1.uuid.generate('A' +
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
name:
|
|
131
|
+
this.uniqueIdentifier +
|
|
132
|
+
this.name +
|
|
133
|
+
this.config.manufacturer +
|
|
134
|
+
this.config.serialNo +
|
|
135
|
+
this.config.model);
|
|
136
|
+
this.accessory = AccessoryUtils.getOrCreate(this.hostNode.host, {
|
|
137
|
+
name: this.name,
|
|
142
138
|
UUID: accessoryUUID,
|
|
143
|
-
manufacturer:
|
|
144
|
-
serialNo:
|
|
145
|
-
model:
|
|
146
|
-
firmwareRev:
|
|
147
|
-
hardwareRev:
|
|
148
|
-
softwareRev:
|
|
139
|
+
manufacturer: this.config.manufacturer,
|
|
140
|
+
serialNo: this.config.serialNo,
|
|
141
|
+
model: this.config.model,
|
|
142
|
+
firmwareRev: this.config.firmwareRev,
|
|
143
|
+
hardwareRev: this.config.hardwareRev,
|
|
144
|
+
softwareRev: this.config.softwareRev
|
|
149
145
|
}, subtypeUUID);
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
this.onIdentify = AccessoryUtils.onIdentify;
|
|
147
|
+
this.accessory.on('identify', this.onIdentify);
|
|
152
148
|
}
|
|
153
149
|
}
|
|
154
150
|
else {
|
|
155
151
|
log.debug('Binding Service accessory as Standalone Accessory');
|
|
156
|
-
|
|
152
|
+
this.accessory = this.hostNode.host;
|
|
157
153
|
}
|
|
158
|
-
|
|
159
|
-
name:
|
|
154
|
+
this.service = ServiceUtils.getOrCreate(this.accessory, {
|
|
155
|
+
name: this.name,
|
|
160
156
|
UUID: subtypeUUID,
|
|
161
|
-
serviceName:
|
|
162
|
-
config:
|
|
163
|
-
},
|
|
164
|
-
|
|
157
|
+
serviceName: this.config.serviceName,
|
|
158
|
+
config: this.config
|
|
159
|
+
}, this.parentService);
|
|
160
|
+
this.characteristicProperties = CharacteristicUtils.load(this.service, this.config);
|
|
165
161
|
ServiceUtils.configureAdaptiveLightning();
|
|
166
|
-
if (
|
|
167
|
-
BridgeUtils.delayedPublish(
|
|
162
|
+
if (this.config.isParent) {
|
|
163
|
+
BridgeUtils.delayedPublish(this);
|
|
168
164
|
}
|
|
169
|
-
|
|
165
|
+
this.nodeStatusUtils.setStatus({
|
|
170
166
|
fill: 'yellow',
|
|
171
167
|
shape: 'ring',
|
|
172
|
-
text:
|
|
168
|
+
text: this.hostNode.config.pinCode
|
|
173
169
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
this.supported = CharacteristicUtils.subscribeAndGetSupported(this.service);
|
|
171
|
+
this.on('input', ServiceUtils.onInput);
|
|
172
|
+
this.on('close', ServiceUtils.onClose);
|
|
177
173
|
};
|
|
178
174
|
return {
|
|
179
175
|
preInit,
|
package/build/lib/Storage.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CharacteristicEventTypes, SerializedAccessory, SerializedService } from '@homebridge/hap-nodejs';
|
|
2
|
-
import storage, { InitOptions } from 'node-persist';
|
|
3
|
-
import { SerializedHostType } from './types/storage/SerializedHostType';
|
|
1
|
+
import type { CharacteristicEventTypes, SerializedAccessory, SerializedService } from '@homebridge/hap-nodejs';
|
|
2
|
+
import storage, { type InitOptions } from 'node-persist';
|
|
3
|
+
import type { SerializedHostType } from './types/storage/SerializedHostType';
|
|
4
4
|
import { StorageType } from './types/storage/StorageType';
|
|
5
5
|
type EventCallback = {
|
|
6
6
|
event: CharacteristicEventTypes;
|
package/build/lib/Storage.js
CHANGED
|
@@ -4,9 +4,9 @@ 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 node_path_1 = __importDefault(require("node:path"));
|
|
7
8
|
const logger_1 = require("@nrchkb/logger");
|
|
8
9
|
const node_persist_1 = __importDefault(require("node-persist"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const uuid_1 = require("uuid");
|
|
11
11
|
const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
|
|
12
12
|
const StorageType_1 = require("./types/storage/StorageType");
|
|
@@ -18,7 +18,7 @@ class Storage {
|
|
|
18
18
|
return Storage.customStoragePath;
|
|
19
19
|
}
|
|
20
20
|
static init(...storagePathSegments) {
|
|
21
|
-
Storage.customStoragePath =
|
|
21
|
+
Storage.customStoragePath = node_path_1.default.resolve(...storagePathSegments);
|
|
22
22
|
Storage.storageInitialized = true;
|
|
23
23
|
Storage.log.trace('Initializing');
|
|
24
24
|
return node_persist_1.default.init({ dir: Storage.storagePath() });
|
package/build/lib/api.js
CHANGED
|
@@ -29,7 +29,7 @@ const EveCharacteristics_1 = __importDefault(require("./hap/eve-app/EveCharacter
|
|
|
29
29
|
const Storage_1 = require("./Storage");
|
|
30
30
|
const HapCategories_1 = __importDefault(require("./types/hap-nodejs/HapCategories"));
|
|
31
31
|
const version = require('../../package.json').version.trim();
|
|
32
|
-
module.exports =
|
|
32
|
+
module.exports = (RED) => {
|
|
33
33
|
const log = (0, logger_1.logger)('NRCHKB', 'API');
|
|
34
34
|
const _initServiceAPI = () => {
|
|
35
35
|
log.debug('Initialize Service API');
|
|
@@ -132,8 +132,8 @@ module.exports = function (RED) {
|
|
|
132
132
|
});
|
|
133
133
|
});
|
|
134
134
|
};
|
|
135
|
-
const _initNRCHKBCustomCharacteristicsAPI = () => __awaiter(
|
|
136
|
-
const getCustomCharacteristics = () => __awaiter(
|
|
135
|
+
const _initNRCHKBCustomCharacteristicsAPI = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
+
const getCustomCharacteristics = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
137
|
try {
|
|
138
138
|
const value = yield Storage_1.Storage.loadCustomCharacteristics();
|
|
139
139
|
log.trace('loadCustomCharacteristics()');
|
|
@@ -156,7 +156,7 @@ module.exports = function (RED) {
|
|
|
156
156
|
};
|
|
157
157
|
const toNumber = (value, optional = undefined) => {
|
|
158
158
|
const num = Number(value);
|
|
159
|
-
if (isNaN(num)) {
|
|
159
|
+
if (Number.isNaN(num)) {
|
|
160
160
|
return optional;
|
|
161
161
|
}
|
|
162
162
|
else
|
|
@@ -238,9 +238,7 @@ module.exports = function (RED) {
|
|
|
238
238
|
node.type === 'homekit-service2') {
|
|
239
239
|
const serviceNodeConfig = node;
|
|
240
240
|
const serviceNode = RED.nodes.getNode(serviceNodeConfig.id);
|
|
241
|
-
if (serviceNode &&
|
|
242
|
-
serviceNode.characteristicProperties &&
|
|
243
|
-
serviceNode.service) {
|
|
241
|
+
if ((serviceNode === null || serviceNode === void 0 ? void 0 : serviceNode.characteristicProperties) && serviceNode.service) {
|
|
244
242
|
for (const key in serviceNode.characteristicProperties) {
|
|
245
243
|
if (customCharacteristicKeys.includes(key)) {
|
|
246
244
|
const characteristic = serviceNode.service
|
|
@@ -259,13 +257,13 @@ module.exports = function (RED) {
|
|
|
259
257
|
};
|
|
260
258
|
log.debug('Initialize NRCHKBCustomCharacteristicsAPI');
|
|
261
259
|
getCustomCharacteristics().then((value) => refreshCustomCharacteristics(value));
|
|
262
|
-
RED.httpAdmin.get('/nrchkb/config', RED.auth.needsPermission('nrchkb.read'), (_req, res) => __awaiter(
|
|
260
|
+
RED.httpAdmin.get('/nrchkb/config', RED.auth.needsPermission('nrchkb.read'), (_req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
263
261
|
res.setHeader('Content-Type', 'application/json');
|
|
264
262
|
res.json({
|
|
265
263
|
customCharacteristics: yield getCustomCharacteristics()
|
|
266
264
|
});
|
|
267
265
|
}));
|
|
268
|
-
RED.httpAdmin.post('/nrchkb/config', RED.auth.needsPermission('nrchkb.write'), (req, res) => __awaiter(
|
|
266
|
+
RED.httpAdmin.post('/nrchkb/config', RED.auth.needsPermission('nrchkb.write'), (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
269
267
|
const customCharacteristics = req.body.customCharacteristics || EveCharacteristics_1.default;
|
|
270
268
|
Storage_1.Storage.saveCustomCharacteristics(customCharacteristics)
|
|
271
269
|
.then(() => {
|
|
@@ -278,12 +276,12 @@ module.exports = function (RED) {
|
|
|
278
276
|
});
|
|
279
277
|
}));
|
|
280
278
|
});
|
|
281
|
-
const _initAccessoryAPI =
|
|
279
|
+
const _initAccessoryAPI = () => {
|
|
282
280
|
log.debug('Initialize Accessory API');
|
|
283
281
|
const accessoryCategoriesData = {};
|
|
284
282
|
Object.keys(HapCategories_1.default)
|
|
285
283
|
.sort()
|
|
286
|
-
.filter((x) => parseInt(x) >= 0)
|
|
284
|
+
.filter((x) => parseInt(x, 10) >= 0)
|
|
287
285
|
.forEach((key) => {
|
|
288
286
|
const keyNumber = key;
|
|
289
287
|
accessoryCategoriesData[keyNumber] = HapCategories_1.default[keyNumber];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Characteristic } from '@homebridge/hap-nodejs';
|
|
2
|
-
import { EveS2R1, EveS2R2, EveS2W1, EveS2W2 } from './eve-app/EveCharacteristics';
|
|
2
|
+
import type { EveS2R1, EveS2R2, EveS2W1, EveS2W2 } from './eve-app/EveCharacteristics';
|
|
3
3
|
declare class HAPCharacteristic extends Characteristic {
|
|
4
4
|
static EveS2R1: typeof EveS2R1;
|
|
5
5
|
static EveS2R2: typeof EveS2R2;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import CustomCharacteristicType from '../../types/CustomCharacteristicType';
|
|
1
|
+
import type CustomCharacteristicType from '../../types/CustomCharacteristicType';
|
|
2
2
|
import HAPCharacteristic from '../HAPCharacteristic';
|
|
3
3
|
declare const EveCharacteristics: CustomCharacteristicType[];
|
|
4
4
|
export declare class EveS2R1 extends HAPCharacteristic {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MDNSAdvertiser } from '@homebridge/hap-nodejs';
|
|
2
|
-
import { NodeDef } from 'node-red';
|
|
3
|
-
import { SemVer } from 'semver';
|
|
4
|
-
import HapCategories from './hap-nodejs/HapCategories';
|
|
1
|
+
import type { MDNSAdvertiser } from '@homebridge/hap-nodejs';
|
|
2
|
+
import type { NodeDef } from 'node-red';
|
|
3
|
+
import type { SemVer } from 'semver';
|
|
4
|
+
import type HapCategories from './hap-nodejs/HapCategories';
|
|
5
5
|
type HAPHostConfigType = NodeDef & {
|
|
6
6
|
bridgeName: string;
|
|
7
7
|
pinCode: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Accessory, Categories } from '@homebridge/hap-nodejs';
|
|
2
|
-
import HAPHostConfigType from './HAPHostConfigType';
|
|
3
|
-
import HostType from './HostType';
|
|
4
|
-
import NodeType from './NodeType';
|
|
1
|
+
import type { Accessory, Categories } from '@homebridge/hap-nodejs';
|
|
2
|
+
import type HAPHostConfigType from './HAPHostConfigType';
|
|
3
|
+
import type HostType from './HostType';
|
|
4
|
+
import type NodeType from './NodeType';
|
|
5
5
|
type HAPHostNodeType = NodeType & {
|
|
6
6
|
config: HAPHostConfigType;
|
|
7
7
|
accessoryCategory: Categories;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NodeDef } from 'node-red';
|
|
2
|
-
import HAPServiceConfigType from './HAPServiceConfigType';
|
|
1
|
+
import type { NodeDef } from 'node-red';
|
|
2
|
+
import type HAPServiceConfigType from './HAPServiceConfigType';
|
|
3
3
|
type HAPService2ConfigType = NodeDef & HAPServiceConfigType & {
|
|
4
4
|
useEventCallback: boolean;
|
|
5
5
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import HAPService2ConfigType from './HAPService2ConfigType';
|
|
2
|
-
import HAPServiceNodeType from './HAPServiceNodeType';
|
|
3
|
-
import NodeType from './NodeType';
|
|
1
|
+
import type HAPService2ConfigType from './HAPService2ConfigType';
|
|
2
|
+
import type HAPServiceNodeType from './HAPServiceNodeType';
|
|
3
|
+
import type NodeType from './NodeType';
|
|
4
4
|
type HAPService2NodeType = NodeType & HAPServiceNodeType & {
|
|
5
5
|
config: HAPService2ConfigType;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AdaptiveLightingControllerMode } from '@homebridge/hap-nodejs/dist/lib/controller/AdaptiveLightingController';
|
|
2
|
-
import { NodeDef } from 'node-red';
|
|
3
|
-
import CameraConfigType from './CameraConfigType';
|
|
1
|
+
import type { AdaptiveLightingControllerMode } from '@homebridge/hap-nodejs/dist/lib/controller/AdaptiveLightingController';
|
|
2
|
+
import type { NodeDef } from 'node-red';
|
|
3
|
+
import type CameraConfigType from './CameraConfigType';
|
|
4
4
|
type HAPServiceConfigType = NodeDef & {
|
|
5
5
|
isParent: boolean;
|
|
6
6
|
hostType: number;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Accessory, AdaptiveLightingController, Characteristic, CharacteristicChange, CharacteristicGetCallback, CharacteristicProps, CharacteristicSetCallback, CharacteristicValue, Service } from '@homebridge/hap-nodejs';
|
|
2
|
-
import { CharacteristicContext } from '@homebridge/hap-nodejs/dist/lib/Characteristic';
|
|
3
|
-
import { HAPConnection } from '@homebridge/hap-nodejs/dist/lib/util/eventedhttp';
|
|
4
|
-
import { NodeAPI } from 'node-red';
|
|
5
|
-
import { NodeStatusUtils } from '../utils/NodeStatusUtils';
|
|
6
|
-
import HAPHostNodeType from './HAPHostNodeType';
|
|
7
|
-
import HAPService2NodeType from './HAPService2NodeType';
|
|
8
|
-
import HAPServiceConfigType from './HAPServiceConfigType';
|
|
9
|
-
import NodeType from './NodeType';
|
|
10
|
-
import PublishTimersType from './PublishTimersType';
|
|
1
|
+
import type { Accessory, AdaptiveLightingController, Characteristic, CharacteristicChange, CharacteristicGetCallback, CharacteristicProps, CharacteristicSetCallback, CharacteristicValue, Service } from '@homebridge/hap-nodejs';
|
|
2
|
+
import type { CharacteristicContext } from '@homebridge/hap-nodejs/dist/lib/Characteristic';
|
|
3
|
+
import type { HAPConnection } from '@homebridge/hap-nodejs/dist/lib/util/eventedhttp';
|
|
4
|
+
import type { NodeAPI } from 'node-red';
|
|
5
|
+
import type { NodeStatusUtils } from '../utils/NodeStatusUtils';
|
|
6
|
+
import type HAPHostNodeType from './HAPHostNodeType';
|
|
7
|
+
import type HAPService2NodeType from './HAPService2NodeType';
|
|
8
|
+
import type HAPServiceConfigType from './HAPServiceConfigType';
|
|
9
|
+
import type NodeType from './NodeType';
|
|
10
|
+
import type PublishTimersType from './PublishTimersType';
|
|
11
11
|
type HAPServiceNodeType = NodeType & {
|
|
12
12
|
config: HAPServiceConfigType;
|
|
13
13
|
RED: NodeAPI;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { NodeAPI } from 'node-red';
|
|
2
|
-
import { NodeStatusUtils } from '../utils/NodeStatusUtils';
|
|
3
|
-
import HAPServiceNodeType from './HAPServiceNodeType';
|
|
4
|
-
import HAPStatusConfigType from './HAPStatusConfigType';
|
|
5
|
-
import NodeType from './NodeType';
|
|
1
|
+
import type { NodeAPI } from 'node-red';
|
|
2
|
+
import type { NodeStatusUtils } from '../utils/NodeStatusUtils';
|
|
3
|
+
import type HAPServiceNodeType from './HAPServiceNodeType';
|
|
4
|
+
import type HAPStatusConfigType from './HAPStatusConfigType';
|
|
5
|
+
import type NodeType from './NodeType';
|
|
6
6
|
type HAPStatusNodeType = NodeType & {
|
|
7
7
|
config: HAPStatusConfigType;
|
|
8
8
|
RED: NodeAPI;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SerializedAccessory } from '@homebridge/hap-nodejs';
|
|
1
|
+
import type { SerializedAccessory } from '@homebridge/hap-nodejs';
|
|
2
2
|
type SerializedHostType = {
|
|
3
3
|
_isBridge: boolean;
|
|
4
4
|
} & SerializedAccessory;
|
|
5
|
-
export { SerializedHostType };
|
|
5
|
+
export type { SerializedHostType };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const logger_1 = require("@nrchkb/logger");
|
|
4
|
-
module.exports =
|
|
4
|
+
module.exports = (node) => {
|
|
5
5
|
const HapNodeJS = require('@homebridge/hap-nodejs');
|
|
6
6
|
const Accessory = HapNodeJS.Accessory;
|
|
7
7
|
const Service = HapNodeJS.Service;
|
|
8
8
|
const Characteristic = HapNodeJS.Characteristic;
|
|
9
9
|
const log = (0, logger_1.logger)('NRCHKB', 'AccessoryUtils', node.config.name, node);
|
|
10
|
-
const getOrCreate =
|
|
10
|
+
const getOrCreate = (host, accessoryInformation, subtypeUUID) => {
|
|
11
|
+
var _a, _b, _c;
|
|
11
12
|
let accessory;
|
|
12
13
|
const services = [];
|
|
13
14
|
log.debug(`Looking for accessory with service subtype ${subtypeUUID} ...`);
|
|
@@ -55,16 +56,13 @@ module.exports = function (node) {
|
|
|
55
56
|
(accessory === null || accessory === void 0 ? void 0 : accessory.addService(Service.AccessoryInformation));
|
|
56
57
|
accessoryInformationService === null || accessoryInformationService === void 0 ? void 0 : accessoryInformationService.setCharacteristic(Characteristic.Name, accessoryInformation.name).setCharacteristic(Characteristic.Manufacturer, accessoryInformation.manufacturer).setCharacteristic(Characteristic.SerialNumber, accessoryInformation.serialNo).setCharacteristic(Characteristic.Model, accessoryInformation.model);
|
|
57
58
|
const revisionRegex = /\d+\.\d+\.\d+/;
|
|
58
|
-
if (accessoryInformation.firmwareRev
|
|
59
|
-
accessoryInformation.firmwareRev.match(revisionRegex)) {
|
|
59
|
+
if ((_a = accessoryInformation.firmwareRev) === null || _a === void 0 ? void 0 : _a.match(revisionRegex)) {
|
|
60
60
|
accessoryInformationService === null || accessoryInformationService === void 0 ? void 0 : accessoryInformationService.setCharacteristic(Characteristic.FirmwareRevision, accessoryInformation.firmwareRev);
|
|
61
61
|
}
|
|
62
|
-
if (accessoryInformation.hardwareRev
|
|
63
|
-
accessoryInformation.hardwareRev.match(revisionRegex)) {
|
|
62
|
+
if ((_b = accessoryInformation.hardwareRev) === null || _b === void 0 ? void 0 : _b.match(revisionRegex)) {
|
|
64
63
|
accessoryInformationService === null || accessoryInformationService === void 0 ? void 0 : accessoryInformationService.setCharacteristic(Characteristic.HardwareRevision, accessoryInformation.hardwareRev);
|
|
65
64
|
}
|
|
66
|
-
if (accessoryInformation.softwareRev
|
|
67
|
-
accessoryInformation.softwareRev.match(revisionRegex)) {
|
|
65
|
+
if ((_c = accessoryInformation.softwareRev) === null || _c === void 0 ? void 0 : _c.match(revisionRegex)) {
|
|
68
66
|
accessoryInformationService === null || accessoryInformationService === void 0 ? void 0 : accessoryInformationService.setCharacteristic(Characteristic.SoftwareRevision, accessoryInformation.softwareRev);
|
|
69
67
|
}
|
|
70
68
|
host.addBridgedAccessories([accessory]);
|
|
@@ -78,7 +76,7 @@ module.exports = function (node) {
|
|
|
78
76
|
log.debug(`Bridge now has ${host.bridgedAccessories.length} accessories.`);
|
|
79
77
|
return accessory;
|
|
80
78
|
};
|
|
81
|
-
const onIdentify =
|
|
79
|
+
const onIdentify = (paired, callback) => {
|
|
82
80
|
var _a;
|
|
83
81
|
if (paired) {
|
|
84
82
|
log.debug(`Identify called on paired Accessory ${node.accessory.displayName}`);
|
|
@@ -101,7 +99,7 @@ module.exports = function (node) {
|
|
|
101
99
|
shape: 'dot',
|
|
102
100
|
text: 'Identify : 1'
|
|
103
101
|
});
|
|
104
|
-
setTimeout(
|
|
102
|
+
setTimeout(() => {
|
|
105
103
|
nodes[i].nodeStatusUtils.clearStatus(statusId);
|
|
106
104
|
}, 3000);
|
|
107
105
|
nodes[i].send([msg, msg]);
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const logger_1 = require("@nrchkb/logger");
|
|
7
7
|
const HostType_1 = __importDefault(require("../types/HostType"));
|
|
8
|
-
module.exports =
|
|
9
|
-
const delayedPublish =
|
|
8
|
+
module.exports = () => {
|
|
9
|
+
const delayedPublish = (node) => {
|
|
10
10
|
const log = (0, logger_1.logger)('NRCHKB', 'BridgeUtils', node.config.name, node);
|
|
11
11
|
if (!node.hostNode.published) {
|
|
12
12
|
if (node.publishTimers[node.hostNode.id] !== undefined) {
|
|
@@ -15,7 +15,7 @@ module.exports = function () {
|
|
|
15
15
|
const hostTypeName = node.hostNode.hostType == HostType_1.default.BRIDGE
|
|
16
16
|
? 'Bridge'
|
|
17
17
|
: 'Standalone Accessory';
|
|
18
|
-
node.publishTimers[node.hostNode.id] = setTimeout(
|
|
18
|
+
node.publishTimers[node.hostNode.id] = setTimeout(() => {
|
|
19
19
|
try {
|
|
20
20
|
if (!node.hostNode.published) {
|
|
21
21
|
const published = node.hostNode.publish();
|
|
@@ -32,7 +32,7 @@ module.exports = function () {
|
|
|
32
32
|
node.nodeStatusUtils.setStatus({
|
|
33
33
|
fill: 'red',
|
|
34
34
|
shape: 'ring',
|
|
35
|
-
text:
|
|
35
|
+
text: `Error while publishing ${hostTypeName}`
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}, 5000);
|