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