node-red-contrib-homekit-bridged 2.0.0-dev.5 → 2.0.0-dev.8
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 +183 -141
- package/build/lib/HAPServiceNode.js +199 -172
- package/build/lib/HAPServiceNode2.js +207 -172
- 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 -288
- package/build/lib/camera/CameraControl.js +119 -84
- package/build/lib/camera/CameraDelegate.js +481 -404
- package/build/lib/camera/MP4StreamingServer.js +148 -139
- 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 +82 -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 -375
- package/build/lib/utils/ServiceUtils2.js +519 -309
- package/build/lib/utils/index.js +10 -11
- 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 +544 -307
- package/build/nodes/service.js +5 -6
- package/build/nodes/service2.html +1721 -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 -40
- 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 -1885
- package/examples/demo/02 - Air Purifier.json +279 -279
- package/examples/demo/03 - Air Quality sensor with Battery.json +254 -254
- package/examples/demo/04 - Dimmable Bulb.json +172 -172
- package/examples/demo/05 - Color Bulb (HSV).json +195 -195
- package/examples/demo/06 - Fan (simple, 3 speeds).json +240 -240
- package/examples/demo/07 - Fan (with speed, oscillate, rotation direction).json +175 -175
- package/examples/demo/08 - CO2 detector.json +224 -224
- package/examples/demo/09 - CO (carbon monoxide) example.json +255 -255
- package/examples/demo/10 - Door window contact sensor.json +234 -234
- package/examples/demos (advanced)/01 - Television with inputs and speaker.json +541 -541
- package/examples/switch/01 - Plain Switch.json +178 -178
- package/package.json +95 -84
- 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/camera/CameraControl.d.ts +0 -3
- package/build/lib/camera/CameraDelegate.d.ts +0 -38
- package/build/lib/camera/MP4StreamingServer.d.ts +0 -26
- 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,44 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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 HapCategories_exports = {};
|
|
20
|
+
__export(HapCategories_exports, {
|
|
21
|
+
default: () => HapCategories_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(HapCategories_exports);
|
|
24
|
+
var HapCategories = /* @__PURE__ */ ((HapCategories2) => {
|
|
25
|
+
HapCategories2[HapCategories2["OTHER"] = 1] = "OTHER";
|
|
26
|
+
HapCategories2[HapCategories2["BRIDGE"] = 2] = "BRIDGE";
|
|
27
|
+
HapCategories2[HapCategories2["FAN"] = 3] = "FAN";
|
|
28
|
+
HapCategories2[HapCategories2["GARAGE_DOOR_OPENER"] = 4] = "GARAGE_DOOR_OPENER";
|
|
29
|
+
HapCategories2[HapCategories2["LIGHTBULB"] = 5] = "LIGHTBULB";
|
|
30
|
+
HapCategories2[HapCategories2["DOOR_LOCK"] = 6] = "DOOR_LOCK";
|
|
31
|
+
HapCategories2[HapCategories2["OUTLET"] = 7] = "OUTLET";
|
|
32
|
+
HapCategories2[HapCategories2["SWITCH"] = 8] = "SWITCH";
|
|
33
|
+
HapCategories2[HapCategories2["THERMOSTAT"] = 9] = "THERMOSTAT";
|
|
34
|
+
HapCategories2[HapCategories2["SENSOR"] = 10] = "SENSOR";
|
|
35
|
+
HapCategories2[HapCategories2["ALARM_SYSTEM"] = 11] = "ALARM_SYSTEM";
|
|
36
|
+
HapCategories2[HapCategories2["SECURITY_SYSTEM"] = 11] = "SECURITY_SYSTEM";
|
|
37
|
+
HapCategories2[HapCategories2["DOOR"] = 12] = "DOOR";
|
|
38
|
+
HapCategories2[HapCategories2["WINDOW"] = 13] = "WINDOW";
|
|
39
|
+
HapCategories2[HapCategories2["WINDOW_COVERING"] = 14] = "WINDOW_COVERING";
|
|
40
|
+
HapCategories2[HapCategories2["PROGRAMMABLE_SWITCH"] = 15] = "PROGRAMMABLE_SWITCH";
|
|
41
|
+
HapCategories2[HapCategories2["RANGE_EXTENDER"] = 16] = "RANGE_EXTENDER";
|
|
42
|
+
HapCategories2[HapCategories2["CAMERA"] = 17] = "CAMERA";
|
|
43
|
+
HapCategories2[HapCategories2["IP_CAMERA"] = 17] = "IP_CAMERA";
|
|
44
|
+
HapCategories2[HapCategories2["VIDEO_DOORBELL"] = 18] = "VIDEO_DOORBELL";
|
|
45
|
+
HapCategories2[HapCategories2["AIR_PURIFIER"] = 19] = "AIR_PURIFIER";
|
|
46
|
+
HapCategories2[HapCategories2["AIR_HEATER"] = 20] = "AIR_HEATER";
|
|
47
|
+
HapCategories2[HapCategories2["AIR_CONDITIONER"] = 21] = "AIR_CONDITIONER";
|
|
48
|
+
HapCategories2[HapCategories2["AIR_HUMIDIFIER"] = 22] = "AIR_HUMIDIFIER";
|
|
49
|
+
HapCategories2[HapCategories2["AIR_DEHUMIDIFIER"] = 23] = "AIR_DEHUMIDIFIER";
|
|
50
|
+
HapCategories2[HapCategories2["APPLE_TV"] = 24] = "APPLE_TV";
|
|
51
|
+
HapCategories2[HapCategories2["HOMEPOD"] = 25] = "HOMEPOD";
|
|
52
|
+
HapCategories2[HapCategories2["SPEAKER"] = 26] = "SPEAKER";
|
|
53
|
+
HapCategories2[HapCategories2["AIRPORT"] = 27] = "AIRPORT";
|
|
54
|
+
HapCategories2[HapCategories2["SPRINKLER"] = 28] = "SPRINKLER";
|
|
55
|
+
HapCategories2[HapCategories2["FAUCET"] = 29] = "FAUCET";
|
|
56
|
+
HapCategories2[HapCategories2["SHOWER_HEAD"] = 30] = "SHOWER_HEAD";
|
|
57
|
+
HapCategories2[HapCategories2["TELEVISION"] = 31] = "TELEVISION";
|
|
58
|
+
HapCategories2[HapCategories2["TARGET_CONTROLLER"] = 32] = "TARGET_CONTROLLER";
|
|
59
|
+
HapCategories2[HapCategories2["ROUTER"] = 33] = "ROUTER";
|
|
60
|
+
HapCategories2[HapCategories2["AUDIO_RECEIVER"] = 34] = "AUDIO_RECEIVER";
|
|
61
|
+
HapCategories2[HapCategories2["TV_SET_TOP_BOX"] = 35] = "TV_SET_TOP_BOX";
|
|
62
|
+
HapCategories2[HapCategories2["TV_STREAMING_STICK"] = 36] = "TV_STREAMING_STICK";
|
|
63
|
+
return HapCategories2;
|
|
64
|
+
})(HapCategories || {});
|
|
65
|
+
var HapCategories_default = HapCategories;
|
|
@@ -1,2 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var SerializedHostType_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(SerializedHostType_exports);
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 StorageType_exports = {};
|
|
20
|
+
__export(StorageType_exports, {
|
|
21
|
+
StorageType: () => StorageType
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(StorageType_exports);
|
|
24
|
+
var StorageType = /* @__PURE__ */ ((StorageType2) => {
|
|
25
|
+
StorageType2["SERVICE"] = "service";
|
|
26
|
+
StorageType2["ACCESSORY"] = "accessory";
|
|
27
|
+
StorageType2["HOST"] = "host";
|
|
28
|
+
StorageType2["CUSTOM_CHARACTERISTICS"] = "customCharacteristics";
|
|
29
|
+
StorageType2["OTHER"] = "other";
|
|
30
|
+
return StorageType2;
|
|
31
|
+
})(StorageType || {});
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
StorageType
|
|
35
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
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 ProtectDiscovery_exports = {};
|
|
20
|
+
__export(ProtectDiscovery_exports, {
|
|
21
|
+
assertProtectControllerConfig: () => assertProtectControllerConfig,
|
|
22
|
+
discoverProtectCameras: () => discoverProtectCameras
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ProtectDiscovery_exports);
|
|
25
|
+
var import_logger = require("@nrchkb/logger");
|
|
26
|
+
const importEsm = (specifier) => {
|
|
27
|
+
const importer = new Function("specifier", "return import(specifier)");
|
|
28
|
+
return importer(specifier);
|
|
29
|
+
};
|
|
30
|
+
const createDiscoveryLogger = () => {
|
|
31
|
+
const log = (0, import_logger.logger)("NRCHKB", "UniFiProtectDiscovery");
|
|
32
|
+
return {
|
|
33
|
+
debug: (message) => log.debug(message),
|
|
34
|
+
error: (message) => log.error(message),
|
|
35
|
+
info: (message) => log.debug(message),
|
|
36
|
+
warn: (message) => log.debug(message)
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const assertProtectControllerConfig = (config, credentials) => {
|
|
40
|
+
if ((config.application ?? "protect") !== "protect") {
|
|
41
|
+
throw new Error("Only UniFi Protect controllers are supported.");
|
|
42
|
+
}
|
|
43
|
+
if (!config.address?.trim()) {
|
|
44
|
+
throw new Error("UniFi controller address is required.");
|
|
45
|
+
}
|
|
46
|
+
if (!credentials.username?.trim() || !credentials.password) {
|
|
47
|
+
throw new Error("UniFi controller username and password are required.");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const discoverProtectCameras = async (config, credentials) => {
|
|
51
|
+
assertProtectControllerConfig(config, credentials);
|
|
52
|
+
const module2 = await importEsm("unifi-protect");
|
|
53
|
+
const client = new module2.ProtectApi(createDiscoveryLogger());
|
|
54
|
+
try {
|
|
55
|
+
const loggedIn = await client.login(
|
|
56
|
+
config.address,
|
|
57
|
+
credentials.username,
|
|
58
|
+
credentials.password
|
|
59
|
+
);
|
|
60
|
+
if (!loggedIn) {
|
|
61
|
+
throw new Error("Unable to log in to UniFi Protect.");
|
|
62
|
+
}
|
|
63
|
+
const bootstrapped = await client.getBootstrap();
|
|
64
|
+
if (!bootstrapped) {
|
|
65
|
+
throw new Error("Unable to retrieve UniFi Protect bootstrap data.");
|
|
66
|
+
}
|
|
67
|
+
return (client.bootstrap?.cameras ?? []).filter((camera) => camera.id && camera.mac).sort(
|
|
68
|
+
(a, b) => (a.name ?? a.marketName ?? a.mac).localeCompare(
|
|
69
|
+
b.name ?? b.marketName ?? b.mac
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
} finally {
|
|
73
|
+
client.logout();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
assertProtectControllerConfig,
|
|
79
|
+
discoverProtectCameras
|
|
80
|
+
});
|
|
@@ -1,113 +1,155 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
var import_hap_nodejs = require("@homebridge/hap-nodejs");
|
|
3
|
+
var import_logger = require("@nrchkb/logger");
|
|
4
|
+
const accessoryCache = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
const buildAccessoryUtils = (node) => {
|
|
6
|
+
const { Service, Characteristic } = require("@homebridge/hap-nodejs");
|
|
7
|
+
const log = (0, import_logger.logger)("NRCHKB", "AccessoryUtils", node.config.name, node);
|
|
8
|
+
const getOrCreate = (host, accessoryInformation, subtypeUUID) => {
|
|
9
|
+
let accessory;
|
|
10
|
+
const services = [];
|
|
11
|
+
let hostCache = accessoryCache.get(host);
|
|
12
|
+
if (!hostCache) {
|
|
13
|
+
hostCache = /* @__PURE__ */ new Map();
|
|
14
|
+
accessoryCache.set(host, hostCache);
|
|
15
|
+
}
|
|
16
|
+
log.debug(
|
|
17
|
+
`Looking for accessory with service subtype ${subtypeUUID} ...`
|
|
18
|
+
);
|
|
19
|
+
if (hostCache.has(subtypeUUID)) {
|
|
20
|
+
accessory = hostCache.get(subtypeUUID);
|
|
21
|
+
log.trace(`Found accessory in cache for subtype ${subtypeUUID}`);
|
|
22
|
+
} else {
|
|
23
|
+
accessory = host.bridgedAccessories.find((a) => {
|
|
24
|
+
const service = a.services.find((s) => {
|
|
25
|
+
return s.subtype === subtypeUUID;
|
|
20
26
|
});
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
27
|
+
return service !== void 0;
|
|
28
|
+
});
|
|
29
|
+
if (accessory) {
|
|
30
|
+
hostCache.set(subtypeUUID, accessory);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (accessory) {
|
|
34
|
+
const accessoryInformationService2 = accessory.getService(Service.AccessoryInformation) || accessory.addService(Service.AccessoryInformation);
|
|
35
|
+
if (accessoryInformationService2.getCharacteristic(
|
|
36
|
+
Characteristic.Manufacturer
|
|
37
|
+
).value !== accessoryInformation.manufacturer || accessoryInformationService2.getCharacteristic(
|
|
38
|
+
Characteristic.Model
|
|
39
|
+
).value !== accessoryInformation.model || accessoryInformationService2.getCharacteristic(
|
|
40
|
+
Characteristic.Name
|
|
41
|
+
).value !== accessoryInformation.name || accessoryInformationService2.getCharacteristic(
|
|
42
|
+
Characteristic.SerialNumber
|
|
43
|
+
).value !== accessoryInformation.serialNo) {
|
|
44
|
+
log.debug(
|
|
45
|
+
"... Manufacturer, Model, Name or Serial Number changed! Replacing it."
|
|
46
|
+
);
|
|
47
|
+
accessory.services.filter(
|
|
48
|
+
(service) => service.UUID !== Service.AccessoryInformation.UUID
|
|
49
|
+
).forEach((service) => {
|
|
50
|
+
accessory?.removeService(service);
|
|
51
|
+
services.push(service);
|
|
52
|
+
});
|
|
53
|
+
host.removeBridgedAccessories([accessory]);
|
|
54
|
+
accessory.destroy();
|
|
55
|
+
hostCache.delete(subtypeUUID);
|
|
56
|
+
accessory = void 0;
|
|
57
|
+
} else {
|
|
58
|
+
log.debug("... found it! Updating it.");
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
log.debug(
|
|
62
|
+
`... didn't find it. Adding new accessory with name ${accessoryInformation.name} and UUID ${accessoryInformation.UUID}`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
let accessoryInformationService;
|
|
66
|
+
if (!accessory) {
|
|
67
|
+
accessory = new import_hap_nodejs.Accessory(
|
|
68
|
+
accessoryInformation.name,
|
|
69
|
+
accessoryInformation.UUID
|
|
70
|
+
);
|
|
71
|
+
services.forEach((service) => {
|
|
72
|
+
accessory?.addService(service);
|
|
73
|
+
});
|
|
74
|
+
accessoryInformationService = accessory?.getService(Service.AccessoryInformation) || accessory?.addService(Service.AccessoryInformation);
|
|
75
|
+
accessoryInformationService?.setCharacteristic(
|
|
76
|
+
Characteristic.Name,
|
|
77
|
+
accessoryInformation.name
|
|
78
|
+
).setCharacteristic(
|
|
79
|
+
Characteristic.Manufacturer,
|
|
80
|
+
accessoryInformation.manufacturer
|
|
81
|
+
).setCharacteristic(
|
|
82
|
+
Characteristic.SerialNumber,
|
|
83
|
+
accessoryInformation.serialNo
|
|
84
|
+
).setCharacteristic(
|
|
85
|
+
Characteristic.Model,
|
|
86
|
+
accessoryInformation.model
|
|
87
|
+
);
|
|
88
|
+
const revisionRegex = /\d+\.\d+\.\d+/;
|
|
89
|
+
if (accessoryInformation.firmwareRev?.match(revisionRegex)) {
|
|
90
|
+
accessoryInformationService?.setCharacteristic(
|
|
91
|
+
Characteristic.FirmwareRevision,
|
|
92
|
+
accessoryInformation.firmwareRev
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
if (accessoryInformation.hardwareRev?.match(revisionRegex)) {
|
|
96
|
+
accessoryInformationService?.setCharacteristic(
|
|
97
|
+
Characteristic.HardwareRevision,
|
|
98
|
+
accessoryInformation.hardwareRev
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if (accessoryInformation.softwareRev?.match(revisionRegex)) {
|
|
102
|
+
accessoryInformationService?.setCharacteristic(
|
|
103
|
+
Characteristic.SoftwareRevision,
|
|
104
|
+
accessoryInformation.softwareRev
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
host.addBridgedAccessories([accessory]);
|
|
108
|
+
} else {
|
|
109
|
+
accessoryInformationService = accessory?.getService(Service.AccessoryInformation) || accessory?.addService(Service.AccessoryInformation);
|
|
110
|
+
}
|
|
111
|
+
accessoryInformationService?.setCharacteristic(
|
|
112
|
+
Characteristic.Identify,
|
|
113
|
+
true
|
|
114
|
+
);
|
|
115
|
+
log.debug(
|
|
116
|
+
`Bridge now has ${host.bridgedAccessories.length} accessories.`
|
|
117
|
+
);
|
|
118
|
+
return accessory;
|
|
119
|
+
};
|
|
120
|
+
const onIdentify = (paired, callback) => {
|
|
121
|
+
if (paired) {
|
|
122
|
+
log.debug(
|
|
123
|
+
`Identify called on paired Accessory ${node.accessory.displayName}`
|
|
124
|
+
);
|
|
125
|
+
} else {
|
|
126
|
+
log.debug(
|
|
127
|
+
`Identify called on unpaired Accessory ${node.accessory.displayName}`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
const nodes = node.childNodes ?? [];
|
|
131
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
132
|
+
const topic = nodes[i].config.topic ? nodes[i].config.topic : nodes[i].topic_in;
|
|
133
|
+
const msg = {
|
|
134
|
+
payload: { Identify: 1 },
|
|
135
|
+
name: nodes[i].name,
|
|
136
|
+
topic
|
|
137
|
+
};
|
|
138
|
+
const statusId = nodes[i].nodeStatusUtils.setStatus({
|
|
139
|
+
fill: "yellow",
|
|
140
|
+
shape: "dot",
|
|
141
|
+
text: "Identify : 1"
|
|
142
|
+
});
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
nodes[i].nodeStatusUtils.clearStatus(statusId);
|
|
145
|
+
}, 3e3);
|
|
146
|
+
nodes[i].send([msg, msg]);
|
|
147
|
+
}
|
|
148
|
+
callback();
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
getOrCreate,
|
|
152
|
+
onIdentify
|
|
153
|
+
};
|
|
113
154
|
};
|
|
155
|
+
module.exports = buildAccessoryUtils;
|