node-red-contrib-homekit-bridged 2.0.0-dev.0 → 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 -64
- package/build/lib/HAPServiceNode.js +91 -95
- package/build/lib/HAPServiceNode2.js +93 -97
- package/build/lib/Storage.d.ts +3 -3
- package/build/lib/Storage.js +2 -2
- package/build/lib/api.js +26 -29
- 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/hap/eve-app/EveCharacteristics.js +10 -10
- 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 +15 -15
- package/build/lib/utils/BridgeUtils.js +5 -5
- package/build/lib/utils/CharacteristicUtils.js +6 -6
- package/build/lib/utils/CharacteristicUtils2.js +6 -6
- package/build/lib/utils/NodeStatusUtils.d.ts +2 -2
- package/build/lib/utils/NodeStatusUtils.js +2 -2
- package/build/lib/utils/ServiceUtils.js +39 -38
- package/build/lib/utils/ServiceUtils2.js +39 -37
- package/build/lib/utils/index.js +2 -2
- package/build/nodes/nrchkb.js +2 -2
- package/build/nodes/status.js +15 -16
- package/examples/demo/01 - ALL Demos single import.json +64 -318
- package/examples/demo/02 - Air Purifier.json +279 -328
- package/examples/demo/03 - Air Quality sensor with Battery.json +254 -282
- package/examples/demo/04 - Dimmable Bulb.json +172 -189
- package/examples/demo/05 - Color Bulb (HSV).json +195 -216
- package/examples/demo/06 - Fan (simple, 3 speeds).json +240 -265
- package/examples/demo/07 - Fan (with speed, oscillate, rotation direction).json +175 -192
- package/examples/demo/08 - CO2 detector.json +224 -255
- package/examples/demo/09 - CO (carbon monoxide) example.json +255 -290
- package/examples/demo/10 - Door window contact sensor.json +234 -265
- package/examples/demos (advanced)/01 - Television with inputs and speaker.json +541 -607
- package/examples/switch/01 - Plain Switch.json +7 -27
- package/package.json +83 -81
|
@@ -10,69 +10,66 @@ const HostType_1 = __importDefault(require("./types/HostType"));
|
|
|
10
10
|
const NodeStatusUtils_1 = require("./utils/NodeStatusUtils");
|
|
11
11
|
module.exports = (RED) => {
|
|
12
12
|
const nrchkbConfigCompatibilityOverride = function () {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
self.config.isParent = true;
|
|
13
|
+
const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', this.config.name, this);
|
|
14
|
+
if (this.config.isParent === undefined) {
|
|
15
|
+
log.trace(`nrchkbConfigCompatibilityOverride => self.config.isParent=${this.config.isParent} value changed to true`);
|
|
16
|
+
this.config.isParent = true;
|
|
18
17
|
}
|
|
19
|
-
if (
|
|
20
|
-
log.trace(`nrchkbConfigCompatibilityOverride => self.config.hostType=${
|
|
21
|
-
|
|
18
|
+
if (this.config.hostType === undefined) {
|
|
19
|
+
log.trace(`nrchkbConfigCompatibilityOverride => self.config.hostType=${this.config.hostType} value changed to HostType.BRIDGE`);
|
|
20
|
+
this.config.hostType = HostType_1.default.BRIDGE;
|
|
22
21
|
}
|
|
23
22
|
};
|
|
24
23
|
const preInit = function (config) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const ServiceUtils = require('./utils/ServiceUtils2')(self);
|
|
24
|
+
this.nodeStatusUtils = new NodeStatusUtils_1.NodeStatusUtils(this);
|
|
25
|
+
this.config = config;
|
|
26
|
+
this.name = this.config.name;
|
|
27
|
+
const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', this.config.name, this);
|
|
28
|
+
this.RED = RED;
|
|
29
|
+
this.publishTimers = {};
|
|
30
|
+
nrchkbConfigCompatibilityOverride.call(this);
|
|
31
|
+
RED.nodes.createNode(this, this.config);
|
|
32
|
+
const ServiceUtils = require('./utils/ServiceUtils2')(this);
|
|
35
33
|
new Promise((resolve) => {
|
|
36
|
-
if (
|
|
34
|
+
if (this.config.waitForSetupMsg) {
|
|
37
35
|
log.debug('Waiting for Setup message. It should be of format {"payload":{"nrchkb":{"setup":{}}}}');
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
this.setupDone = false;
|
|
37
|
+
this.nodeStatusUtils.setStatus({
|
|
40
38
|
fill: 'blue',
|
|
41
39
|
shape: 'dot',
|
|
42
|
-
text: 'Waiting for Setup'
|
|
40
|
+
text: 'Waiting for Setup'
|
|
43
41
|
});
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
this.handleWaitForSetup = (msg) => ServiceUtils.handleWaitForSetup(this.config, msg, resolve);
|
|
43
|
+
this.on('input', this.handleWaitForSetup);
|
|
46
44
|
}
|
|
47
45
|
else {
|
|
48
|
-
resolve(
|
|
46
|
+
resolve(this.config);
|
|
49
47
|
}
|
|
50
48
|
})
|
|
51
49
|
.then((newConfig) => {
|
|
52
|
-
init.call(
|
|
50
|
+
init.call(this, newConfig);
|
|
53
51
|
})
|
|
54
52
|
.catch((error) => {
|
|
55
53
|
log.error(`Error while starting Service due to ${error}`);
|
|
56
54
|
});
|
|
57
55
|
};
|
|
58
56
|
const init = function (config) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
if (self.config.isParent) {
|
|
57
|
+
this.config = config;
|
|
58
|
+
const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', this.config.name, this);
|
|
59
|
+
const ServiceUtils = require('./utils/ServiceUtils2')(this);
|
|
60
|
+
if (this.config.isParent) {
|
|
64
61
|
log.debug('Starting Parent Service');
|
|
65
|
-
configure.call(
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
configure.call(this);
|
|
63
|
+
this.configured = true;
|
|
64
|
+
this.reachable = true;
|
|
68
65
|
}
|
|
69
66
|
else {
|
|
70
67
|
const serviceType = config.serviceName === 'CameraControl' ? 'Camera' : 'Linked';
|
|
71
68
|
ServiceUtils.waitForParent()
|
|
72
69
|
.then(() => {
|
|
73
70
|
log.debug(`Starting ${serviceType} Service`);
|
|
74
|
-
configure.call(
|
|
75
|
-
|
|
71
|
+
configure.call(this);
|
|
72
|
+
this.configured = true;
|
|
76
73
|
})
|
|
77
74
|
.catch((error) => {
|
|
78
75
|
log.error(`Error while starting ${serviceType} Service due to ${error}`);
|
|
@@ -81,102 +78,101 @@ module.exports = (RED) => {
|
|
|
81
78
|
};
|
|
82
79
|
const configure = function () {
|
|
83
80
|
var _a, _b;
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const Utils = require('./utils')(self);
|
|
81
|
+
const log = (0, logger_1.logger)('NRCHKB', 'HAPServiceNode2', this.config.name, this);
|
|
82
|
+
const Utils = require('./utils')(this);
|
|
87
83
|
const AccessoryUtils = Utils.AccessoryUtils;
|
|
88
84
|
const BridgeUtils = Utils.BridgeUtils;
|
|
89
|
-
const CharacteristicUtils = require('./utils/CharacteristicUtils2')(
|
|
90
|
-
const ServiceUtils = require('./utils/ServiceUtils2')(
|
|
85
|
+
const CharacteristicUtils = require('./utils/CharacteristicUtils2')(this);
|
|
86
|
+
const ServiceUtils = require('./utils/ServiceUtils2')(this);
|
|
91
87
|
let parentNode;
|
|
92
|
-
if (
|
|
93
|
-
const hostId =
|
|
94
|
-
?
|
|
95
|
-
:
|
|
96
|
-
|
|
97
|
-
if (!
|
|
98
|
-
const message = `Host node ${
|
|
88
|
+
if (this.config.isParent) {
|
|
89
|
+
const hostId = this.config.hostType == HostType_1.default.BRIDGE
|
|
90
|
+
? this.config.bridge
|
|
91
|
+
: this.config.accessoryId;
|
|
92
|
+
this.hostNode = RED.nodes.getNode(hostId);
|
|
93
|
+
if (!this.hostNode) {
|
|
94
|
+
const message = `Host node ${this.config.hostType == HostType_1.default.BRIDGE ? 'Bridge' : 'Standalone Accessory'} ${hostId} not found`;
|
|
99
95
|
log.error(message, false);
|
|
100
96
|
throw new NRCHKBError_1.default(message);
|
|
101
97
|
}
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
this.childNodes = [];
|
|
99
|
+
this.childNodes.push(this);
|
|
104
100
|
}
|
|
105
101
|
else {
|
|
106
|
-
parentNode = RED.nodes.getNode(
|
|
102
|
+
parentNode = RED.nodes.getNode(this.config.parentService);
|
|
107
103
|
if (!parentNode) {
|
|
108
104
|
log.error('Parent Node not assigned', false);
|
|
109
105
|
throw new NRCHKBError_1.default('Parent Node not assigned');
|
|
110
106
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (!
|
|
107
|
+
this.parentNode = parentNode;
|
|
108
|
+
this.parentService = this.parentNode.service;
|
|
109
|
+
if (!this.parentService) {
|
|
114
110
|
log.error('Parent Service not assigned', false);
|
|
115
111
|
throw new NRCHKBError_1.default('Parent Service not assigned');
|
|
116
112
|
}
|
|
117
|
-
|
|
118
|
-
(_a =
|
|
119
|
-
|
|
113
|
+
this.hostNode = this.parentNode.hostNode;
|
|
114
|
+
(_a = this.parentNode.childNodes) === null || _a === void 0 ? void 0 : _a.push(this);
|
|
115
|
+
this.accessory = this.parentNode.accessory;
|
|
120
116
|
}
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
117
|
+
this.name = this.config.name;
|
|
118
|
+
if (Object.hasOwn(this, '_flow') &&
|
|
119
|
+
Object.hasOwn(this, '_alias') &&
|
|
120
|
+
(this._flow ? Object(this._flow).hasOwn('TYPE') : false) &&
|
|
121
|
+
((_b = this._flow) === null || _b === void 0 ? void 0 : _b.TYPE) === 'subflow') {
|
|
122
|
+
this.uniqueIdentifier = `${this._alias}/${this._flow.path}`;
|
|
127
123
|
}
|
|
128
124
|
else {
|
|
129
|
-
|
|
125
|
+
this.uniqueIdentifier = this.id;
|
|
130
126
|
}
|
|
131
|
-
const subtypeUUID = hap_nodejs_1.uuid.generate(
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
127
|
+
const subtypeUUID = hap_nodejs_1.uuid.generate(this.uniqueIdentifier);
|
|
128
|
+
if (this.config.hostType == HostType_1.default.BRIDGE) {
|
|
129
|
+
if (this.config.isParent) {
|
|
134
130
|
const accessoryUUID = hap_nodejs_1.uuid.generate('A' +
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
name:
|
|
131
|
+
this.uniqueIdentifier +
|
|
132
|
+
this.name +
|
|
133
|
+
this.config.manufacturer +
|
|
134
|
+
this.config.serialNo +
|
|
135
|
+
this.config.model);
|
|
136
|
+
this.accessory = AccessoryUtils.getOrCreate(this.hostNode.host, {
|
|
137
|
+
name: this.name,
|
|
142
138
|
UUID: accessoryUUID,
|
|
143
|
-
manufacturer:
|
|
144
|
-
serialNo:
|
|
145
|
-
model:
|
|
146
|
-
firmwareRev:
|
|
147
|
-
hardwareRev:
|
|
148
|
-
softwareRev:
|
|
139
|
+
manufacturer: this.config.manufacturer,
|
|
140
|
+
serialNo: this.config.serialNo,
|
|
141
|
+
model: this.config.model,
|
|
142
|
+
firmwareRev: this.config.firmwareRev,
|
|
143
|
+
hardwareRev: this.config.hardwareRev,
|
|
144
|
+
softwareRev: this.config.softwareRev
|
|
149
145
|
}, subtypeUUID);
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
this.onIdentify = AccessoryUtils.onIdentify;
|
|
147
|
+
this.accessory.on('identify', this.onIdentify);
|
|
152
148
|
}
|
|
153
149
|
}
|
|
154
150
|
else {
|
|
155
151
|
log.debug('Binding Service accessory as Standalone Accessory');
|
|
156
|
-
|
|
152
|
+
this.accessory = this.hostNode.host;
|
|
157
153
|
}
|
|
158
|
-
|
|
159
|
-
name:
|
|
154
|
+
this.service = ServiceUtils.getOrCreate(this.accessory, {
|
|
155
|
+
name: this.name,
|
|
160
156
|
UUID: subtypeUUID,
|
|
161
|
-
serviceName:
|
|
162
|
-
config:
|
|
163
|
-
},
|
|
164
|
-
|
|
157
|
+
serviceName: this.config.serviceName,
|
|
158
|
+
config: this.config
|
|
159
|
+
}, this.parentService);
|
|
160
|
+
this.characteristicProperties = CharacteristicUtils.load(this.service, this.config);
|
|
165
161
|
ServiceUtils.configureAdaptiveLightning();
|
|
166
|
-
if (
|
|
167
|
-
BridgeUtils.delayedPublish(
|
|
162
|
+
if (this.config.isParent) {
|
|
163
|
+
BridgeUtils.delayedPublish(this);
|
|
168
164
|
}
|
|
169
|
-
|
|
165
|
+
this.nodeStatusUtils.setStatus({
|
|
170
166
|
fill: 'yellow',
|
|
171
167
|
shape: 'ring',
|
|
172
|
-
text:
|
|
168
|
+
text: this.hostNode.config.pinCode
|
|
173
169
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
this.supported = CharacteristicUtils.subscribeAndGetSupported(this.service);
|
|
171
|
+
this.on('input', ServiceUtils.onInput);
|
|
172
|
+
this.on('close', ServiceUtils.onClose);
|
|
177
173
|
};
|
|
178
174
|
return {
|
|
179
175
|
preInit,
|
|
180
|
-
init
|
|
176
|
+
init
|
|
181
177
|
};
|
|
182
178
|
};
|
package/build/lib/Storage.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CharacteristicEventTypes, SerializedAccessory, SerializedService } from '@homebridge/hap-nodejs';
|
|
2
|
-
import storage, { InitOptions } from 'node-persist';
|
|
3
|
-
import { SerializedHostType } from './types/storage/SerializedHostType';
|
|
1
|
+
import type { CharacteristicEventTypes, SerializedAccessory, SerializedService } from '@homebridge/hap-nodejs';
|
|
2
|
+
import storage, { type InitOptions } from 'node-persist';
|
|
3
|
+
import type { SerializedHostType } from './types/storage/SerializedHostType';
|
|
4
4
|
import { StorageType } from './types/storage/StorageType';
|
|
5
5
|
type EventCallback = {
|
|
6
6
|
event: CharacteristicEventTypes;
|
package/build/lib/Storage.js
CHANGED
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Storage = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
8
|
const logger_1 = require("@nrchkb/logger");
|
|
8
9
|
const node_persist_1 = __importDefault(require("node-persist"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const uuid_1 = require("uuid");
|
|
11
11
|
const NRCHKBError_1 = __importDefault(require("./NRCHKBError"));
|
|
12
12
|
const StorageType_1 = require("./types/storage/StorageType");
|
|
@@ -18,7 +18,7 @@ class Storage {
|
|
|
18
18
|
return Storage.customStoragePath;
|
|
19
19
|
}
|
|
20
20
|
static init(...storagePathSegments) {
|
|
21
|
-
Storage.customStoragePath =
|
|
21
|
+
Storage.customStoragePath = node_path_1.default.resolve(...storagePathSegments);
|
|
22
22
|
Storage.storageInitialized = true;
|
|
23
23
|
Storage.log.trace('Initializing');
|
|
24
24
|
return node_persist_1.default.init({ dir: Storage.storagePath() });
|
package/build/lib/api.js
CHANGED
|
@@ -29,38 +29,38 @@ const EveCharacteristics_1 = __importDefault(require("./hap/eve-app/EveCharacter
|
|
|
29
29
|
const Storage_1 = require("./Storage");
|
|
30
30
|
const HapCategories_1 = __importDefault(require("./types/hap-nodejs/HapCategories"));
|
|
31
31
|
const version = require('../../package.json').version.trim();
|
|
32
|
-
module.exports =
|
|
32
|
+
module.exports = (RED) => {
|
|
33
33
|
const log = (0, logger_1.logger)('NRCHKB', 'API');
|
|
34
34
|
const _initServiceAPI = () => {
|
|
35
35
|
log.debug('Initialize Service API');
|
|
36
36
|
const serviceData = {
|
|
37
37
|
BatteryService: {
|
|
38
|
-
nrchkbDisabledText: 'BatteryService (deprecated, replaced by Battery)'
|
|
38
|
+
nrchkbDisabledText: 'BatteryService (deprecated, replaced by Battery)'
|
|
39
39
|
},
|
|
40
40
|
BridgeConfiguration: {
|
|
41
|
-
nrchkbDisabledText: 'BridgeConfiguration (deprecated, unused)'
|
|
41
|
+
nrchkbDisabledText: 'BridgeConfiguration (deprecated, unused)'
|
|
42
42
|
},
|
|
43
43
|
BridgingState: {
|
|
44
|
-
nrchkbDisabledText: 'BridgingState (deprecated, unused)'
|
|
44
|
+
nrchkbDisabledText: 'BridgingState (deprecated, unused)'
|
|
45
45
|
},
|
|
46
46
|
CameraControl: {
|
|
47
|
-
nrchkbDisabledText: 'CameraControl (deprecated, replaced by)'
|
|
47
|
+
nrchkbDisabledText: 'CameraControl (deprecated, replaced by)'
|
|
48
48
|
},
|
|
49
49
|
CameraEventRecordingManagement: {
|
|
50
|
-
nrchkbDisabledText: 'CameraEventRecordingManagement (deprecated, replaced by CameraRecordingManagement)'
|
|
50
|
+
nrchkbDisabledText: 'CameraEventRecordingManagement (deprecated, replaced by CameraRecordingManagement)'
|
|
51
51
|
},
|
|
52
52
|
Relay: {
|
|
53
|
-
nrchkbDisabledText: 'Relay (deprecated, replaced by CloudRelay)'
|
|
53
|
+
nrchkbDisabledText: 'Relay (deprecated, replaced by CloudRelay)'
|
|
54
54
|
},
|
|
55
55
|
Slat: {
|
|
56
|
-
nrchkbDisabledText: 'Slat (deprecated, replaced by Slats)'
|
|
56
|
+
nrchkbDisabledText: 'Slat (deprecated, replaced by Slats)'
|
|
57
57
|
},
|
|
58
58
|
TimeInformation: {
|
|
59
|
-
nrchkbDisabledText: 'TimeInformation (deprecated, unused)'
|
|
59
|
+
nrchkbDisabledText: 'TimeInformation (deprecated, unused)'
|
|
60
60
|
},
|
|
61
61
|
TunneledBTLEAccessoryService: {
|
|
62
|
-
nrchkbDisabledText: 'TunneledBTLEAccessoryService (deprecated, replaced by Tunnel)'
|
|
63
|
-
}
|
|
62
|
+
nrchkbDisabledText: 'TunneledBTLEAccessoryService (deprecated, replaced by Tunnel)'
|
|
63
|
+
}
|
|
64
64
|
};
|
|
65
65
|
Object.values(hap_nodejs_1.Service)
|
|
66
66
|
.filter((service) => service.prototype instanceof hap_nodejs_1.Service)
|
|
@@ -128,12 +128,12 @@ module.exports = function (RED) {
|
|
|
128
128
|
res.setHeader('Content-Type', 'application/json');
|
|
129
129
|
res.json({
|
|
130
130
|
version: xyzVersion,
|
|
131
|
-
experimental
|
|
131
|
+
experimental
|
|
132
132
|
});
|
|
133
133
|
});
|
|
134
134
|
};
|
|
135
|
-
const _initNRCHKBCustomCharacteristicsAPI = () => __awaiter(
|
|
136
|
-
const getCustomCharacteristics = () => __awaiter(
|
|
135
|
+
const _initNRCHKBCustomCharacteristicsAPI = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
+
const getCustomCharacteristics = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
137
|
try {
|
|
138
138
|
const value = yield Storage_1.Storage.loadCustomCharacteristics();
|
|
139
139
|
log.trace('loadCustomCharacteristics()');
|
|
@@ -156,7 +156,7 @@ module.exports = function (RED) {
|
|
|
156
156
|
};
|
|
157
157
|
const toNumber = (value, optional = undefined) => {
|
|
158
158
|
const num = Number(value);
|
|
159
|
-
if (isNaN(num)) {
|
|
159
|
+
if (Number.isNaN(num)) {
|
|
160
160
|
return optional;
|
|
161
161
|
}
|
|
162
162
|
else
|
|
@@ -201,7 +201,7 @@ module.exports = function (RED) {
|
|
|
201
201
|
super(name, CustomCharacteristic.UUID, Object.assign(Object.assign({}, validatedProps), { perms: (_a = validatedProps.perms) !== null && _a !== void 0 ? _a : [
|
|
202
202
|
"pr",
|
|
203
203
|
"pw",
|
|
204
|
-
"ev"
|
|
204
|
+
"ev"
|
|
205
205
|
] }));
|
|
206
206
|
this.value = this.getDefaultValue();
|
|
207
207
|
}
|
|
@@ -209,11 +209,11 @@ module.exports = function (RED) {
|
|
|
209
209
|
CustomCharacteristic.UUID = UUID;
|
|
210
210
|
Object.defineProperty(CustomCharacteristic, 'name', {
|
|
211
211
|
value: key,
|
|
212
|
-
configurable: true
|
|
212
|
+
configurable: true
|
|
213
213
|
});
|
|
214
214
|
Object.defineProperty(hap_nodejs_1.Characteristic, key, {
|
|
215
215
|
value: CustomCharacteristic,
|
|
216
|
-
configurable: true
|
|
216
|
+
configurable: true
|
|
217
217
|
});
|
|
218
218
|
customCharacteristicKeys.push(key);
|
|
219
219
|
}
|
|
@@ -238,15 +238,12 @@ module.exports = function (RED) {
|
|
|
238
238
|
node.type === 'homekit-service2') {
|
|
239
239
|
const serviceNodeConfig = node;
|
|
240
240
|
const serviceNode = RED.nodes.getNode(serviceNodeConfig.id);
|
|
241
|
-
if (serviceNode &&
|
|
242
|
-
serviceNode.characteristicProperties &&
|
|
243
|
-
serviceNode.service) {
|
|
241
|
+
if ((serviceNode === null || serviceNode === void 0 ? void 0 : serviceNode.characteristicProperties) && serviceNode.service) {
|
|
244
242
|
for (const key in serviceNode.characteristicProperties) {
|
|
245
243
|
if (customCharacteristicKeys.includes(key)) {
|
|
246
244
|
const characteristic = serviceNode.service
|
|
247
245
|
.getCharacteristic(hap_nodejs_1.Characteristic[key])
|
|
248
|
-
.setProps(serviceNode
|
|
249
|
-
.characteristicProperties[key]);
|
|
246
|
+
.setProps(serviceNode.characteristicProperties[key]);
|
|
250
247
|
serviceNode.supported.push(key);
|
|
251
248
|
characteristic.on('get', serviceNode.onCharacteristicGet);
|
|
252
249
|
characteristic.on('set', serviceNode.onCharacteristicSet);
|
|
@@ -260,13 +257,13 @@ module.exports = function (RED) {
|
|
|
260
257
|
};
|
|
261
258
|
log.debug('Initialize NRCHKBCustomCharacteristicsAPI');
|
|
262
259
|
getCustomCharacteristics().then((value) => refreshCustomCharacteristics(value));
|
|
263
|
-
RED.httpAdmin.get('/nrchkb/config', RED.auth.needsPermission('nrchkb.read'), (_req, res) => __awaiter(
|
|
260
|
+
RED.httpAdmin.get('/nrchkb/config', RED.auth.needsPermission('nrchkb.read'), (_req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
264
261
|
res.setHeader('Content-Type', 'application/json');
|
|
265
262
|
res.json({
|
|
266
|
-
customCharacteristics: yield getCustomCharacteristics()
|
|
263
|
+
customCharacteristics: yield getCustomCharacteristics()
|
|
267
264
|
});
|
|
268
265
|
}));
|
|
269
|
-
RED.httpAdmin.post('/nrchkb/config', RED.auth.needsPermission('nrchkb.write'), (req, res) => __awaiter(
|
|
266
|
+
RED.httpAdmin.post('/nrchkb/config', RED.auth.needsPermission('nrchkb.write'), (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
270
267
|
const customCharacteristics = req.body.customCharacteristics || EveCharacteristics_1.default;
|
|
271
268
|
Storage_1.Storage.saveCustomCharacteristics(customCharacteristics)
|
|
272
269
|
.then(() => {
|
|
@@ -279,12 +276,12 @@ module.exports = function (RED) {
|
|
|
279
276
|
});
|
|
280
277
|
}));
|
|
281
278
|
});
|
|
282
|
-
const _initAccessoryAPI =
|
|
279
|
+
const _initAccessoryAPI = () => {
|
|
283
280
|
log.debug('Initialize Accessory API');
|
|
284
281
|
const accessoryCategoriesData = {};
|
|
285
282
|
Object.keys(HapCategories_1.default)
|
|
286
283
|
.sort()
|
|
287
|
-
.filter((x) => parseInt(x) >= 0)
|
|
284
|
+
.filter((x) => parseInt(x, 10) >= 0)
|
|
288
285
|
.forEach((key) => {
|
|
289
286
|
const keyNumber = key;
|
|
290
287
|
accessoryCategoriesData[keyNumber] = HapCategories_1.default[keyNumber];
|
|
@@ -304,6 +301,6 @@ module.exports = function (RED) {
|
|
|
304
301
|
};
|
|
305
302
|
return {
|
|
306
303
|
init,
|
|
307
|
-
stringifyVersion
|
|
304
|
+
stringifyVersion
|
|
308
305
|
};
|
|
309
306
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Characteristic } from '@homebridge/hap-nodejs';
|
|
2
|
-
import { EveS2R1, EveS2R2, EveS2W1, EveS2W2 } from './eve-app/EveCharacteristics';
|
|
2
|
+
import type { EveS2R1, EveS2R2, EveS2W1, EveS2W2 } from './eve-app/EveCharacteristics';
|
|
3
3
|
declare class HAPCharacteristic extends Characteristic {
|
|
4
4
|
static EveS2R1: typeof EveS2R1;
|
|
5
5
|
static EveS2R2: typeof EveS2R2;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import CustomCharacteristicType from '../../types/CustomCharacteristicType';
|
|
1
|
+
import type CustomCharacteristicType from '../../types/CustomCharacteristicType';
|
|
2
2
|
import HAPCharacteristic from '../HAPCharacteristic';
|
|
3
3
|
declare const EveCharacteristics: CustomCharacteristicType[];
|
|
4
4
|
export declare class EveS2R1 extends HAPCharacteristic {
|
|
@@ -11,42 +11,42 @@ const EveCharacteristics = [
|
|
|
11
11
|
name: 'Eve-Volt',
|
|
12
12
|
format: "float",
|
|
13
13
|
perms: ["pr"],
|
|
14
|
-
description: 'Volt (V) value. Used by Eve.app.'
|
|
14
|
+
description: 'Volt (V) value. Used by Eve.app.'
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
UUID: 'E863F126-079E-48FF-8F27-9C2605A29F52',
|
|
18
18
|
name: 'Eve-Ampere',
|
|
19
19
|
format: "float",
|
|
20
20
|
perms: ["pr"],
|
|
21
|
-
description: 'Ampere (A) value. Used by Eve.app.'
|
|
21
|
+
description: 'Ampere (A) value. Used by Eve.app.'
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
UUID: 'E863F10D-079E-48FF-8F27-9C2605A29F52',
|
|
25
25
|
name: 'Eve-Watt',
|
|
26
26
|
format: "float",
|
|
27
27
|
perms: ["pr"],
|
|
28
|
-
description: 'Watt (W) value. Used by Eve.app, reported as "Consumption".'
|
|
28
|
+
description: 'Watt (W) value. Used by Eve.app, reported as "Consumption".'
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
UUID: 'E863F10C-079E-48FF-8F27-9C2605A29F52',
|
|
32
32
|
name: 'Eve-Kilowatt-hour',
|
|
33
33
|
format: "float",
|
|
34
34
|
perms: ["pr"],
|
|
35
|
-
description: 'Kilowatt-hour (kWh) value. Used by Eve.app, reported as Total Consumption.'
|
|
35
|
+
description: 'Kilowatt-hour (kWh) value. Used by Eve.app, reported as Total Consumption.'
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
UUID: 'E863F110-079E-48FF-8F27-9C2605A29F52',
|
|
39
39
|
name: 'Eve-Volt-Ampere',
|
|
40
40
|
format: "uint16",
|
|
41
41
|
perms: ["pr"],
|
|
42
|
-
description: 'Volt-Ampere (VA) value. Used by Eve.app.'
|
|
43
|
-
}
|
|
42
|
+
description: 'Volt-Ampere (VA) value. Used by Eve.app.'
|
|
43
|
+
}
|
|
44
44
|
];
|
|
45
45
|
class EveS2R1 extends HAPCharacteristic_1.default {
|
|
46
46
|
constructor() {
|
|
47
47
|
super('Eve-S2R1', EveS2R1.UUID, {
|
|
48
48
|
format: "data",
|
|
49
|
-
perms: ["pr", "ev", "hd"]
|
|
49
|
+
perms: ["pr", "ev", "hd"]
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -57,7 +57,7 @@ class EveS2R2 extends HAPCharacteristic_1.default {
|
|
|
57
57
|
constructor() {
|
|
58
58
|
super('Eve-S2R2', EveS2R2.UUID, {
|
|
59
59
|
format: "data",
|
|
60
|
-
perms: ["pr", "ev", "hd"]
|
|
60
|
+
perms: ["pr", "ev", "hd"]
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -68,7 +68,7 @@ class EveS2W1 extends HAPCharacteristic_1.default {
|
|
|
68
68
|
constructor() {
|
|
69
69
|
super('Eve-S2W1', EveS2W1.UUID, {
|
|
70
70
|
format: "data",
|
|
71
|
-
perms: ["pw", "hd"]
|
|
71
|
+
perms: ["pw", "hd"]
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -79,7 +79,7 @@ class EveS2W2 extends HAPCharacteristic_1.default {
|
|
|
79
79
|
constructor() {
|
|
80
80
|
super('Eve-S2W2', EveS2W2.UUID, {
|
|
81
81
|
format: "data",
|
|
82
|
-
perms: ["pw", "hd"]
|
|
82
|
+
perms: ["pw", "hd"]
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MDNSAdvertiser } from '@homebridge/hap-nodejs';
|
|
2
|
-
import { NodeDef } from 'node-red';
|
|
3
|
-
import { SemVer } from 'semver';
|
|
4
|
-
import HapCategories from './hap-nodejs/HapCategories';
|
|
1
|
+
import type { MDNSAdvertiser } from '@homebridge/hap-nodejs';
|
|
2
|
+
import type { NodeDef } from 'node-red';
|
|
3
|
+
import type { SemVer } from 'semver';
|
|
4
|
+
import type HapCategories from './hap-nodejs/HapCategories';
|
|
5
5
|
type HAPHostConfigType = NodeDef & {
|
|
6
6
|
bridgeName: string;
|
|
7
7
|
pinCode: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Accessory, Categories } from '@homebridge/hap-nodejs';
|
|
2
|
-
import HAPHostConfigType from './HAPHostConfigType';
|
|
3
|
-
import HostType from './HostType';
|
|
4
|
-
import NodeType from './NodeType';
|
|
1
|
+
import type { Accessory, Categories } from '@homebridge/hap-nodejs';
|
|
2
|
+
import type HAPHostConfigType from './HAPHostConfigType';
|
|
3
|
+
import type HostType from './HostType';
|
|
4
|
+
import type NodeType from './NodeType';
|
|
5
5
|
type HAPHostNodeType = NodeType & {
|
|
6
6
|
config: HAPHostConfigType;
|
|
7
7
|
accessoryCategory: Categories;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NodeDef } from 'node-red';
|
|
2
|
-
import HAPServiceConfigType from './HAPServiceConfigType';
|
|
1
|
+
import type { NodeDef } from 'node-red';
|
|
2
|
+
import type HAPServiceConfigType from './HAPServiceConfigType';
|
|
3
3
|
type HAPService2ConfigType = NodeDef & HAPServiceConfigType & {
|
|
4
4
|
useEventCallback: boolean;
|
|
5
5
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import HAPService2ConfigType from './HAPService2ConfigType';
|
|
2
|
-
import HAPServiceNodeType from './HAPServiceNodeType';
|
|
3
|
-
import NodeType from './NodeType';
|
|
1
|
+
import type HAPService2ConfigType from './HAPService2ConfigType';
|
|
2
|
+
import type HAPServiceNodeType from './HAPServiceNodeType';
|
|
3
|
+
import type NodeType from './NodeType';
|
|
4
4
|
type HAPService2NodeType = NodeType & HAPServiceNodeType & {
|
|
5
5
|
config: HAPService2ConfigType;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AdaptiveLightingControllerMode } from '@homebridge/hap-nodejs/dist/lib/controller/AdaptiveLightingController';
|
|
2
|
-
import { NodeDef } from 'node-red';
|
|
3
|
-
import CameraConfigType from './CameraConfigType';
|
|
1
|
+
import type { AdaptiveLightingControllerMode } from '@homebridge/hap-nodejs/dist/lib/controller/AdaptiveLightingController';
|
|
2
|
+
import type { NodeDef } from 'node-red';
|
|
3
|
+
import type CameraConfigType from './CameraConfigType';
|
|
4
4
|
type HAPServiceConfigType = NodeDef & {
|
|
5
5
|
isParent: boolean;
|
|
6
6
|
hostType: number;
|