node-red-contrib-homekit-bridged 2.0.0-dev.0 → 2.0.0-dev.10
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 +185 -148
- package/build/lib/HAPServiceNode.js +200 -177
- package/build/lib/HAPServiceNode2.js +208 -177
- package/build/lib/NRCHKBError.js +23 -2
- package/build/lib/PairingQRCode.js +62 -0
- package/build/lib/Storage.js +152 -90
- package/build/lib/api.js +654 -291
- package/build/lib/camera/CameraControl.js +125 -0
- package/build/lib/camera/CameraDelegate.js +507 -0
- package/build/lib/camera/MP4StreamingServer.js +159 -0
- package/build/lib/hap/HAPCharacteristic.js +25 -4
- package/build/lib/hap/HAPService.js +25 -4
- package/build/lib/hap/eve-app/EveCharacteristics.js +124 -81
- package/build/lib/hap/eve-app/EveServices.js +50 -17
- package/build/lib/hap/hap-nodejs.js +32 -0
- package/build/lib/migration/HomeKitService2Migration.js +34 -0
- package/build/lib/migration/NodeMigration.js +75 -0
- package/build/lib/types/AccessoryInformationType.js +15 -1
- package/build/lib/types/CameraConfigType.js +15 -1
- package/build/lib/types/CustomCharacteristicType.js +15 -1
- package/build/lib/types/HAPHostConfigType.js +15 -1
- package/build/lib/types/HAPHostNodeType.js +15 -1
- package/build/lib/types/HAPService2ConfigType.js +15 -1
- package/build/lib/types/HAPService2NodeType.js +15 -1
- package/build/lib/types/HAPServiceConfigType.js +15 -1
- package/build/lib/types/HAPServiceNodeType.js +15 -1
- package/build/lib/types/HAPStatusConfigType.js +15 -1
- package/build/lib/types/HAPStatusNodeType.js +15 -1
- package/build/lib/types/HostType.js +28 -7
- package/build/lib/types/NodeType.js +15 -1
- package/build/lib/types/PublishTimersType.js +15 -1
- package/build/lib/types/UniFiControllerConfigType.js +16 -0
- package/build/lib/types/hap-nodejs/HapAdaptiveLightingControllerMode.js +28 -7
- package/build/lib/types/hap-nodejs/HapCategories.js +64 -43
- package/build/lib/types/storage/SerializedHostType.js +15 -1
- package/build/lib/types/storage/StorageType.js +34 -10
- package/build/lib/unifi/ProtectDiscovery.js +80 -0
- package/build/lib/utils/AccessoryUtils.js +152 -110
- package/build/lib/utils/BridgeUtils.js +95 -39
- package/build/lib/utils/CharacteristicUtils.js +5 -49
- package/build/lib/utils/CharacteristicUtils2.js +5 -49
- package/build/lib/utils/CharacteristicUtilsBase.js +81 -0
- package/build/lib/utils/NodeStatusUtils.js +89 -40
- package/build/lib/utils/ServiceUtils.js +433 -371
- package/build/lib/utils/ServiceUtils2.js +519 -305
- package/build/lib/utils/index.js +11 -12
- package/build/nodes/bridge.html +206 -168
- package/build/nodes/bridge.js +27 -9
- package/build/nodes/locales/en-US/node-red-contrib-homekit-bridged.json +22 -0
- package/build/nodes/nrchkb.html +1753 -117
- package/build/nodes/nrchkb.js +66 -88
- package/build/nodes/plugin-instance.html +509 -0
- package/build/nodes/plugin-instance.js +46 -0
- package/build/nodes/service.html +557 -306
- package/build/nodes/service.js +5 -6
- package/build/nodes/service2.html +1735 -455
- package/build/nodes/service2.js +5 -8
- package/build/nodes/standalone.html +208 -176
- package/build/nodes/standalone.js +27 -9
- package/build/nodes/status.html +51 -18
- package/build/nodes/status.js +47 -41
- package/build/nodes/unifi-controller.html +92 -0
- package/build/nodes/unifi-controller.js +20 -0
- package/build/plugins/embedded/homebridge-camera-ffmpeg/index.js +479 -0
- package/build/plugins/embedded/homebridge-unifi-protect/index.js +521 -0
- package/build/plugins/embedded/index.js +58 -0
- package/build/plugins/nrchkb-homekit-plugins.js +17 -0
- package/build/plugins/registry/index.js +203 -0
- package/build/plugins/registry/types.js +16 -0
- package/build/scripts/migrate-homekit-service-flows.js +47 -0
- package/examples/demo/01 - ALL Demos single import.json +1885 -2139
- package/examples/demo/02 - Air Purifier.json +12 -61
- package/examples/demo/03 - Air Quality sensor with Battery.json +8 -36
- package/examples/demo/04 - Dimmable Bulb.json +4 -21
- package/examples/demo/05 - Color Bulb (HSV).json +5 -26
- package/examples/demo/06 - Fan (simple, 3 speeds).json +6 -31
- package/examples/demo/07 - Fan (with speed, oscillate, rotation direction).json +4 -21
- package/examples/demo/08 - CO2 detector.json +8 -39
- package/examples/demo/09 - CO (carbon monoxide) example.json +9 -44
- package/examples/demo/10 - Door window contact sensor.json +8 -39
- package/examples/demos (advanced)/01 - Television with inputs and speaker.json +19 -85
- package/examples/switch/01 - Plain Switch.json +179 -199
- package/package.json +48 -34
- package/build/lib/HAPHostNode.d.ts +0 -1
- package/build/lib/HAPServiceNode.d.ts +0 -1
- package/build/lib/HAPServiceNode2.d.ts +0 -1
- package/build/lib/NRCHKBError.d.ts +0 -3
- package/build/lib/Storage.d.ts +0 -30
- package/build/lib/api.d.ts +0 -1
- package/build/lib/hap/HAPCharacteristic.d.ts +0 -9
- package/build/lib/hap/HAPService.d.ts +0 -6
- package/build/lib/hap/eve-app/EveCharacteristics.d.ts +0 -20
- package/build/lib/hap/eve-app/EveServices.d.ts +0 -5
- package/build/lib/types/AccessoryInformationType.d.ts +0 -11
- package/build/lib/types/CameraConfigType.d.ts +0 -24
- package/build/lib/types/CustomCharacteristicType.d.ts +0 -6
- package/build/lib/types/HAPHostConfigType.d.ts +0 -22
- package/build/lib/types/HAPHostNodeType.d.ts +0 -14
- package/build/lib/types/HAPService2ConfigType.d.ts +0 -6
- package/build/lib/types/HAPService2NodeType.d.ts +0 -7
- package/build/lib/types/HAPServiceConfigType.d.ts +0 -26
- package/build/lib/types/HAPServiceNodeType.d.ts +0 -38
- package/build/lib/types/HAPStatusConfigType.d.ts +0 -5
- package/build/lib/types/HAPStatusNodeType.d.ts +0 -12
- package/build/lib/types/HostType.d.ts +0 -5
- package/build/lib/types/NodeType.d.ts +0 -3
- package/build/lib/types/PublishTimersType.d.ts +0 -4
- package/build/lib/types/hap-nodejs/HapAdaptiveLightingControllerMode.d.ts +0 -5
- package/build/lib/types/hap-nodejs/HapCategories.d.ts +0 -41
- package/build/lib/types/storage/SerializedHostType.d.ts +0 -5
- package/build/lib/types/storage/StorageType.d.ts +0 -8
- package/build/lib/utils/AccessoryUtils.d.ts +0 -1
- package/build/lib/utils/BridgeUtils.d.ts +0 -1
- package/build/lib/utils/CharacteristicUtils.d.ts +0 -1
- package/build/lib/utils/CharacteristicUtils2.d.ts +0 -1
- package/build/lib/utils/NodeStatusUtils.d.ts +0 -17
- package/build/lib/utils/ServiceUtils.d.ts +0 -1
- package/build/lib/utils/ServiceUtils2.d.ts +0 -1
- package/build/lib/utils/index.d.ts +0 -1
- package/build/nodes/bridge.d.ts +0 -1
- package/build/nodes/nrchkb.d.ts +0 -1
- package/build/nodes/service.d.ts +0 -1
- package/build/nodes/service2.d.ts +0 -1
- package/build/nodes/standalone.d.ts +0 -1
- package/build/nodes/status.d.ts +0 -1
|
@@ -1,182 +1,213 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
4
15
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var import_hap_nodejs = require("@homebridge/hap-nodejs");
|
|
25
|
+
var import_logger = require("@nrchkb/logger");
|
|
26
|
+
var import_NRCHKBError = __toESM(require("./NRCHKBError"));
|
|
27
|
+
var import_HostType = __toESM(require("./types/HostType"));
|
|
28
|
+
var import_NodeStatusUtils = require("./utils/NodeStatusUtils");
|
|
11
29
|
module.exports = (RED) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
resolve(self.config);
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
.then((newConfig) => {
|
|
52
|
-
init.call(self, newConfig);
|
|
53
|
-
})
|
|
54
|
-
.catch((error) => {
|
|
55
|
-
log.error(`Error while starting Service due to ${error}`);
|
|
30
|
+
const nrchkbConfigCompatibilityOverride = function() {
|
|
31
|
+
const log = (0, import_logger.logger)("NRCHKB", "HAPServiceNode2", this.config.name, this);
|
|
32
|
+
if (this.config.isParent === void 0) {
|
|
33
|
+
log.trace(
|
|
34
|
+
`nrchkbConfigCompatibilityOverride => self.config.isParent=${this.config.isParent} value changed to true`
|
|
35
|
+
);
|
|
36
|
+
this.config.isParent = true;
|
|
37
|
+
}
|
|
38
|
+
if (this.config.hostType === void 0) {
|
|
39
|
+
log.trace(
|
|
40
|
+
`nrchkbConfigCompatibilityOverride => self.config.hostType=${this.config.hostType} value changed to HostType.BRIDGE`
|
|
41
|
+
);
|
|
42
|
+
this.config.hostType = import_HostType.default.BRIDGE;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const preInit = function(config) {
|
|
46
|
+
this.nodeStatusUtils = new import_NodeStatusUtils.NodeStatusUtils(this);
|
|
47
|
+
this.config = config;
|
|
48
|
+
this.name = this.config.name;
|
|
49
|
+
this.nrchkbClosing = false;
|
|
50
|
+
const log = (0, import_logger.logger)("NRCHKB", "HAPServiceNode2", this.config.name, this);
|
|
51
|
+
this.RED = RED;
|
|
52
|
+
this.publishTimers = {};
|
|
53
|
+
nrchkbConfigCompatibilityOverride.call(this);
|
|
54
|
+
RED.nodes.createNode(this, this.config);
|
|
55
|
+
const ServiceUtils = require("./utils/ServiceUtils2")(this);
|
|
56
|
+
new Promise((resolve) => {
|
|
57
|
+
if (this.config.waitForSetupMsg) {
|
|
58
|
+
log.debug(
|
|
59
|
+
'Waiting for Setup message. It should be of format {"payload":{"nrchkb":{"setup":{}}}}'
|
|
60
|
+
);
|
|
61
|
+
this.setupDone = false;
|
|
62
|
+
this.nodeStatusUtils.setStatus({
|
|
63
|
+
fill: "blue",
|
|
64
|
+
shape: "dot",
|
|
65
|
+
text: "Waiting for Setup"
|
|
56
66
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
67
|
+
this.handleWaitForSetup = (msg) => ServiceUtils.handleWaitForSetup(this.config, msg, resolve);
|
|
68
|
+
this.on("input", this.handleWaitForSetup);
|
|
69
|
+
} else {
|
|
70
|
+
resolve(this.config);
|
|
71
|
+
}
|
|
72
|
+
}).then((newConfig) => {
|
|
73
|
+
init.call(this, newConfig);
|
|
74
|
+
}).catch((error) => {
|
|
75
|
+
log.error(`Error while starting Service due to ${error}`);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const init = function(config) {
|
|
79
|
+
this.config = config;
|
|
80
|
+
const log = (0, import_logger.logger)("NRCHKB", "HAPServiceNode2", this.config.name, this);
|
|
81
|
+
const ServiceUtils = require("./utils/ServiceUtils2")(this);
|
|
82
|
+
if (this.config.isParent) {
|
|
83
|
+
log.debug("Starting Parent Service");
|
|
84
|
+
configure.call(this).then(() => {
|
|
85
|
+
this.configured = true;
|
|
86
|
+
this.reachable = true;
|
|
87
|
+
}).catch((error) => {
|
|
88
|
+
log.error(
|
|
89
|
+
`Error while starting Parent Service due to ${error}`
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
const serviceType = config.serviceName === "Camera" ? "Camera" : "Linked";
|
|
94
|
+
ServiceUtils.waitForParent().then(async () => {
|
|
95
|
+
log.debug(`Starting ${serviceType} Service`);
|
|
96
|
+
await configure.call(this);
|
|
97
|
+
this.configured = true;
|
|
98
|
+
}).catch((error) => {
|
|
99
|
+
log.error(
|
|
100
|
+
`Error while starting ${serviceType} Service due to ${error}`
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const configure = async function() {
|
|
106
|
+
const log = (0, import_logger.logger)("NRCHKB", "HAPServiceNode2", this.config.name, this);
|
|
107
|
+
const Utils = require("./utils")(this);
|
|
108
|
+
const AccessoryUtils = Utils.AccessoryUtils;
|
|
109
|
+
const BridgeUtils = Utils.BridgeUtils;
|
|
110
|
+
const CharacteristicUtils = require("./utils/CharacteristicUtils2")(
|
|
111
|
+
this
|
|
112
|
+
);
|
|
113
|
+
const ServiceUtils = require("./utils/ServiceUtils2")(this);
|
|
114
|
+
let parentNode;
|
|
115
|
+
if (this.config.isParent) {
|
|
116
|
+
const hostId = this.config.hostType == import_HostType.default.BRIDGE ? this.config.bridge : this.config.accessoryId;
|
|
117
|
+
this.hostNode = RED.nodes.getNode(hostId);
|
|
118
|
+
if (!this.hostNode) {
|
|
119
|
+
const message = `Host node ${this.config.hostType == import_HostType.default.BRIDGE ? "Bridge" : "Standalone Accessory"} ${hostId} not found`;
|
|
120
|
+
log.error(message, false);
|
|
121
|
+
throw new import_NRCHKBError.default(message);
|
|
122
|
+
}
|
|
123
|
+
this.childNodes = [];
|
|
124
|
+
this.childNodes.push(this);
|
|
125
|
+
} else {
|
|
126
|
+
parentNode = RED.nodes.getNode(
|
|
127
|
+
this.config.parentService
|
|
128
|
+
);
|
|
129
|
+
if (!parentNode) {
|
|
130
|
+
log.error("Parent Node not assigned", false);
|
|
131
|
+
throw new import_NRCHKBError.default("Parent Node not assigned");
|
|
132
|
+
}
|
|
133
|
+
this.parentNode = parentNode;
|
|
134
|
+
this.parentService = this.parentNode.service;
|
|
135
|
+
if (!this.parentService) {
|
|
136
|
+
log.error("Parent Service not assigned", false);
|
|
137
|
+
throw new import_NRCHKBError.default("Parent Service not assigned");
|
|
138
|
+
}
|
|
139
|
+
this.hostNode = this.parentNode.hostNode;
|
|
140
|
+
this.parentNode.childNodes?.push(this);
|
|
141
|
+
this.accessory = this.parentNode.accessory;
|
|
142
|
+
}
|
|
143
|
+
this.name = this.config.name;
|
|
144
|
+
if (Object.hasOwn(this, "_flow") && Object.hasOwn(this, "_alias") && (this._flow ? Object(this._flow).hasOwn("TYPE") : false) && this._flow?.TYPE === "subflow") {
|
|
145
|
+
this.uniqueIdentifier = `${this._alias}/${this._flow.path}`;
|
|
146
|
+
} else {
|
|
147
|
+
this.uniqueIdentifier = this.id;
|
|
148
|
+
}
|
|
149
|
+
const subtypeUUID = import_hap_nodejs.uuid.generate(this.uniqueIdentifier);
|
|
150
|
+
if (this.config.hostType == import_HostType.default.BRIDGE) {
|
|
151
|
+
if (this.config.isParent) {
|
|
152
|
+
const accessoryUUID = import_hap_nodejs.uuid.generate(
|
|
153
|
+
"A" + this.uniqueIdentifier + this.name + this.config.manufacturer + this.config.serialNo + this.config.model
|
|
154
|
+
);
|
|
155
|
+
this.accessory = AccessoryUtils.getOrCreate(
|
|
156
|
+
this.hostNode.host,
|
|
157
|
+
{
|
|
158
|
+
name: this.name,
|
|
159
|
+
UUID: accessoryUUID,
|
|
160
|
+
manufacturer: this.config.manufacturer,
|
|
161
|
+
serialNo: this.config.serialNo,
|
|
162
|
+
model: this.config.model,
|
|
163
|
+
firmwareRev: this.config.firmwareRev,
|
|
164
|
+
hardwareRev: this.config.hardwareRev,
|
|
165
|
+
softwareRev: this.config.softwareRev
|
|
166
|
+
},
|
|
167
|
+
subtypeUUID
|
|
168
|
+
// subtype of the primary service for identification
|
|
169
|
+
);
|
|
170
|
+
this.onIdentify = AccessoryUtils.onIdentify;
|
|
171
|
+
this.accessory.on("identify", this.onIdentify);
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
log.debug("Binding Service accessory as Standalone Accessory");
|
|
175
|
+
this.accessory = this.hostNode.host;
|
|
176
|
+
}
|
|
177
|
+
this.service = await ServiceUtils.getOrCreate(
|
|
178
|
+
this.accessory,
|
|
179
|
+
{
|
|
180
|
+
name: this.name,
|
|
181
|
+
UUID: subtypeUUID,
|
|
182
|
+
serviceName: this.config.serviceName,
|
|
183
|
+
config: this.config
|
|
184
|
+
},
|
|
185
|
+
this.parentService
|
|
186
|
+
);
|
|
187
|
+
if (this.nrchkbClosing) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.characteristicProperties = CharacteristicUtils.load(
|
|
191
|
+
this.service,
|
|
192
|
+
this.config
|
|
193
|
+
);
|
|
194
|
+
ServiceUtils.configureAdaptiveLightning();
|
|
195
|
+
if (this.config.isParent) {
|
|
196
|
+
BridgeUtils.delayedPublish(this);
|
|
197
|
+
}
|
|
198
|
+
this.nodeStatusUtils.setStatus({
|
|
199
|
+
fill: "yellow",
|
|
200
|
+
shape: "ring",
|
|
201
|
+
text: this.hostNode.config.pinCode
|
|
202
|
+
});
|
|
203
|
+
this.supported = CharacteristicUtils.subscribeAndGetSupported(
|
|
204
|
+
this.service
|
|
205
|
+
);
|
|
206
|
+
this.on("input", ServiceUtils.onInput);
|
|
207
|
+
this.on("close", ServiceUtils.onClose);
|
|
208
|
+
};
|
|
209
|
+
return {
|
|
210
|
+
preInit,
|
|
211
|
+
init
|
|
212
|
+
};
|
|
182
213
|
};
|
package/build/lib/NRCHKBError.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var NRCHKBError_exports = {};
|
|
20
|
+
__export(NRCHKBError_exports, {
|
|
21
|
+
default: () => NRCHKBError_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(NRCHKBError_exports);
|
|
3
24
|
class NRCHKBError extends Error {
|
|
4
25
|
}
|
|
5
|
-
|
|
26
|
+
var NRCHKBError_default = NRCHKBError;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var PairingQRCode_exports = {};
|
|
30
|
+
__export(PairingQRCode_exports, {
|
|
31
|
+
createPairingQRCodeDataURL: () => createPairingQRCodeDataURL,
|
|
32
|
+
formatPinCodeForPairing: () => formatPinCodeForPairing
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(PairingQRCode_exports);
|
|
35
|
+
var import_qrcode = require("homekit-code/lib/commands/qrcode/qrcode.utils");
|
|
36
|
+
var import_NRCHKBError = __toESM(require("./NRCHKBError"));
|
|
37
|
+
const pinCodeRegex = /^(?:\d{3}-\d{2}-\d{3}|\d{4}-\d{4})$/;
|
|
38
|
+
const formatPinCodeForPairing = (pinCode) => {
|
|
39
|
+
if (!pinCode) {
|
|
40
|
+
throw new import_NRCHKBError.default("Pin code cannot be empty");
|
|
41
|
+
}
|
|
42
|
+
if (!pinCodeRegex.test(pinCode)) {
|
|
43
|
+
throw new import_NRCHKBError.default(`Invalid HomeKit pin code format: ${pinCode}`);
|
|
44
|
+
}
|
|
45
|
+
const cleanPinCode = pinCode.replace(/\D/g, "");
|
|
46
|
+
return {
|
|
47
|
+
bottom: cleanPinCode.slice(4),
|
|
48
|
+
top: cleanPinCode.slice(0, 4)
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const createPairingQRCodeDataURL = async (setupUri, pinCode) => {
|
|
52
|
+
const svg = await (0, import_qrcode.composeQrCode)({
|
|
53
|
+
pairingCode: pinCode.replace(/\D/g, ""),
|
|
54
|
+
setupUri
|
|
55
|
+
});
|
|
56
|
+
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
57
|
+
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
createPairingQRCodeDataURL,
|
|
61
|
+
formatPinCodeForPairing
|
|
62
|
+
});
|