node-red-contrib-homekit-bridged 2.0.0-dev.1 → 2.0.0-dev.2
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 +24 -20
- 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
package/build/lib/HAPHostNode.js
CHANGED
|
@@ -17,17 +17,16 @@ const logger_1 = require("@nrchkb/logger");
|
|
|
17
17
|
const semver_1 = require("semver");
|
|
18
18
|
const preload_1 = __importDefault(require("semver/preload"));
|
|
19
19
|
const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
|
|
20
|
-
const HapCategories_1 = __importDefault(require("./types/hap-nodejs/HapCategories"));
|
|
21
20
|
const HostType_1 = __importDefault(require("./types/HostType"));
|
|
21
|
+
const HapCategories_1 = __importDefault(require("./types/hap-nodejs/HapCategories"));
|
|
22
22
|
module.exports = (RED, hostType) => {
|
|
23
23
|
const init = function (config) {
|
|
24
24
|
var _a, _b, _c;
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
self.name = config.bridgeName;
|
|
25
|
+
const log = (0, logger_1.logger)('NRCHKB', 'HAPHostNode', config.bridgeName, this);
|
|
26
|
+
this.hostType = hostType;
|
|
27
|
+
RED.nodes.createNode(this, config);
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.name = config.bridgeName;
|
|
31
30
|
if (!hostNameValidator(config.bridgeName)) {
|
|
32
31
|
log.error('Host name is incorrect', false);
|
|
33
32
|
return new NRCHKBError_1.default('Host name is incorrect');
|
|
@@ -35,79 +34,79 @@ module.exports = (RED, hostType) => {
|
|
|
35
34
|
if (preload_1.default.parse(config.firmwareRev) == null) {
|
|
36
35
|
config.firmwareRev = new semver_1.SemVer('0.0.0');
|
|
37
36
|
}
|
|
38
|
-
|
|
37
|
+
this.accessoryCategory = (this.hostType == HostType_1.default.BRIDGE
|
|
39
38
|
? HapCategories_1.default.BRIDGE
|
|
40
|
-
:
|
|
41
|
-
|
|
39
|
+
: this.config.accessoryCategory);
|
|
40
|
+
this.published = false;
|
|
42
41
|
try {
|
|
43
|
-
|
|
42
|
+
this.bridgeUsername = macify(this.id);
|
|
44
43
|
}
|
|
45
44
|
catch (error) {
|
|
46
45
|
log.error(error);
|
|
47
46
|
return error;
|
|
48
47
|
}
|
|
49
|
-
const hostUUID = hap_nodejs_1.uuid.generate(
|
|
50
|
-
const hostTypeName =
|
|
48
|
+
const hostUUID = hap_nodejs_1.uuid.generate(this.id);
|
|
49
|
+
const hostTypeName = this.hostType == HostType_1.default.BRIDGE ? 'Bridge' : 'Standalone Accessory';
|
|
51
50
|
log.debug(`Creating ${hostTypeName} with UUID ${hostUUID}`);
|
|
52
|
-
if (
|
|
53
|
-
|
|
51
|
+
if (this.hostType == HostType_1.default.BRIDGE) {
|
|
52
|
+
this.host = new hap_nodejs_1.Bridge(this.name, hostUUID);
|
|
54
53
|
}
|
|
55
54
|
else {
|
|
56
|
-
|
|
55
|
+
this.host = new hap_nodejs_1.Accessory(this.name, hostUUID);
|
|
57
56
|
}
|
|
58
|
-
|
|
57
|
+
this.publish = () => {
|
|
59
58
|
var _a, _b;
|
|
60
|
-
if (
|
|
61
|
-
log.debug(`Publishing ${hostTypeName} with pin code ${
|
|
59
|
+
if (this.hostType == HostType_1.default.BRIDGE) {
|
|
60
|
+
log.debug(`Publishing ${hostTypeName} with pin code ${this.config.pinCode} and ${this.host.bridgedAccessories.length} accessories`);
|
|
62
61
|
}
|
|
63
62
|
else {
|
|
64
|
-
log.debug(`Publishing ${hostTypeName} with pin code ${
|
|
63
|
+
log.debug(`Publishing ${hostTypeName} with pin code ${this.config.pinCode}`);
|
|
65
64
|
}
|
|
66
|
-
if (
|
|
65
|
+
if (this.config.port === 1880) {
|
|
67
66
|
log.error(`Cannot publish on ${hostTypeName} port 1880 as it is reserved for node-red`);
|
|
68
|
-
|
|
67
|
+
this.published = false;
|
|
69
68
|
return false;
|
|
70
69
|
}
|
|
71
|
-
let oldPinCode =
|
|
72
|
-
if ((oldPinCode.match(/-/g) || []).length
|
|
70
|
+
let oldPinCode = this.config.pinCode;
|
|
71
|
+
if ((oldPinCode.match(/-/g) || []).length === 1) {
|
|
73
72
|
oldPinCode = oldPinCode.replace(/-/g, '');
|
|
74
73
|
oldPinCode = `${oldPinCode.slice(0, 3)}-${oldPinCode.slice(3, 5)}-${oldPinCode.slice(5, 8)}`;
|
|
75
74
|
}
|
|
76
75
|
let bind;
|
|
77
|
-
if (((_a =
|
|
78
|
-
if (
|
|
79
|
-
bind =
|
|
76
|
+
if (((_a = this.config.bind) === null || _a === void 0 ? void 0 : _a.length) && this.config.bindType) {
|
|
77
|
+
if (this.config.bindType === 'str') {
|
|
78
|
+
bind = this.config.bind;
|
|
80
79
|
}
|
|
81
|
-
else if (
|
|
82
|
-
bind = JSON.parse(
|
|
80
|
+
else if (this.config.bindType === 'json') {
|
|
81
|
+
bind = JSON.parse(this.config.bind);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
|
-
|
|
86
|
-
username:
|
|
87
|
-
port:
|
|
84
|
+
this.host.publish({
|
|
85
|
+
username: this.bridgeUsername,
|
|
86
|
+
port: this.config.port && !Number.isNaN(this.config.port)
|
|
87
|
+
? this.config.port
|
|
88
|
+
: 0,
|
|
88
89
|
pincode: oldPinCode,
|
|
89
|
-
category:
|
|
90
|
+
category: this.accessoryCategory,
|
|
90
91
|
bind: bind,
|
|
91
|
-
advertiser: (_b =
|
|
92
|
-
},
|
|
93
|
-
|
|
92
|
+
advertiser: (_b = this.config.advertiser) !== null && _b !== void 0 ? _b : "bonjour-hap"
|
|
93
|
+
}, this.config.allowInsecureRequest);
|
|
94
|
+
this.published = true;
|
|
94
95
|
return true;
|
|
95
96
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
self.host.on('identify', function (paired, callback) {
|
|
97
|
+
this.on('close', (removed, done) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
if (removed) {
|
|
99
|
+
log.debug('This node has been deleted');
|
|
100
|
+
yield this.host.destroy();
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
log.debug('This node is being restarted');
|
|
104
|
+
yield this.host.unpublish();
|
|
105
|
+
}
|
|
106
|
+
this.published = false;
|
|
107
|
+
done();
|
|
108
|
+
}));
|
|
109
|
+
this.host.on('identify', (paired, callback) => {
|
|
111
110
|
if (paired) {
|
|
112
111
|
log.debug(`Identify called on paired ${hostTypeName}`);
|
|
113
112
|
}
|
|
@@ -116,15 +115,15 @@ module.exports = (RED, hostType) => {
|
|
|
116
115
|
}
|
|
117
116
|
callback();
|
|
118
117
|
});
|
|
119
|
-
const accessoryInformationService =
|
|
120
|
-
|
|
118
|
+
const accessoryInformationService = this.host.getService(hap_nodejs_1.Service.AccessoryInformation) ||
|
|
119
|
+
this.host.addService(hap_nodejs_1.Service.AccessoryInformation);
|
|
121
120
|
accessoryInformationService
|
|
122
|
-
.setCharacteristic(hap_nodejs_1.Characteristic.Manufacturer,
|
|
123
|
-
.setCharacteristic(hap_nodejs_1.Characteristic.SerialNumber,
|
|
124
|
-
.setCharacteristic(hap_nodejs_1.Characteristic.Model,
|
|
125
|
-
.setCharacteristic(hap_nodejs_1.Characteristic.FirmwareRevision, (_a =
|
|
126
|
-
.setCharacteristic(hap_nodejs_1.Characteristic.HardwareRevision, (_b =
|
|
127
|
-
.setCharacteristic(hap_nodejs_1.Characteristic.SoftwareRevision, (_c =
|
|
121
|
+
.setCharacteristic(hap_nodejs_1.Characteristic.Manufacturer, this.config.manufacturer)
|
|
122
|
+
.setCharacteristic(hap_nodejs_1.Characteristic.SerialNumber, this.config.serialNo)
|
|
123
|
+
.setCharacteristic(hap_nodejs_1.Characteristic.Model, this.config.model)
|
|
124
|
+
.setCharacteristic(hap_nodejs_1.Characteristic.FirmwareRevision, (_a = this.config.firmwareRev) === null || _a === void 0 ? void 0 : _a.toString())
|
|
125
|
+
.setCharacteristic(hap_nodejs_1.Characteristic.HardwareRevision, (_b = this.config.hardwareRev) === null || _b === void 0 ? void 0 : _b.toString())
|
|
126
|
+
.setCharacteristic(hap_nodejs_1.Characteristic.SoftwareRevision, (_c = this.config.softwareRev) === null || _c === void 0 ? void 0 : _c.toString());
|
|
128
127
|
};
|
|
129
128
|
const macify = (nodeId) => {
|
|
130
129
|
if (nodeId) {
|
|
@@ -142,9 +141,7 @@ module.exports = (RED, hostType) => {
|
|
|
142
141
|
throw new NRCHKBError_1.default('nodeId cannot be empty in macify process');
|
|
143
142
|
}
|
|
144
143
|
};
|
|
145
|
-
const hostNameValidator =
|
|
146
|
-
return hostName ? /^[^.]{1,64}$/.test(hostName) : false;
|
|
147
|
-
};
|
|
144
|
+
const hostNameValidator = (hostName) => hostName ? /^[^.]{1,64}$/.test(hostName) : false;
|
|
148
145
|
return {
|
|
149
146
|
init,
|
|
150
147
|
macify
|
|
@@ -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', 'HAPServiceNode', 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/ServiceUtils')(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', 'HAPServiceNode', 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/ServiceUtils')(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', 'HAPServiceNode', this.config.name, this);
|
|
59
|
+
const ServiceUtils = require('./utils/ServiceUtils')(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', 'HAPServiceNode', this.config.name, this);
|
|
82
|
+
const Utils = require('./utils')(this);
|
|
87
83
|
const AccessoryUtils = Utils.AccessoryUtils;
|
|
88
84
|
const BridgeUtils = Utils.BridgeUtils;
|
|
89
85
|
const CharacteristicUtils = Utils.CharacteristicUtils;
|
|
90
86
|
const ServiceUtils = Utils.ServiceUtils;
|
|
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,
|