homebridge-plejd 1.7.0-beta-1 → 1.7.0
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/CHANGELOG.md +3 -6
- package/README.md +6 -0
- package/config.schema.json +7 -0
- package/dist/PlejdHbAccessory.d.ts +3 -5
- package/dist/PlejdHbAccessory.js +9 -29
- package/dist/PlejdHbAccessory.js.map +1 -1
- package/dist/PlejdHbPlatform.d.ts +1 -0
- package/dist/PlejdHbPlatform.js +9 -6
- package/dist/PlejdHbPlatform.js.map +1 -1
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +14 -10
- package/dist/constants.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +2 -1
- package/dist/utils.js.map +1 -1
- package/package.json +3 -2
- package/tests/plejdService.spec.ts +30 -21
package/CHANGELOG.md
CHANGED
@@ -1,13 +1,10 @@
|
|
1
|
-
#### 1.7.0
|
2
|
-
|
3
|
-
Migrated to characteristict SetDuration
|
4
|
-
|
5
|
-
#### 1.7.0-beta(2025-09-11)
|
1
|
+
#### 1.7.0 (2025-09-19)
|
6
2
|
|
3
|
+
Reduced message timeout for BLE commands
|
7
4
|
Update filter for finding lights
|
8
5
|
Refactorings
|
9
6
|
Added tests
|
10
|
-
Added opt-in brightness transition
|
7
|
+
Added opt-in brightness transition when light is on
|
11
8
|
|
12
9
|
#### 1.6.2(2024-12-24)
|
13
10
|
|
package/README.md
CHANGED
@@ -60,10 +60,16 @@ Device info can be found like [this](./docs/Device%20Info.md)!
|
|
60
60
|
|
61
61
|
### Notes
|
62
62
|
|
63
|
+
I'm maintaining this plugin on my spare time and I use it daily. Though I do not have much time due to children and life. Feel free to help out in any way.
|
64
|
+
|
63
65
|
This plugin lacks testing for multiple platforms. Feel free to test on your system. The main dependency [@abandonware/Noble](https://github.com/abandonware/noble) is your guide in case of your separate system. Usually BLE is the problem.
|
64
66
|
|
65
67
|
Feel free to open a ticket if you can't get it working.
|
66
68
|
|
69
|
+
The underlying protocol is relying on the BLE address to be exposed. This is not available on mac, meaning this app won't work on mac for now. There might be workarounds for this.
|
70
|
+
|
71
|
+
I do not own all hardware from Plejd, this means I have not been able to make sure that it all works. However, feel free to add a PR. I'd like to add switches and sensors, this is not yet available as I do not own any of these.
|
72
|
+
|
67
73
|
## Thanks
|
68
74
|
|
69
75
|
Big thanks to:
|
package/config.schema.json
CHANGED
@@ -33,6 +33,13 @@
|
|
33
33
|
"placeholder": "828291.. or 82-82-91...",
|
34
34
|
"description": "With or without '-' "
|
35
35
|
},
|
36
|
+
"transition_ms": {
|
37
|
+
"title": "Add transition when changing brightness levels (Note: Not for on/off to reduce flickering with button actions)",
|
38
|
+
"type": "number",
|
39
|
+
"required": false,
|
40
|
+
"placeholder": "1000",
|
41
|
+
"description": "Amount of milliseconds of transitioning brightness"
|
42
|
+
},
|
36
43
|
"devices": {
|
37
44
|
"type": "array",
|
38
45
|
"items": {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { PlatformAccessory
|
1
|
+
import { PlatformAccessory } from "homebridge";
|
2
2
|
import { Device } from "./model/device.js";
|
3
3
|
import { PlejdHbPlatform } from "./PlejdHbPlatform.js";
|
4
4
|
/**
|
@@ -8,17 +8,15 @@ import { PlejdHbPlatform } from "./PlejdHbPlatform.js";
|
|
8
8
|
*/
|
9
9
|
export declare class PlejdHbAccessory {
|
10
10
|
private readonly platform;
|
11
|
-
private readonly log;
|
12
11
|
private readonly accessory;
|
13
12
|
readonly device: Device;
|
13
|
+
private readonly transitionMs;
|
14
14
|
private service;
|
15
15
|
private state;
|
16
|
-
constructor(platform: PlejdHbPlatform,
|
16
|
+
constructor(platform: PlejdHbPlatform, accessory: PlatformAccessory, device: Device, transitionMs: number);
|
17
17
|
onPlejdUpdates: (isOn: boolean, brightness?: number) => void;
|
18
18
|
private setOn;
|
19
19
|
private getOn;
|
20
20
|
private setBrightness;
|
21
21
|
private getBrightness;
|
22
|
-
private setTransitionDuration;
|
23
|
-
private getTransitionDuration;
|
24
22
|
}
|
package/dist/PlejdHbAccessory.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { PLATFORM_NAME } from "./constants.js";
|
2
2
|
/**
|
3
3
|
* Platform Accessory
|
4
4
|
* An instance of this class is created for each accessory your platform registers
|
@@ -6,20 +6,20 @@ import { DEFAULT_BRIGHTNESS_TRANSITION_MS, PLATFORM_NAME, } from "./constants.js
|
|
6
6
|
*/
|
7
7
|
export class PlejdHbAccessory {
|
8
8
|
platform;
|
9
|
-
log;
|
10
9
|
accessory;
|
11
10
|
device;
|
11
|
+
transitionMs;
|
12
12
|
service;
|
13
13
|
state;
|
14
|
-
constructor(platform,
|
14
|
+
constructor(platform, accessory, device, transitionMs) {
|
15
15
|
this.platform = platform;
|
16
|
-
this.log = log;
|
17
16
|
this.accessory = accessory;
|
18
17
|
this.device = device;
|
18
|
+
this.transitionMs = transitionMs;
|
19
19
|
this.state = {
|
20
20
|
brightness: accessory.context.brightness ?? 100,
|
21
21
|
isOn: accessory.context.isOn ?? false,
|
22
|
-
|
22
|
+
transitionMs,
|
23
23
|
};
|
24
24
|
// set accessory information
|
25
25
|
this.accessory
|
@@ -28,20 +28,9 @@ export class PlejdHbAccessory {
|
|
28
28
|
.setCharacteristic(this.platform.Characteristic.Model, this.device.model)
|
29
29
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.device.identifier.toString());
|
30
30
|
if (this.device.isDimmer) {
|
31
|
-
// get the LightBulb service if it exists, otherwise create a new LightBulb service
|
32
31
|
this.service =
|
33
32
|
this.accessory.getService(this.platform.Service.Lightbulb) ||
|
34
33
|
this.accessory.addService(this.platform.Service.Lightbulb);
|
35
|
-
const durationChar = this.service.getCharacteristic(this.platform.Characteristic.SetDuration) ||
|
36
|
-
this.service.addCharacteristic(this.platform.Characteristic.SetDuration);
|
37
|
-
durationChar
|
38
|
-
.setProps({
|
39
|
-
minValue: 0,
|
40
|
-
maxValue: 3600000,
|
41
|
-
minStep: 100,
|
42
|
-
})
|
43
|
-
.onSet(this.setTransitionDuration.bind(this))
|
44
|
-
.onGet(this.getTransitionDuration.bind(this));
|
45
34
|
this.service
|
46
35
|
.getCharacteristic(this.platform.Characteristic.Brightness)
|
47
36
|
.onGet(this.getBrightness.bind(this))
|
@@ -75,9 +64,9 @@ export class PlejdHbAccessory {
|
|
75
64
|
};
|
76
65
|
setOn = async (value) => {
|
77
66
|
const newState = value;
|
78
|
-
this.log.
|
67
|
+
this.platform.log.debug(`Homekit: turning ${value === true ? "on" : "off"} ${this.device.name} (current state: isOn=${this.state.isOn}, brightness=${this.state.brightness})`);
|
79
68
|
if (this.state.isOn === newState) {
|
80
|
-
this.log.debug(`${this.device.name} already ${newState ? "on" : "off"}, skipping`);
|
69
|
+
this.platform.log.debug(`${this.device.name} already ${newState ? "on" : "off"}, skipping`);
|
81
70
|
return;
|
82
71
|
}
|
83
72
|
await this.platform.plejdService?.updateState(this.device.identifier, value);
|
@@ -85,24 +74,15 @@ export class PlejdHbAccessory {
|
|
85
74
|
};
|
86
75
|
getOn = () => this.state.isOn;
|
87
76
|
setBrightness = async (value) => {
|
88
|
-
this.log.debug(`Homekit: Set brightness of ${this.device.name} to ${value}`);
|
89
|
-
const transitionMs = this.state.transitionDuration > 0
|
90
|
-
? this.state.transitionDuration
|
91
|
-
: DEFAULT_BRIGHTNESS_TRANSITION_MS;
|
77
|
+
this.platform.log.debug(`Homekit: Set brightness of ${this.device.name} to ${value}`);
|
92
78
|
await this.platform.plejdService?.updateState(this.device.identifier, true, {
|
93
79
|
targetBrightness: value,
|
94
80
|
currentBrightness: this.state.brightness,
|
95
|
-
transitionMs,
|
81
|
+
transitionMs: this.transitionMs,
|
96
82
|
});
|
97
83
|
this.state.brightness = value;
|
98
84
|
this.state.isOn = true;
|
99
85
|
};
|
100
86
|
getBrightness = () => this.state.brightness;
|
101
|
-
setTransitionDuration = async (value) => {
|
102
|
-
this.state.transitionDuration = value;
|
103
|
-
this.accessory.context.transitionDuration = this.state.transitionDuration;
|
104
|
-
this.log.debug(`Set transition duration for ${this.device.name} to ${value}ms`);
|
105
|
-
};
|
106
|
-
getTransitionDuration = () => this.state.transitionDuration;
|
107
87
|
}
|
108
88
|
//# sourceMappingURL=PlejdHbAccessory.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PlejdHbAccessory.js","sourceRoot":"","sources":["../src/PlejdHbAccessory.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"PlejdHbAccessory.js","sourceRoot":"","sources":["../src/PlejdHbAccessory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAQ/C;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAKR;IACA;IACD;IACC;IAPX,OAAO,CAAU;IACjB,KAAK,CAAc;IAE3B,YACmB,QAAyB,EACzB,SAA4B,EAC7B,MAAc,EACb,YAAoB;QAHpB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,cAAS,GAAT,SAAS,CAAmB;QAC7B,WAAM,GAAN,MAAM,CAAQ;QACb,iBAAY,GAAZ,YAAY,CAAQ;QAErC,IAAI,CAAC,KAAK,GAAG;YACX,UAAU,EAAE,SAAS,CAAC,OAAO,CAAC,UAAU,IAAI,GAAG;YAC/C,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK;YACrC,YAAY;SACb,CAAC;QAEF,4BAA4B;QAC5B,IAAI,CAAC,SAAS;aACX,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACvD,iBAAiB,CAChB,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EACzC,aAAa,CACd;aACA,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;aACxE,iBAAiB,CAChB,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,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M,CAAC,IAAI,YAAY,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,YAAY,CACnE,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAC3C,IAAI,CAAC,MAAM,CAAC,UAAU,EACtB,KAAgB,CACjB,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAgB,CAAC;IACrC,CAAC,CAAC;IAEM,KAAK,GAAG,GAAwB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAEnD,aAAa,GAAG,KAAK,EAAE,KAA0B,EAAE,EAAE;QAC3D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CACrB,8BAA8B,IAAI,CAAC,MAAM,CAAC,IAAI,OAAO,KAAK,EAAE,CAC7D,CAAC;QACF,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAC3C,IAAI,CAAC,MAAM,CAAC,UAAU,EACtB,IAAI,EACJ;YACE,gBAAgB,EAAE,KAAe;YACjC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;YACxC,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CACF,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,KAAe,CAAC;QACxC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;IACzB,CAAC,CAAC;IAEM,aAAa,GAAG,GAAwB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;CAC1E"}
|
@@ -14,6 +14,7 @@ export declare class PlejdHbPlatform implements DynamicPlatformPlugin {
|
|
14
14
|
plejdService?: PlejdService;
|
15
15
|
readonly accessories: PlatformAccessory[];
|
16
16
|
readonly plejdHbAccessories: PlejdHbAccessory[];
|
17
|
+
private readonly transitionMs;
|
17
18
|
constructor(log: Logger, config: PlatformConfig, homebridgeApi: API);
|
18
19
|
configurePlejd: () => Promise<void>;
|
19
20
|
configureDevices: (log: Logger, config: PlatformConfig, site?: Site) => void;
|
package/dist/PlejdHbPlatform.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { PLATFORM_NAME, PLUGIN_NAME } from "./constants.js";
|
2
|
-
import { isDimmable, isAddon } from "./utils.js";
|
1
|
+
import { DEFAULT_BRIGHTNESS_TRANSITION_MS, PLATFORM_NAME, PLUGIN_NAME, } from "./constants.js";
|
2
|
+
import { isDimmable, isAddon, isSwitch } from "./utils.js";
|
3
3
|
import { PlejdHbAccessory } from "./PlejdHbAccessory.js";
|
4
4
|
import { PlejdService } from "./plejdService.js";
|
5
5
|
import PlejdRemoteApi from "./plejdApi.js";
|
@@ -14,6 +14,7 @@ export class PlejdHbPlatform {
|
|
14
14
|
// this is used to track restored cached accessories
|
15
15
|
accessories = [];
|
16
16
|
plejdHbAccessories = [];
|
17
|
+
transitionMs;
|
17
18
|
constructor(log, config, homebridgeApi) {
|
18
19
|
this.log = log;
|
19
20
|
this.config = config;
|
@@ -21,6 +22,8 @@ export class PlejdHbPlatform {
|
|
21
22
|
homebridgeApi.on("didFinishLaunching", this.configurePlejd);
|
22
23
|
this.Characteristic = homebridgeApi.hap.Characteristic;
|
23
24
|
this.Service = homebridgeApi.hap.Service;
|
25
|
+
this.transitionMs =
|
26
|
+
config.transition_ms ?? DEFAULT_BRIGHTNESS_TRANSITION_MS;
|
24
27
|
}
|
25
28
|
configurePlejd = async () => {
|
26
29
|
if (this.config.password && this.config.site && this.config.username) {
|
@@ -50,8 +53,8 @@ export class PlejdHbPlatform {
|
|
50
53
|
const id = device.deviceId;
|
51
54
|
const plejdDevice = site.plejdDevices.find((x) => x.deviceId === id);
|
52
55
|
const model = plejdDevice.firmware.notes;
|
53
|
-
if (isAddon(model)) {
|
54
|
-
this.log.info(`Ignoring ${model} as it is not supported for now`);
|
56
|
+
if (isAddon(model) || isSwitch(model)) {
|
57
|
+
this.log.info(`Ignoring ${model} as it is not supported for now, help with this is needed`);
|
55
58
|
return;
|
56
59
|
}
|
57
60
|
const room = site.rooms.find((x) => x.roomId === device.roomId);
|
@@ -126,7 +129,7 @@ export class PlejdHbPlatform {
|
|
126
129
|
}
|
127
130
|
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === device.uuid);
|
128
131
|
if (existingAccessory) {
|
129
|
-
this.plejdHbAccessories.push(new PlejdHbAccessory(this,
|
132
|
+
this.plejdHbAccessories.push(new PlejdHbAccessory(this, existingAccessory, device, this.transitionMs));
|
130
133
|
}
|
131
134
|
else {
|
132
135
|
this.addNewDevice(device);
|
@@ -137,7 +140,7 @@ export class PlejdHbPlatform {
|
|
137
140
|
const accessory = new this.homebridgeApi.platformAccessory(device.name, device.uuid);
|
138
141
|
accessory.context.device = device;
|
139
142
|
// See above.
|
140
|
-
this.plejdHbAccessories.push(new PlejdHbAccessory(this,
|
143
|
+
this.plejdHbAccessories.push(new PlejdHbAccessory(this, accessory, device, this.transitionMs));
|
141
144
|
// link the accessory to your platform
|
142
145
|
this.homebridgeApi.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [
|
143
146
|
accessory,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PlejdHbPlatform.js","sourceRoot":"","sources":["../src/PlejdHbPlatform.ts"],"names":[],"mappings":"AAUA,OAAO,
|
1
|
+
{"version":3,"file":"PlejdHbPlatform.js","sourceRoot":"","sources":["../src/PlejdHbPlatform.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,gCAAgC,EAChC,aAAa,EACb,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,cAAc,MAAM,eAAe,CAAC;AAG3C,MAAM,OAA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,iBAAiB;qBACd,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;oBAChC,EAAE,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;oBAC3C,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;YAED,gBAAgB,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACpD,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;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"}
|
package/dist/constants.d.ts
CHANGED
@@ -6,11 +6,12 @@ export declare const PLATFORM_NAME = "Plejd";
|
|
6
6
|
* This must match the name of your plugin as defined the package.json
|
7
7
|
*/
|
8
8
|
export declare const PLUGIN_NAME = "homebridge-plejd";
|
9
|
-
export declare const PLEJD_WRITE_TIMEOUT =
|
9
|
+
export declare const PLEJD_WRITE_TIMEOUT = 50;
|
10
10
|
export declare const PLEJD_PING_TIMEOUT = 3000;
|
11
11
|
export declare const DEFAULT_BRIGHTNESS_TRANSITION_MS = 0;
|
12
12
|
/**
|
13
13
|
* Lights and switches from Plejd
|
14
14
|
*/
|
15
15
|
export declare const PLEJD_LIGHTS: string[];
|
16
|
+
export declare const PLEJD_SWITCHES: string[];
|
16
17
|
export declare const PLEJD_ADDONS: string[];
|
package/dist/constants.js
CHANGED
@@ -6,22 +6,24 @@ export const PLATFORM_NAME = "Plejd";
|
|
6
6
|
* This must match the name of your plugin as defined the package.json
|
7
7
|
*/
|
8
8
|
export const PLUGIN_NAME = "homebridge-plejd";
|
9
|
-
export const PLEJD_WRITE_TIMEOUT =
|
9
|
+
export const PLEJD_WRITE_TIMEOUT = 50;
|
10
10
|
export const PLEJD_PING_TIMEOUT = 3000;
|
11
11
|
export const DEFAULT_BRIGHTNESS_TRANSITION_MS = 0;
|
12
12
|
/**
|
13
13
|
* Lights and switches from Plejd
|
14
14
|
*/
|
15
15
|
export const PLEJD_LIGHTS = ["DIM-01", "DIM-02", "LED-10", "LED-75"];
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
export const PLEJD_SWITCHES = [
|
17
|
+
"REL-01",
|
18
|
+
"REL-02",
|
19
|
+
"REL-01-2P",
|
20
|
+
"DAL-01",
|
21
|
+
"SPR-01",
|
22
|
+
"SPD-01",
|
23
|
+
"CTR-01",
|
24
|
+
];
|
24
25
|
export const PLEJD_ADDONS = [
|
26
|
+
"DAL-01",
|
25
27
|
"RTR-01",
|
26
28
|
"WPH-01",
|
27
29
|
"WRT-01",
|
@@ -30,6 +32,8 @@ export const PLEJD_ADDONS = [
|
|
30
32
|
"GWY-01",
|
31
33
|
"BAT-01",
|
32
34
|
"EXT-01",
|
33
|
-
"
|
35
|
+
"WMS-01",
|
36
|
+
"JAL-01",
|
37
|
+
"TRM-01",
|
34
38
|
];
|
35
39
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAClD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;CACT,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;CACT,CAAC"}
|
package/dist/utils.d.ts
CHANGED
@@ -4,3 +4,4 @@ export declare const plejdChallageResp: (key: Buffer, chal: Buffer) => Buffer;
|
|
4
4
|
export declare const plejdEncodeDecode: (key: Buffer, addressBuffer: Buffer, data: Buffer) => Buffer;
|
5
5
|
export declare const isDimmable: (type: string) => boolean;
|
6
6
|
export declare const isAddon: (type: string) => boolean;
|
7
|
+
export declare const isSwitch: (type: string) => boolean;
|
package/dist/utils.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { createCipheriv, createHash } from "crypto";
|
2
|
-
import { PLEJD_LIGHTS, PLEJD_ADDONS } from "./constants.js";
|
2
|
+
import { PLEJD_LIGHTS, PLEJD_ADDONS, PLEJD_SWITCHES } from "./constants.js";
|
3
3
|
export const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
4
4
|
/*
|
5
5
|
* Set a timeout for a function
|
@@ -42,6 +42,7 @@ export const isDimmable = (type) => {
|
|
42
42
|
normalizedType.includes("dim"));
|
43
43
|
};
|
44
44
|
export const isAddon = (type) => !!PLEJD_ADDONS.find((addon) => type.toLowerCase().includes(addon.toLowerCase()));
|
45
|
+
export const isSwitch = (type) => !!PLEJD_SWITCHES.find((switchType) => type.toLowerCase().includes(switchType.toLowerCase()));
|
45
46
|
const xor = (first, second) => {
|
46
47
|
const result = Buffer.alloc(first.length);
|
47
48
|
for (let i = 0; i < first.length; i++) {
|
package/dist/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE5E,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAClC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EACvB,SAA2B,EAC3B,SAAS,GAAG,IAAI,EACJ,EAAE;IACd,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,SAAS,EAAE;QACX,IAAI,OAAO,CAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAC3B,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CA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,CAAC;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"displayName": "Plejd",
|
4
4
|
"name": "homebridge-plejd",
|
5
5
|
"author": "Herlix",
|
6
|
-
"version": "1.7.0
|
6
|
+
"version": "1.7.0",
|
7
7
|
"description": "HomeKit support for the Plejd BLE platform using Homebridge",
|
8
8
|
"license": "Apache-2.0",
|
9
9
|
"type": "module",
|
@@ -24,7 +24,8 @@
|
|
24
24
|
"dev": "npm run build && npm link && nodemon",
|
25
25
|
"build": "rimraf ./dist && tsc",
|
26
26
|
"prepublishOnly": "npm run lint && npm run build",
|
27
|
-
"test": "jest ./**/*.spec.* --detectOpenHandles --forceExit --silent=false"
|
27
|
+
"test": "jest ./**/*.spec.* --detectOpenHandles --forceExit --silent=false",
|
28
|
+
"test:watch": "jest ./**/*.spec.* --detectOpenHandles --forceExit --silent=false --watch"
|
28
29
|
},
|
29
30
|
"keywords": [
|
30
31
|
"homebridge-plugin",
|
@@ -16,14 +16,19 @@ describe("PlejdService updateState", () => {
|
|
16
16
|
);
|
17
17
|
});
|
18
18
|
|
19
|
-
describe("Turn off scenarios", () => {
|
19
|
+
describe("Turn on/off scenarios", () => {
|
20
20
|
it.each([
|
21
21
|
["isOn=false, brightness=undefined", false, undefined],
|
22
22
|
["isOn=false, brightness=0", false, 0],
|
23
23
|
["isOn=true, brightness=0", true, 0],
|
24
24
|
["isOn=true, brightness=undefined", true, undefined],
|
25
|
+
["isOn=true, brightness=0", true, 0],
|
26
|
+
// ["isOn=true, brightness=1 (Not needed due to brightness change)", true, 1],
|
25
27
|
])("%s should queue a turn off command", async (_, isOn, brightness) => {
|
26
28
|
const deviceId = 42;
|
29
|
+
const refQueue = service.readQueue();
|
30
|
+
expect(refQueue.length).toBe(0);
|
31
|
+
|
27
32
|
await service.updateState(deviceId, isOn, {
|
28
33
|
targetBrightness: brightness,
|
29
34
|
});
|
@@ -36,7 +41,7 @@ describe("PlejdService updateState", () => {
|
|
36
41
|
deviceId.toString(16).padStart(2, "0") +
|
37
42
|
PlejdCommand.RequestNoResponse +
|
38
43
|
PlejdCommand.OnOffState +
|
39
|
-
"00";
|
44
|
+
(isOn ? "01" : "00");
|
40
45
|
|
41
46
|
expect(command).toBe(expected);
|
42
47
|
});
|
@@ -50,7 +55,7 @@ describe("PlejdService updateState", () => {
|
|
50
55
|
await service.updateState(deviceId, true, {
|
51
56
|
currentBrightness: brightness,
|
52
57
|
targetBrightness: brightness,
|
53
|
-
|
58
|
+
transitionMs: transitionMS,
|
54
59
|
});
|
55
60
|
const queue = service.readQueue();
|
56
61
|
expect(queue.length).toBe(0);
|
@@ -58,21 +63,21 @@ describe("PlejdService updateState", () => {
|
|
58
63
|
|
59
64
|
it("should queue multiple brightness commands for a transition", async () => {
|
60
65
|
const deviceId = 42;
|
61
|
-
const
|
62
|
-
const
|
66
|
+
const currentBrightness = 10;
|
67
|
+
const targetBrightness = 70;
|
68
|
+
const transitionMs = 500;
|
63
69
|
|
64
70
|
await service.updateState(deviceId, true, {
|
65
|
-
targetBrightness
|
66
|
-
|
71
|
+
targetBrightness,
|
72
|
+
currentBrightness,
|
73
|
+
transitionMs,
|
67
74
|
});
|
68
75
|
|
69
76
|
const queue = service.readQueue();
|
70
77
|
|
71
|
-
|
72
|
-
const expectedSteps = Math.round(transitionMS / PLEJD_WRITE_TIMEOUT);
|
78
|
+
const expectedSteps = Math.round(transitionMs / PLEJD_WRITE_TIMEOUT);
|
73
79
|
expect(queue.length).toBe(expectedSteps);
|
74
80
|
|
75
|
-
// Check that all commands are brightness commands
|
76
81
|
queue.forEach((item) => {
|
77
82
|
const command = item.toString("hex");
|
78
83
|
expect(command.substring(2, 6)).toBe(PlejdCommand.RequestNoResponse);
|
@@ -80,16 +85,22 @@ describe("PlejdService updateState", () => {
|
|
80
85
|
expect(command.substring(10, 14)).toBe("0100"); // isOn = true
|
81
86
|
});
|
82
87
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
+
for (let step = 1; step <= expectedSteps; step++) {
|
89
|
+
const brightnessDifference = targetBrightness - currentBrightness;
|
90
|
+
const currentStepBrightness = Math.min(
|
91
|
+
100,
|
92
|
+
Math.max(
|
93
|
+
0,
|
94
|
+
currentBrightness + (brightnessDifference * step) / expectedSteps,
|
95
|
+
),
|
96
|
+
);
|
97
|
+
const eightBitBrightness = Math.round(currentStepBrightness * 2.55);
|
98
|
+
const item = queue[expectedSteps - step];
|
88
99
|
const command = item.toString("hex");
|
89
100
|
const brightnessHex = command.substring(14, 18);
|
90
101
|
const brightnessValue = parseInt(brightnessHex, 16);
|
91
|
-
expect(brightnessValue).toBe(
|
92
|
-
}
|
102
|
+
expect(brightnessValue).toBe(eightBitBrightness);
|
103
|
+
}
|
93
104
|
});
|
94
105
|
|
95
106
|
it("should handle a 1-second transition with default parameters", async () => {
|
@@ -98,13 +109,11 @@ describe("PlejdService updateState", () => {
|
|
98
109
|
|
99
110
|
await service.updateState(deviceId, true, {
|
100
111
|
targetBrightness: brightness,
|
101
|
-
|
112
|
+
transitionMs: 1000,
|
102
113
|
});
|
103
114
|
const queue = service.readQueue();
|
104
115
|
|
105
|
-
|
106
|
-
const expectedSteps = 10;
|
107
|
-
expect(queue.length).toBe(expectedSteps);
|
116
|
+
expect(queue.length).toBe(1000 / PLEJD_WRITE_TIMEOUT);
|
108
117
|
});
|
109
118
|
|
110
119
|
it("should handle a 0-ms transition with default parameters", async () => {
|