homebridge-plejd 1.3.4 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +17 -1
- package/README.md +14 -17
- package/dist/index.d.ts +2 -3
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/model/device.d.ts +0 -1
- package/dist/model/device.js +1 -2
- package/dist/model/plejdSite.d.ts +0 -1
- package/dist/model/plejdSite.js +44 -47
- package/dist/model/plejdSite.js.map +1 -1
- package/dist/model/userInputConfig.d.ts +0 -1
- package/dist/model/userInputConfig.js +1 -2
- package/dist/plejdApi.d.ts +3 -4
- package/dist/plejdApi.js +124 -123
- package/dist/plejdApi.js.map +1 -1
- package/dist/plejdPlatform.d.ts +8 -9
- package/dist/plejdPlatform.js +190 -188
- package/dist/plejdPlatform.js.map +1 -1
- package/dist/plejdPlatformAccessory.d.ts +3 -4
- package/dist/plejdPlatformAccessory.js +46 -48
- package/dist/plejdPlatformAccessory.js.map +1 -1
- package/dist/plejdService.d.ts +2 -3
- package/dist/plejdService.js +262 -258
- package/dist/plejdService.js.map +1 -1
- package/dist/plejdUtils.d.ts +1 -2
- package/dist/plejdUtils.js +11 -17
- package/dist/plejdUtils.js.map +1 -1
- package/dist/settings.d.ts +0 -1
- package/dist/settings.js +6 -9
- package/dist/settings.js.map +1 -1
- package/package.json +20 -22
- package/dist/index.d.ts.map +0 -1
- package/dist/model/device.d.ts.map +0 -1
- package/dist/model/plejdSite.d.ts.map +0 -1
- package/dist/model/userInputConfig.d.ts.map +0 -1
- package/dist/plejdApi.d.ts.map +0 -1
- package/dist/plejdPlatform.d.ts.map +0 -1
- package/dist/plejdPlatformAccessory.d.ts.map +0 -1
- package/dist/plejdService.d.ts.map +0 -1
- package/dist/plejdUtils.d.ts.map +0 -1
- package/dist/settings.d.ts.map +0 -1
- package/my-site.json +0 -2427
package/dist/plejdPlatform.d.ts
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service, Characteristic } from
|
2
|
-
import { PlejdPlatformAccessoryHandler } from
|
3
|
-
import { UserInputConfig } from
|
4
|
-
import { Device } from
|
5
|
-
import { PlejdService } from
|
6
|
-
import { Site } from
|
1
|
+
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service, Characteristic } from "homebridge";
|
2
|
+
import { PlejdPlatformAccessoryHandler } from "./plejdPlatformAccessory.js";
|
3
|
+
import { UserInputConfig } from "./model/userInputConfig.js";
|
4
|
+
import { Device } from "./model/device.js";
|
5
|
+
import { PlejdService } from "./plejdService.js";
|
6
|
+
import { Site } from "./model/plejdSite.js";
|
7
7
|
export declare class PlejdPlatform implements DynamicPlatformPlugin {
|
8
8
|
readonly log: Logger;
|
9
9
|
readonly config: PlatformConfig;
|
10
|
-
readonly
|
10
|
+
readonly homebridgeApi: API;
|
11
11
|
readonly Service: typeof Service;
|
12
12
|
readonly Characteristic: typeof Characteristic;
|
13
13
|
userInputConfig?: UserInputConfig;
|
14
14
|
plejdService?: PlejdService;
|
15
15
|
readonly accessories: PlatformAccessory[];
|
16
16
|
readonly plejdHandlers: PlejdPlatformAccessoryHandler[];
|
17
|
-
constructor(log: Logger, config: PlatformConfig,
|
17
|
+
constructor(log: Logger, config: PlatformConfig, homebridgeApi: API);
|
18
18
|
configurePlejd: () => void;
|
19
19
|
configureDevices: (log: Logger, config: PlatformConfig, site?: Site) => void;
|
20
20
|
/**
|
@@ -27,4 +27,3 @@ export declare class PlejdPlatform implements DynamicPlatformPlugin {
|
|
27
27
|
onPlejdUpdates: (identifier: number, isOn: boolean, brightness?: number) => void;
|
28
28
|
private generateId;
|
29
29
|
}
|
30
|
-
//# sourceMappingURL=plejdPlatform.d.ts.map
|
package/dist/plejdPlatform.js
CHANGED
@@ -1,211 +1,213 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
import { PLATFORM_NAME, PLEJD_ADDONS, PLEJD_LIGHTS, PLUGIN_NAME, } from "./settings.js";
|
2
|
+
import { PlejdPlatformAccessoryHandler } from "./plejdPlatformAccessory.js";
|
3
|
+
import { PlejdService } from "./plejdService.js";
|
4
|
+
import PlejdRemoteApi from "./plejdApi.js";
|
5
|
+
export class PlejdPlatform {
|
6
|
+
log;
|
7
|
+
config;
|
8
|
+
homebridgeApi;
|
9
|
+
Service;
|
10
|
+
Characteristic;
|
11
|
+
userInputConfig;
|
12
|
+
plejdService;
|
13
|
+
// this is used to track restored cached accessories
|
14
|
+
accessories = [];
|
15
|
+
plejdHandlers = [];
|
16
|
+
constructor(log, config, homebridgeApi) {
|
13
17
|
this.log = log;
|
14
18
|
this.config = config;
|
15
|
-
this.
|
16
|
-
this.
|
17
|
-
|
18
|
-
|
19
|
-
this.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
else {
|
80
|
-
devices[pre].name = item.name;
|
81
|
-
}
|
19
|
+
this.homebridgeApi = homebridgeApi;
|
20
|
+
this.log.debug("Finished initializing platform:", this.config.platform);
|
21
|
+
homebridgeApi.on("didFinishLaunching", this.configurePlejd);
|
22
|
+
this.Characteristic = homebridgeApi.hap.Characteristic;
|
23
|
+
this.Service = homebridgeApi.hap.Service;
|
24
|
+
}
|
25
|
+
configurePlejd = () => {
|
26
|
+
if (this.config.password && this.config.site && this.config.username) {
|
27
|
+
this.log.info("Using login information to fetch devices & crypto key");
|
28
|
+
this.log.info("Any devices added manually will update the downloaded devices");
|
29
|
+
const pApi = new PlejdRemoteApi(this.log, this.config.site, this.config.username, this.config.password, true);
|
30
|
+
pApi
|
31
|
+
.getPlejdRemoteSite()
|
32
|
+
.then((site) => this.configureDevices(this.log, this.config, site))
|
33
|
+
.catch((e) => this.log.error(`Plejd remote access error: ${e}`));
|
34
|
+
}
|
35
|
+
else if (this.config.crypto_key &&
|
36
|
+
this.config.devices &&
|
37
|
+
this.config.devices.count > 0) {
|
38
|
+
this.log.info("Using supplied crypto key & devices");
|
39
|
+
this.configureDevices(this.log, this.config, undefined);
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
this.log.warn("No settings are prepared, either supply crypto key & devices OR username, password & site");
|
43
|
+
}
|
44
|
+
};
|
45
|
+
configureDevices = (log, config, site) => {
|
46
|
+
const devices = config.devices || [];
|
47
|
+
if (site) {
|
48
|
+
config.crypto_key = site.plejdMesh.cryptoKey;
|
49
|
+
const items = [];
|
50
|
+
// Extract devices
|
51
|
+
site.devices.forEach((item) => {
|
52
|
+
const name = item.title;
|
53
|
+
const id = item.deviceId;
|
54
|
+
const e = site.plejdDevices.find((x) => x.deviceId === id);
|
55
|
+
const dim = e.firmware.notes;
|
56
|
+
if (PLEJD_ADDONS.includes(dim)) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
const room = site.rooms.find((x) => x.roomId === item.roomId);
|
60
|
+
let identifier = site.inputAddress[id][0];
|
61
|
+
if (dim.endsWith("-02") &&
|
62
|
+
items.find((a) => a.identifier === identifier) !== undefined) {
|
63
|
+
identifier += 1;
|
64
|
+
}
|
65
|
+
const res = {
|
66
|
+
name: name,
|
67
|
+
model: dim,
|
68
|
+
identifier: identifier,
|
69
|
+
isDimmer: PLEJD_LIGHTS.includes(dim),
|
70
|
+
uuid: this.generateId(identifier.toString()),
|
71
|
+
room: room?.title,
|
72
|
+
hidden: false,
|
73
|
+
};
|
74
|
+
items.push(res);
|
75
|
+
});
|
76
|
+
items.forEach((item) => {
|
77
|
+
const pre = devices.findIndex((x) => x.identifier === item.identifier);
|
78
|
+
if (pre !== -1) {
|
79
|
+
if (devices[pre].hidden) {
|
80
|
+
log.debug("Hiding device |", devices[pre]);
|
81
|
+
devices.splice(pre);
|
82
82
|
}
|
83
83
|
else {
|
84
|
-
devices.
|
84
|
+
devices[pre].name = item.name;
|
85
85
|
}
|
86
|
-
});
|
87
|
-
}
|
88
|
-
for (let i = 0; i < devices.length; i++) {
|
89
|
-
if (devices[i].model) {
|
90
|
-
devices[i].isDimmer = settings_1.PLEJD_LIGHTS.includes(devices[i].model);
|
91
86
|
}
|
92
87
|
else {
|
93
|
-
|
94
|
-
}
|
95
|
-
if (devices[i].identifier) {
|
96
|
-
devices[i].uuid = this.generateId(devices[i].identifier.toString());
|
97
|
-
}
|
98
|
-
else {
|
99
|
-
log.error('Missing device identifier |', devices[i].name);
|
88
|
+
devices.push(item);
|
100
89
|
}
|
90
|
+
});
|
91
|
+
}
|
92
|
+
for (let i = 0; i < devices.length; i++) {
|
93
|
+
if (devices[i].model) {
|
94
|
+
devices[i].isDimmer = PLEJD_LIGHTS.includes(devices[i].model);
|
101
95
|
}
|
102
|
-
|
103
|
-
log.error(
|
96
|
+
else {
|
97
|
+
log.error("Missing device model |", devices[i].name);
|
104
98
|
}
|
105
|
-
|
106
|
-
|
107
|
-
devices: devices,
|
108
|
-
cryptoKey: cryptoKey,
|
109
|
-
};
|
110
|
-
log.info('Plejd Crypto Key:', config.crypto_key);
|
111
|
-
log.info('Plejd Devices connected to HomeKit:', this.userInputConfig.devices);
|
112
|
-
this.plejdService = new plejdService_1.PlejdService(this.userInputConfig, log, this.onPlejdUpdates.bind(this));
|
113
|
-
this.discoverDevices();
|
114
|
-
};
|
115
|
-
/**
|
116
|
-
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
117
|
-
* It should be used to setup event handlers for characteristics and update respective values.
|
118
|
-
*/
|
119
|
-
this.configureAccessory = (accessory) => {
|
120
|
-
this.log.info('Loading accessory from cache | ', accessory.displayName);
|
121
|
-
this.accessories.push(accessory);
|
122
|
-
};
|
123
|
-
this.discoverDevices = () => {
|
124
|
-
var _a;
|
125
|
-
const units = this.userInputConfig.devices.map((x) => x.uuid);
|
126
|
-
const notRegistered = this.accessories.filter((ac) => !units.includes(ac.UUID));
|
127
|
-
if (notRegistered.length > 0) {
|
128
|
-
this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, notRegistered);
|
99
|
+
if (devices[i].identifier) {
|
100
|
+
devices[i].uuid = this.generateId(devices[i].identifier.toString());
|
129
101
|
}
|
130
|
-
|
131
|
-
|
132
|
-
if (device.hidden) {
|
133
|
-
continue;
|
134
|
-
}
|
135
|
-
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === device.uuid);
|
136
|
-
if (existingAccessory) {
|
137
|
-
this.plejdHandlers.push(new plejdPlatformAccessory_1.PlejdPlatformAccessoryHandler(this, existingAccessory, device));
|
138
|
-
}
|
139
|
-
else {
|
140
|
-
this.addNewDevice(device);
|
141
|
-
}
|
102
|
+
else {
|
103
|
+
log.error("Missing device identifier |", devices[i].name);
|
142
104
|
}
|
105
|
+
}
|
106
|
+
if (!config.crypto_key) {
|
107
|
+
log.error("No Crypto key was found in the configuration. Check the plugin documentation for more info");
|
108
|
+
}
|
109
|
+
const cryptoKey = Buffer.from(config.crypto_key.replace(/-/g, ""), "hex");
|
110
|
+
this.userInputConfig = {
|
111
|
+
devices: devices,
|
112
|
+
cryptoKey: cryptoKey,
|
143
113
|
};
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
114
|
+
log.info("Plejd Crypto Key:", config.crypto_key);
|
115
|
+
log.info("Plejd Devices connected to HomeKit:", this.userInputConfig.devices);
|
116
|
+
this.plejdService = new PlejdService(this.userInputConfig, log, this.onPlejdUpdates.bind(this));
|
117
|
+
this.discoverDevices();
|
118
|
+
};
|
119
|
+
/**
|
120
|
+
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
121
|
+
* It should be used to setup event handlers for characteristics and update respective values.
|
122
|
+
*/
|
123
|
+
configureAccessory = (accessory) => {
|
124
|
+
this.log.info("Loading accessory from cache | ", accessory.displayName);
|
125
|
+
this.accessories.push(accessory);
|
126
|
+
};
|
127
|
+
discoverDevices = () => {
|
128
|
+
const units = this.userInputConfig.devices.map((x) => x.uuid);
|
129
|
+
const notRegistered = this.accessories.filter((ac) => !units.includes(ac.UUID));
|
130
|
+
if (notRegistered.length > 0) {
|
131
|
+
this.homebridgeApi.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, notRegistered);
|
132
|
+
}
|
133
|
+
this.log.debug("registering devices", this.userInputConfig?.devices);
|
134
|
+
for (const device of this.userInputConfig.devices) {
|
135
|
+
if (device.hidden) {
|
136
|
+
continue;
|
149
137
|
}
|
150
|
-
const
|
151
|
-
|
152
|
-
|
153
|
-
this.plejdHandlers.push(new plejdPlatformAccessory_1.PlejdPlatformAccessoryHandler(this, accessory, device));
|
154
|
-
// link the accessory to your platform
|
155
|
-
this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [
|
156
|
-
accessory,
|
157
|
-
]);
|
158
|
-
if (!this.accessories.find((x) => x.UUID === device.uuid)) {
|
159
|
-
this.accessories.push(accessory);
|
138
|
+
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === device.uuid);
|
139
|
+
if (existingAccessory) {
|
140
|
+
this.plejdHandlers.push(new PlejdPlatformAccessoryHandler(this, existingAccessory, device));
|
160
141
|
}
|
161
|
-
|
162
|
-
|
163
|
-
var _a, _b, _c;
|
164
|
-
const uuid = (_a = this.userInputConfig.devices.find((d) => d.identifier === identifier)) === null || _a === void 0 ? void 0 : _a.uuid;
|
165
|
-
if (uuid === undefined) {
|
166
|
-
// Scene or Room, eg: Unused
|
167
|
-
return;
|
142
|
+
else {
|
143
|
+
this.addNewDevice(device);
|
168
144
|
}
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
145
|
+
}
|
146
|
+
};
|
147
|
+
addNewDevice = (device) => {
|
148
|
+
let name = device.name;
|
149
|
+
this.log.info("Adding new accessory |", name);
|
150
|
+
if (device.room) {
|
151
|
+
name = device.room + " - " + name;
|
152
|
+
}
|
153
|
+
const accessory = new this.homebridgeApi.platformAccessory(device.name, device.uuid);
|
154
|
+
accessory.context.device = device;
|
155
|
+
// See above.
|
156
|
+
this.plejdHandlers.push(new PlejdPlatformAccessoryHandler(this, accessory, device));
|
157
|
+
// link the accessory to your platform
|
158
|
+
this.homebridgeApi.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [
|
159
|
+
accessory,
|
160
|
+
]);
|
161
|
+
if (!this.accessories.find((x) => x.UUID === device.uuid)) {
|
162
|
+
this.accessories.push(accessory);
|
163
|
+
}
|
164
|
+
};
|
165
|
+
onPlejdUpdates = (identifier, isOn, brightness) => {
|
166
|
+
const uuid = this.userInputConfig.devices.find((d) => d.identifier === identifier)?.uuid;
|
167
|
+
if (uuid === undefined) {
|
168
|
+
// Scene or Room, eg: Unused
|
169
|
+
return;
|
170
|
+
}
|
171
|
+
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
172
|
+
const device = this.userInputConfig.devices.find((dev) => dev.identifier === identifier);
|
173
|
+
const plejdHandler = this.plejdHandlers.find((dev) => dev.device.identifier === identifier);
|
174
|
+
if (existingAccessory && device && plejdHandler) {
|
175
|
+
if (device.isDimmer) {
|
176
|
+
const ser = existingAccessory.getService(this.Service.Lightbulb);
|
177
|
+
if (!ser) {
|
178
|
+
this.log.warn("Unable to get service");
|
186
179
|
}
|
187
|
-
|
188
|
-
|
189
|
-
|
180
|
+
const on = ser?.getCharacteristic(this.Characteristic.On);
|
181
|
+
if (!on) {
|
182
|
+
this.log.warn("Unable to get Characteristic [On]");
|
183
|
+
}
|
184
|
+
on?.updateValue(isOn);
|
185
|
+
if (brightness !== undefined) {
|
186
|
+
ser
|
187
|
+
?.getCharacteristic(this.Characteristic.Brightness)
|
188
|
+
.updateValue(brightness);
|
190
189
|
}
|
191
|
-
plejdHandler.updateState(isOn, brightness);
|
192
190
|
}
|
193
191
|
else {
|
194
|
-
|
195
|
-
this.
|
196
|
-
this.
|
197
|
-
|
198
|
-
else {
|
199
|
-
this.log.info('Unable find HomKit device associated with incoming Plejd update |', device);
|
200
|
-
}
|
192
|
+
existingAccessory
|
193
|
+
.getService(this.Service.Switch)
|
194
|
+
?.getCharacteristic(this.Characteristic.On)
|
195
|
+
?.updateValue(isOn);
|
201
196
|
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
197
|
+
plejdHandler.updateState(isOn, brightness);
|
198
|
+
}
|
199
|
+
else {
|
200
|
+
if (device) {
|
201
|
+
this.addNewDevice(device);
|
202
|
+
this.onPlejdUpdates(identifier, isOn, brightness);
|
203
|
+
}
|
204
|
+
else {
|
205
|
+
this.log.info("Unable find HomKit device associated with incoming Plejd update |", device);
|
206
|
+
}
|
207
|
+
}
|
208
|
+
};
|
209
|
+
generateId = (input) => {
|
210
|
+
return this.homebridgeApi.hap.uuid.generate(input);
|
211
|
+
};
|
209
212
|
}
|
210
|
-
exports.PlejdPlatform = PlejdPlatform;
|
211
213
|
//# sourceMappingURL=plejdPlatform.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plejdPlatform.js","sourceRoot":"","sources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AW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;gBAC1B,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,GAAG,CAAC,IAAI,CACX,mEAAmE,EACnE,MAAM,CACP,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE;QAC7C,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC,CAAC;CACH"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { PlatformAccessory } from
|
2
|
-
import { Device } from
|
3
|
-
import { PlejdPlatform } from
|
1
|
+
import { PlatformAccessory } from "homebridge";
|
2
|
+
import { Device } from "./model/device.js";
|
3
|
+
import { PlejdPlatform } from "./plejdPlatform.js";
|
4
4
|
/**
|
5
5
|
* Platform Accessory
|
6
6
|
* An instance of this class is created for each accessory your platform registers
|
@@ -19,4 +19,3 @@ export declare class PlejdPlatformAccessoryHandler {
|
|
19
19
|
private setBrightness;
|
20
20
|
private getBrightness;
|
21
21
|
}
|
22
|
-
//# sourceMappingURL=plejdPlatformAccessory.d.ts.map
|
@@ -1,65 +1,28 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.PlejdPlatformAccessoryHandler = void 0;
|
4
|
-
const settings_1 = require("./settings");
|
1
|
+
import { PLATFORM_NAME } from "./settings.js";
|
5
2
|
/**
|
6
3
|
* Platform Accessory
|
7
4
|
* An instance of this class is created for each accessory your platform registers
|
8
5
|
* Each accessory may expose multiple services of different service types.
|
9
6
|
*/
|
10
|
-
class PlejdPlatformAccessoryHandler {
|
7
|
+
export class PlejdPlatformAccessoryHandler {
|
8
|
+
platform;
|
9
|
+
accessory;
|
10
|
+
device;
|
11
|
+
service;
|
12
|
+
state;
|
11
13
|
constructor(platform, accessory, device) {
|
12
|
-
var _a, _b;
|
13
14
|
this.platform = platform;
|
14
15
|
this.accessory = accessory;
|
15
16
|
this.device = device;
|
16
|
-
this.updateState = (isOn, brightness) => {
|
17
|
-
this.state.isOn = isOn;
|
18
|
-
this.platform.log.debug('updateState | Sending isOn', isOn);
|
19
|
-
this.service
|
20
|
-
.getCharacteristic(this.platform.Characteristic.On)
|
21
|
-
.updateValue(isOn);
|
22
|
-
if (brightness) {
|
23
|
-
this.state.brightness = Math.round(brightness);
|
24
|
-
this.platform.log.debug('update state | Sending brightness', this.state.brightness);
|
25
|
-
this.service
|
26
|
-
.getCharacteristic(this.platform.Characteristic.Brightness)
|
27
|
-
.updateValue(this.state.brightness);
|
28
|
-
}
|
29
|
-
this.accessory.context = this.state;
|
30
|
-
this.platform.log.debug(`State updated | ${JSON.stringify(this.state)}`);
|
31
|
-
};
|
32
|
-
this.setOn = async (value) => {
|
33
|
-
var _a;
|
34
|
-
const newVal = value;
|
35
|
-
this.platform.log.info(`Updating state | ${this.device.name} | to ${newVal ? 'On' : 'off'} | from ${this.state.isOn ? 'On' : 'Off'}`);
|
36
|
-
this.updateState(newVal, this.state.brightness);
|
37
|
-
(_a = this.platform.plejdService) === null || _a === void 0 ? void 0 : _a.updateState(this.device.identifier, newVal, null);
|
38
|
-
};
|
39
|
-
this.getOn = async () => {
|
40
|
-
this.platform.log.debug('Get Characteristic On', this.device.name, this.state.isOn);
|
41
|
-
return this.state.isOn;
|
42
|
-
};
|
43
|
-
this.setBrightness = async (value) => {
|
44
|
-
var _a;
|
45
|
-
const newVal = value; // Number between 1-100
|
46
|
-
this.platform.log.debug(`Updating brightness | ${this.device.name} | to ${newVal} | from ${this.state.brightness}`);
|
47
|
-
this.updateState(this.state.isOn, newVal);
|
48
|
-
(_a = this.platform.plejdService) === null || _a === void 0 ? void 0 : _a.updateState(this.device.identifier, this.state.isOn, newVal);
|
49
|
-
};
|
50
|
-
this.getBrightness = async () => {
|
51
|
-
this.platform.log.debug('Get Characteristic Brightness', this.device.name, this.state.brightness);
|
52
|
-
return this.state.brightness;
|
53
|
-
};
|
54
17
|
platform.log.debug(`Adding handler for a ${this.device.model} with id ${this.device.identifier}`);
|
55
18
|
this.state = {
|
56
|
-
brightness:
|
57
|
-
isOn:
|
19
|
+
brightness: accessory.context.brightness ?? 100,
|
20
|
+
isOn: accessory.context.isOn ?? false,
|
58
21
|
};
|
59
22
|
// set accessory information
|
60
23
|
this.accessory
|
61
24
|
.getService(this.platform.Service.AccessoryInformation)
|
62
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer,
|
25
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, PLATFORM_NAME)
|
63
26
|
.setCharacteristic(this.platform.Characteristic.Model, this.device.model)
|
64
27
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.device.identifier.toString());
|
65
28
|
if (this.device.isDimmer) {
|
@@ -84,6 +47,41 @@ class PlejdPlatformAccessoryHandler {
|
|
84
47
|
.onGet(this.getOn.bind(this));
|
85
48
|
this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
|
86
49
|
}
|
50
|
+
updateState = (isOn, brightness) => {
|
51
|
+
this.state.isOn = isOn;
|
52
|
+
this.platform.log.debug("updateState | Sending isOn", isOn);
|
53
|
+
this.service
|
54
|
+
.getCharacteristic(this.platform.Characteristic.On)
|
55
|
+
.updateValue(isOn);
|
56
|
+
if (brightness) {
|
57
|
+
this.state.brightness = Math.round(brightness);
|
58
|
+
this.platform.log.debug("update state | Sending brightness", this.state.brightness);
|
59
|
+
this.service
|
60
|
+
.getCharacteristic(this.platform.Characteristic.Brightness)
|
61
|
+
.updateValue(this.state.brightness);
|
62
|
+
}
|
63
|
+
this.accessory.context = this.state;
|
64
|
+
this.platform.log.debug(`State updated | ${JSON.stringify(this.state)}`);
|
65
|
+
};
|
66
|
+
setOn = async (value) => {
|
67
|
+
const newVal = value;
|
68
|
+
this.platform.log.info(`Updating state | ${this.device.name} | to ${newVal ? "On" : "off"} | from ${this.state.isOn ? "On" : "Off"}`);
|
69
|
+
this.updateState(newVal, this.state.brightness);
|
70
|
+
this.platform.plejdService?.updateState(this.device.identifier, newVal, null);
|
71
|
+
};
|
72
|
+
getOn = async () => {
|
73
|
+
this.platform.log.debug("Get Characteristic On", this.device.name, this.state.isOn);
|
74
|
+
return this.state.isOn;
|
75
|
+
};
|
76
|
+
setBrightness = async (value) => {
|
77
|
+
const newVal = value; // Number between 1-100
|
78
|
+
this.platform.log.debug(`Updating brightness | ${this.device.name} | to ${newVal} | from ${this.state.brightness}`);
|
79
|
+
this.updateState(this.state.isOn, newVal);
|
80
|
+
this.platform.plejdService?.updateState(this.device.identifier, this.state.isOn, newVal);
|
81
|
+
};
|
82
|
+
getBrightness = async () => {
|
83
|
+
this.platform.log.debug("Get Characteristic Brightness", this.device.name, this.state.brightness);
|
84
|
+
return this.state.brightness;
|
85
|
+
};
|
87
86
|
}
|
88
|
-
exports.PlejdPlatformAccessoryHandler = PlejdPlatformAccessoryHandler;
|
89
87
|
//# sourceMappingURL=plejdPlatformAccessory.js.map
|