@switchbot/homebridge-switchbot 2.5.0-beta.0 → 2.5.0-beta.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/config.schema.json +1 -1
- package/dist/device/blindtilt.d.ts +3 -5
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +46 -164
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +1 -5
- package/dist/device/curtain.js.map +1 -1
- package/dist/settings.d.ts +24 -18
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +2 -2
- package/src/device/blindtilt.ts +48 -166
- package/src/device/curtain.ts +1 -5
- package/src/settings.ts +39 -64
package/src/device/blindtilt.ts
CHANGED
|
@@ -21,7 +21,7 @@ export class BlindTilt {
|
|
|
21
21
|
CurrentPosition!: CharacteristicValue;
|
|
22
22
|
PositionState!: CharacteristicValue;
|
|
23
23
|
TargetPosition!: CharacteristicValue;
|
|
24
|
-
BatteryLevel
|
|
24
|
+
BatteryLevel!: CharacteristicValue;
|
|
25
25
|
StatusLowBattery?: CharacteristicValue;
|
|
26
26
|
CurrentHorizontalTiltAngle!: CharacteristicValue;
|
|
27
27
|
TargetHorizontalTiltAngle!: CharacteristicValue;
|
|
@@ -30,9 +30,8 @@ export class BlindTilt {
|
|
|
30
30
|
deviceStatus!: any; //deviceStatusResponse;
|
|
31
31
|
slidePosition: deviceStatus['slidePosition'];
|
|
32
32
|
moving: deviceStatus['moving'];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Mode!: string;
|
|
33
|
+
Battery: deviceStatus['battery'];
|
|
34
|
+
direction: deviceStatus['direction'];
|
|
36
35
|
|
|
37
36
|
// BLE Others
|
|
38
37
|
connected?: boolean;
|
|
@@ -137,6 +136,8 @@ export class BlindTilt {
|
|
|
137
136
|
.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
138
137
|
.setProps({
|
|
139
138
|
minStep: this.minStep(device),
|
|
139
|
+
minValue: 0,
|
|
140
|
+
maxValue: 100,
|
|
140
141
|
validValueRanges: [0, 100],
|
|
141
142
|
})
|
|
142
143
|
.onSet(this.TargetPositionSet.bind(this));
|
|
@@ -144,9 +145,10 @@ export class BlindTilt {
|
|
|
144
145
|
this.windowCoveringService
|
|
145
146
|
.getCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle)
|
|
146
147
|
.setProps({
|
|
147
|
-
minStep:
|
|
148
|
+
minStep: 180,
|
|
148
149
|
minValue: -90,
|
|
149
150
|
maxValue: 90,
|
|
151
|
+
validValues: [-90, 90],
|
|
150
152
|
validValueRanges: [-90, 90],
|
|
151
153
|
})
|
|
152
154
|
.onGet(() => {
|
|
@@ -156,9 +158,10 @@ export class BlindTilt {
|
|
|
156
158
|
this.windowCoveringService
|
|
157
159
|
.getCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle)
|
|
158
160
|
.setProps({
|
|
159
|
-
minStep:
|
|
161
|
+
minStep: 180,
|
|
160
162
|
minValue: -90,
|
|
161
163
|
maxValue: 90,
|
|
164
|
+
validValues: [-90, 90],
|
|
162
165
|
validValueRanges: [-90, 90],
|
|
163
166
|
})
|
|
164
167
|
.onSet(this.TargetHorizontalTiltAngleSet.bind(this));
|
|
@@ -278,46 +281,6 @@ export class BlindTilt {
|
|
|
278
281
|
`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},` +
|
|
279
282
|
` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState},`,
|
|
280
283
|
);
|
|
281
|
-
// CurrentHorizontalTiltAngle
|
|
282
|
-
this.CurrentHorizontalTiltAngle = 100 - Number(this.position);
|
|
283
|
-
await this.setMinMax();
|
|
284
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentHorizontalTiltAngle ${this.CurrentHorizontalTiltAngle}`);
|
|
285
|
-
if (this.setNewTarget) {
|
|
286
|
-
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Checking Status ...`);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (this.setNewTarget && this.inMotion) {
|
|
290
|
-
await this.setMinMax();
|
|
291
|
-
if (this.TargetHorizontalTiltAngle > this.CurrentHorizontalTiltAngle) {
|
|
292
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Closing,`+
|
|
293
|
-
` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
294
|
-
this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
|
|
295
|
-
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
|
|
296
|
-
this.debugLog(`${this.device.deviceType}: ${this.CurrentHorizontalTiltAngle} INCREASING PositionState: ${this.PositionState}`);
|
|
297
|
-
} else if (this.TargetHorizontalTiltAngle < this.CurrentHorizontalTiltAngle) {
|
|
298
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Opening,`+
|
|
299
|
-
` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
300
|
-
this.PositionState = this.platform.Characteristic.PositionState.DECREASING;
|
|
301
|
-
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
|
|
302
|
-
this.debugLog(`${this.device.deviceType}: ${this.CurrentHorizontalTiltAngle} DECREASING PositionState: ${this.PositionState}`);
|
|
303
|
-
} else {
|
|
304
|
-
this.debugLog(`${this.device.deviceType}: ${this.CurrentHorizontalTiltAngle} Standby,`+
|
|
305
|
-
` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
306
|
-
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
307
|
-
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
|
|
308
|
-
this.debugLog(`${this.device.deviceType}: ${this.CurrentHorizontalTiltAngle} STOPPED PositionState: ${this.PositionState}`);
|
|
309
|
-
}
|
|
310
|
-
} else {
|
|
311
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Standby,`+
|
|
312
|
-
` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
313
|
-
this.TargetHorizontalTiltAngle = this.CurrentHorizontalTiltAngle;
|
|
314
|
-
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
315
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Stopped`);
|
|
316
|
-
}
|
|
317
|
-
this.debugLog(
|
|
318
|
-
`${this.device.deviceType}: ${this.accessory.displayName} CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle},` +
|
|
319
|
-
` TargetHorizontalTiltAngle: ${this.TargetHorizontalTiltAngle}, PositionState: ${this.PositionState},`,
|
|
320
|
-
);
|
|
321
284
|
|
|
322
285
|
// Battery
|
|
323
286
|
this.BatteryLevel = Number(this.battery);
|
|
@@ -364,49 +327,17 @@ export class BlindTilt {
|
|
|
364
327
|
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
365
328
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Stopped`);
|
|
366
329
|
}
|
|
367
|
-
this.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
// CurrentHorizontalTiltAngle
|
|
372
|
-
this.CurrentHorizontalTiltAngle = 100 - Number(this.slidePosition);
|
|
373
|
-
await this.setMinMax();
|
|
374
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
375
|
-
if (this.setNewTarget) {
|
|
376
|
-
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Checking Status ...`);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (this.setNewTarget && this.moving) {
|
|
380
|
-
await this.setMinMax();
|
|
381
|
-
if (this.TargetHorizontalTiltAngle > this.CurrentHorizontalTiltAngle) {
|
|
382
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Closing,`
|
|
383
|
-
+ ` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle} `);
|
|
384
|
-
this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
|
|
385
|
-
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
|
|
386
|
-
this.debugLog(`${this.device.deviceType}: ${this.CurrentHorizontalTiltAngle} INCREASING PositionState: ${this.PositionState}`);
|
|
387
|
-
} else if (this.TargetHorizontalTiltAngle < this.CurrentHorizontalTiltAngle) {
|
|
388
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Opening,`
|
|
389
|
-
+ ` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle} `);
|
|
390
|
-
this.PositionState = this.platform.Characteristic.PositionState.DECREASING;
|
|
391
|
-
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
|
|
392
|
-
this.debugLog(`${this.device.deviceType}: ${this.CurrentHorizontalTiltAngle} DECREASING PositionState: ${this.PositionState}`);
|
|
393
|
-
} else {
|
|
394
|
-
this.debugLog(`${this.device.deviceType}: ${this.CurrentHorizontalTiltAngle} Standby,`
|
|
395
|
-
+ ` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
396
|
-
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
397
|
-
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
|
|
398
|
-
this.debugLog(`${this.device.deviceType}: ${this.CurrentHorizontalTiltAngle} STOPPED PositionState: ${this.PositionState}`);
|
|
399
|
-
}
|
|
330
|
+
if (this.direction === 'Up') {
|
|
331
|
+
this.CurrentHorizontalTiltAngle = 90;
|
|
332
|
+
} else if (this.direction === 'Down') {
|
|
333
|
+
this.CurrentHorizontalTiltAngle = -90;
|
|
400
334
|
} else {
|
|
401
|
-
this.
|
|
402
|
-
+ ` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
403
|
-
this.TargetPosition = this.CurrentHorizontalTiltAngle;
|
|
404
|
-
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
405
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Stopped`);
|
|
335
|
+
this.CurrentHorizontalTiltAngle = 0;
|
|
406
336
|
}
|
|
407
337
|
this.debugLog(
|
|
408
|
-
`${this.device.deviceType}: ${this.accessory.displayName}
|
|
409
|
-
` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState}
|
|
338
|
+
`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},` +
|
|
339
|
+
` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState},` +
|
|
340
|
+
` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`,
|
|
410
341
|
);
|
|
411
342
|
}
|
|
412
343
|
|
|
@@ -438,7 +369,6 @@ export class BlindTilt {
|
|
|
438
369
|
if (switchbot !== false) {
|
|
439
370
|
switchbot
|
|
440
371
|
.startScan({
|
|
441
|
-
model: 'c',
|
|
442
372
|
id: this.device.bleMac,
|
|
443
373
|
})
|
|
444
374
|
.then(async () => {
|
|
@@ -517,9 +447,10 @@ export class BlindTilt {
|
|
|
517
447
|
try {
|
|
518
448
|
this.deviceStatus = JSON.parse(rawData);
|
|
519
449
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${superStringify(this.deviceStatus)}`);
|
|
520
|
-
this.slidePosition = this.deviceStatus.body.slidePosition
|
|
450
|
+
this.slidePosition = this.deviceStatus.body.slidePosition;// "slidePosition": 0 = Closed Down | 100 = Closed Up | 50 = Fully Open
|
|
521
451
|
this.moving = this.deviceStatus.body.moving;
|
|
522
|
-
this.
|
|
452
|
+
this.Battery = this.deviceStatus.body.battery;
|
|
453
|
+
this.direction = this.deviceStatus.body.direction; // "Up"/"Down"
|
|
523
454
|
this.openAPIparseStatus();
|
|
524
455
|
this.updateHomeKitCharacteristics();
|
|
525
456
|
} catch (e: any) {
|
|
@@ -569,12 +500,6 @@ export class BlindTilt {
|
|
|
569
500
|
.join(':')
|
|
570
501
|
.toLowerCase();
|
|
571
502
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
572
|
-
this.SilentPerformance();
|
|
573
|
-
const adjustedMode = this.setPositionMode || null;
|
|
574
|
-
if (adjustedMode === null) {
|
|
575
|
-
this.Mode = 'Default Mode';
|
|
576
|
-
}
|
|
577
|
-
this.debugLog(`${this.accessory.displayName} Mode: ${this.Mode}`);
|
|
578
503
|
if (switchbot !== false) {
|
|
579
504
|
switchbot
|
|
580
505
|
.discover({ model: 'c', quick: true, id: this.device.bleMac })
|
|
@@ -583,7 +508,7 @@ export class BlindTilt {
|
|
|
583
508
|
return await this.retry({
|
|
584
509
|
max: await this.maxRetry(),
|
|
585
510
|
fn: () => {
|
|
586
|
-
return device_list[0].runToPos(100 - Number(this.TargetPosition)
|
|
511
|
+
return device_list[0].runToPos(100 - Number(this.TargetPosition));
|
|
587
512
|
},
|
|
588
513
|
});
|
|
589
514
|
})
|
|
@@ -643,24 +568,34 @@ export class BlindTilt {
|
|
|
643
568
|
const sign = signTerm.toString('base64');
|
|
644
569
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
645
570
|
this.debugLog(`Pushing ${this.TargetPosition}`);
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
571
|
+
let command = '';
|
|
572
|
+
let parameter = '';
|
|
573
|
+
if (this.TargetHorizontalTiltAngle === 90 && this.TargetPosition === 100) {
|
|
574
|
+
command = 'fullyOpen';
|
|
575
|
+
parameter = 'default';
|
|
576
|
+
} else if (this.TargetHorizontalTiltAngle === -90 && this.TargetPosition === 100) {
|
|
577
|
+
command = 'fullyOpen';
|
|
578
|
+
parameter = 'default';
|
|
579
|
+
} else if (this.TargetHorizontalTiltAngle === 90 && this.TargetPosition === 0) {
|
|
580
|
+
command = 'closeUp';
|
|
581
|
+
parameter = 'default';
|
|
582
|
+
} else if (this.TargetHorizontalTiltAngle === -90 && this.TargetPosition === 0) {
|
|
583
|
+
command = 'closeDown';
|
|
584
|
+
parameter = 'default';
|
|
649
585
|
} else {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
586
|
+
let direction = '';
|
|
587
|
+
const position = this.TargetPosition;
|
|
588
|
+
if (this.TargetHorizontalTiltAngle === 90) {
|
|
589
|
+
direction = 'up';
|
|
590
|
+
} else {
|
|
591
|
+
direction = 'down';
|
|
592
|
+
}
|
|
593
|
+
command = 'setPosition';
|
|
594
|
+
parameter = `${direction};${position}`;
|
|
658
595
|
}
|
|
659
|
-
this.debugLog(`${this.accessory.displayName} Mode: ${this.Mode}`);
|
|
660
|
-
const adjustedMode = this.setPositionMode || 'ff';
|
|
661
596
|
const body = superStringify({
|
|
662
|
-
'command':
|
|
663
|
-
'parameter':
|
|
597
|
+
'command': `${command}`,
|
|
598
|
+
'parameter': `${parameter}`,
|
|
664
599
|
'commandType': 'command',
|
|
665
600
|
});
|
|
666
601
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
@@ -762,27 +697,11 @@ export class BlindTilt {
|
|
|
762
697
|
}
|
|
763
698
|
|
|
764
699
|
this.TargetHorizontalTiltAngle = value;
|
|
700
|
+
this.accessory.context.TargetHorizontalTiltAngle = this.TargetHorizontalTiltAngle;
|
|
765
701
|
if (this.device.mqttURL) {
|
|
766
702
|
this.mqttPublish('TargetHorizontalTiltAngle', this.TargetHorizontalTiltAngle);
|
|
767
703
|
}
|
|
768
704
|
|
|
769
|
-
await this.setMinMax();
|
|
770
|
-
if (value > this.CurrentHorizontalTiltAngle) {
|
|
771
|
-
this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
|
|
772
|
-
this.setNewTarget = true;
|
|
773
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} value: ${value},`
|
|
774
|
-
+ ` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
775
|
-
} else if (value < this.CurrentHorizontalTiltAngle) {
|
|
776
|
-
this.PositionState = this.platform.Characteristic.PositionState.DECREASING;
|
|
777
|
-
this.setNewTarget = true;
|
|
778
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} value: ${value},`
|
|
779
|
-
+ ` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
780
|
-
} else {
|
|
781
|
-
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
782
|
-
this.setNewTarget = false;
|
|
783
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} value: ${value},`
|
|
784
|
-
+ ` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
785
|
-
}
|
|
786
705
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.PositionState);
|
|
787
706
|
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
|
|
788
707
|
|
|
@@ -833,17 +752,6 @@ export class BlindTilt {
|
|
|
833
752
|
this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.TargetPosition, Number(this.TargetPosition));
|
|
834
753
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: ${this.TargetPosition}`);
|
|
835
754
|
}
|
|
836
|
-
if (this.CurrentHorizontalTiltAngle === undefined || Number.isNaN(this.CurrentHorizontalTiltAngle)) {
|
|
837
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
838
|
-
} else {
|
|
839
|
-
if (this.device.mqttURL) {
|
|
840
|
-
this.mqttPublish('CurrentHorizontalTiltAngle', this.CurrentHorizontalTiltAngle);
|
|
841
|
-
}
|
|
842
|
-
this.accessory.context.CurrentHorizontalTiltAngle = this.CurrentHorizontalTiltAngle;
|
|
843
|
-
this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle, Number(this.CurrentPosition));
|
|
844
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
845
|
-
+` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
846
|
-
}
|
|
847
755
|
if (this.TargetHorizontalTiltAngle === undefined || Number.isNaN(this.TargetHorizontalTiltAngle)) {
|
|
848
756
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} TargetHorizontalTiltAngle: ${this.TargetHorizontalTiltAngle}`);
|
|
849
757
|
} else {
|
|
@@ -954,26 +862,6 @@ export class BlindTilt {
|
|
|
954
862
|
}
|
|
955
863
|
}
|
|
956
864
|
|
|
957
|
-
async SilentPerformance() {
|
|
958
|
-
if (this.TargetPosition > 50) {
|
|
959
|
-
if (this.device.curtain?.setOpenMode === '1') {
|
|
960
|
-
this.setPositionMode = 1;
|
|
961
|
-
this.Mode = 'Silent Mode';
|
|
962
|
-
} else {
|
|
963
|
-
this.setPositionMode = 0;
|
|
964
|
-
this.Mode = 'Performance Mode';
|
|
965
|
-
}
|
|
966
|
-
} else {
|
|
967
|
-
if (this.device.curtain?.setCloseMode === '1') {
|
|
968
|
-
this.setPositionMode = 1;
|
|
969
|
-
this.Mode = 'Silent Mode';
|
|
970
|
-
} else {
|
|
971
|
-
this.setPositionMode = 0;
|
|
972
|
-
this.Mode = 'Performance Mode';
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
|
|
977
865
|
async setMinMax(): Promise<void> {
|
|
978
866
|
if (this.device.curtain?.set_min) {
|
|
979
867
|
if (this.CurrentPosition <= this.device.curtain?.set_min) {
|
|
@@ -991,7 +879,7 @@ export class BlindTilt {
|
|
|
991
879
|
if (device.curtain?.set_minStep) {
|
|
992
880
|
this.set_minStep = device.curtain?.set_minStep;
|
|
993
881
|
} else {
|
|
994
|
-
this.set_minStep =
|
|
882
|
+
this.set_minStep = 90;
|
|
995
883
|
}
|
|
996
884
|
return this.set_minStep;
|
|
997
885
|
}
|
|
@@ -1124,12 +1012,6 @@ export class BlindTilt {
|
|
|
1124
1012
|
this.TargetPosition = this.accessory.context.TargetPosition;
|
|
1125
1013
|
}
|
|
1126
1014
|
|
|
1127
|
-
if (this.CurrentHorizontalTiltAngle === undefined) {
|
|
1128
|
-
this.CurrentHorizontalTiltAngle = 0;
|
|
1129
|
-
} else {
|
|
1130
|
-
this.CurrentHorizontalTiltAngle = this.accessory.context.CurrentHorizontalTiltAngle;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
1015
|
if (this.TargetHorizontalTiltAngle === undefined) {
|
|
1134
1016
|
this.TargetHorizontalTiltAngle = 0;
|
|
1135
1017
|
} else {
|
package/src/device/curtain.ts
CHANGED
|
@@ -954,7 +954,7 @@ export class Curtain {
|
|
|
954
954
|
this.scanDuration = this.updateRate;
|
|
955
955
|
if (this.BLE) {
|
|
956
956
|
this.warnLog(`${this.device.deviceType}: `
|
|
957
|
-
+ `${this.accessory.displayName} scanDuration is less
|
|
957
|
+
+ `${this.accessory.displayName} scanDuration is less than updateRate, overriding scanDuration with updateRate`);
|
|
958
958
|
}
|
|
959
959
|
} else {
|
|
960
960
|
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
@@ -965,10 +965,6 @@ export class Curtain {
|
|
|
965
965
|
} else {
|
|
966
966
|
if (this.updateRate > 1) {
|
|
967
967
|
this.scanDuration = this.updateRate;
|
|
968
|
-
if (this.BLE) {
|
|
969
|
-
this.warnLog(`${this.device.deviceType}: `
|
|
970
|
-
+ `${this.accessory.displayName} scanDuration is less then updateRate, overriding scanDuration with updateRate`);
|
|
971
|
-
}
|
|
972
968
|
} else {
|
|
973
969
|
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
974
970
|
}
|
package/src/settings.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
1
2
|
import { MacAddress, PlatformConfig } from 'homebridge';
|
|
2
3
|
import { IClientOptions } from 'async-mqtt';
|
|
3
4
|
/**
|
|
@@ -229,70 +230,44 @@ export type irdevice = {
|
|
|
229
230
|
};
|
|
230
231
|
|
|
231
232
|
export type deviceStatus = {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
shakeRange?: string;
|
|
271
|
-
//only available for Motion Sensor, Contact Sensor devices. determines if motion is detected
|
|
272
|
-
moveDetected?: boolean;
|
|
273
|
-
//only available for Motion Sensor, Contact Sensor devices. tell the ambient environment is bright or dim
|
|
274
|
-
//only available for Color Bulb/Strip Light devices. the brightness value, range from 1 to 100
|
|
275
|
-
brightness?: string | number;
|
|
276
|
-
//only available for Contact Sensor devices. open/close/timeOutNotClose
|
|
277
|
-
openState?: string;
|
|
278
|
-
//only available for Color Bulb/Strip Light devices. the color value, RGB "255:255:255"
|
|
279
|
-
color?: string;
|
|
280
|
-
//only available for Color Bulb devices. the color temperature value, range from 2700 to 6500
|
|
281
|
-
colorTemperature?: number;
|
|
282
|
-
//only available for Humidifier devices. determines if the water tank empty or not
|
|
283
|
-
lackWater?: boolean;
|
|
284
|
-
//only available for Plug Mini (US)/Plug Mini (JP). Current voltage of the device (Unit: V).
|
|
285
|
-
voltage: number;
|
|
286
|
-
//only available for Plug Mini (US)/Plug Mini (JP). The power consumption of the device for the day (Unit: W/min).
|
|
287
|
-
weight: number;
|
|
288
|
-
//only available for Plug Mini (US)/Plug Mini (JP). How long the device has been used for the day (Unit: min).
|
|
289
|
-
electricityOfDay: number;
|
|
290
|
-
//only available for Plug Mini (US)/Plug Mini (JP). Current current of the device (Unit: A).
|
|
291
|
-
electricCurrent: number;
|
|
292
|
-
//only available for Lock devices. determines if the lock is locked or not.
|
|
293
|
-
lockState: string;
|
|
294
|
-
//only available for Lock devices. determines if the door is closed or not.
|
|
295
|
-
doorState: string;
|
|
233
|
+
//v1.1 of API
|
|
234
|
+
deviceId: string; //device ID. (Used by the following deviceTypes: Bot, Curtain, Meter, Meter Plus, Lock, Keypad, Keypad Touch, Motion Sensor, Contact Sensor, Ceiling Light, Ceiling Light Pro, Plug Mini (US), Plug Mini (JP), Strip Light, Color Bulb, Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Humidifier, Blind Tilt)
|
|
235
|
+
deviceType: string; //device type. (Used by the following deviceTypes: Bot, Curtain, Meter, Meter Plus, Lock, Keypad, Keypad Touch, Motion Sensor, Contact Sensor, Ceiling Light, Ceiling Light Pro, Plug Mini (US), Plug Mini (JP), Strip Light, Color Bulb, Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Humidifier, Blind Tilt)
|
|
236
|
+
hubDeviceId: string; //device's parent Hub ID. 000000000000 when the device itself is a Hub or it is connected through Wi-Fi. (Used by the following deviceTypes: Bot, Curtain, Meter, Meter Plus, Lock, Keypad, Keypad Touch, Motion Sensor, Contact Sensor, Ceiling Light, Ceiling Light Pro, Plug Mini (JP), Strip Light, Color Bulb, Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Humidifier, Blind Tilt)
|
|
237
|
+
power?: string; //ON/OFF state. (Used by the following deviceTypes: Bot, Ceiling Light, Ceiling Light Pro, PLug, Plug Mini (US), Plug Mini (JP), Strip Light, Color Bulb, Humidifier)
|
|
238
|
+
calibrate?: boolean; //determines if device has been calibrated or not. (Used by the following deviceTypes: Curtain, Lock, Blind Tilt)
|
|
239
|
+
group?: boolean; //determines if a device is paired with or grouped with another device or not. (Used by the following deviceTypes: Curtain, Blind Tilt)
|
|
240
|
+
moving?: boolean; //determines if a device is moving or not. (Used by the following deviceTypes: Curtain, Blind Tilt)
|
|
241
|
+
slidePosition?: number;//the current position (0-100) the percentage of the distance between the calibrated open position and closed position. (Used by the following deviceTypes: Curtain, Blind Tilt)
|
|
242
|
+
temperature?: number; //temperature in celsius (Used by the following deviceTypes: Meter, Meter Plus, Humidifier)
|
|
243
|
+
humidity?: number; //humidity percentage. (Used by the following deviceTypes: Meter, Meter Plus, Humidifier)
|
|
244
|
+
lockState?: string; //determines if locked or not. (Used by the following deviceTypes: Lock)
|
|
245
|
+
doorState?: string; //determines if the door is closed or not. (Used by the following deviceTypes: Lock)
|
|
246
|
+
moveDetected?: boolean; //determines if motion is detected. (Used by the following deviceTypes: Motion Sensor, Contact Sensor)
|
|
247
|
+
brightness?: string | number; //the ambient brightness picked up by the sensor. bright or dim. (Used by the following deviceTypes: Motion Sensor, Contact Sensor) | the brightness value, range from 1 to 100. (Used by the following deviceTypes: Ceiling Light, Ceiling Light Pro, Strip Light, Color Bulb)
|
|
248
|
+
openState?: string; //the open state of the sensor. open, close, or timeOutNotClose. (Used by the following deviceTypes: Contact Sensor)
|
|
249
|
+
colorTemperature?: number; //the color temperature value, range from 2700 to 6500. (Used by the following deviceTypes: Ceiling Light, Ceiling Light Pro, Color Bulb)
|
|
250
|
+
voltage?: number; //the voltage of the device, measured in Volt. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
|
|
251
|
+
weight?: number; //the power consumed in a day, measured in Watts. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
|
|
252
|
+
electricityOfDay?: number; //the duration that the device has been used during a day, measured in minutes. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
|
|
253
|
+
electricCurrent?: number; //the current of the device at the moment, measured in Amp. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
|
|
254
|
+
color?: string; //the color value, RGB "255:255:255". (Used by the following deviceTypes: Strip Light, Color Bulb)
|
|
255
|
+
workingStatus?: string; //the working status of the device. StandBy, Clearing, Paused, GotoChargeBase, Charging, ChargeDone, Dormant, InTrouble, InRemoteControl, or InDustCollecting. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus)
|
|
256
|
+
onlineStatus?: string; //the connection status of the device. online or offline. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus)
|
|
257
|
+
battery?: number; //the current battery level. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Blind Tilt)
|
|
258
|
+
deviceName?: string; //device name. (Used by the following deviceTypes: Robot Vacuum Cleaner S1 Plus)
|
|
259
|
+
nebulizationEfficiency?: number; //atomization efficiency percentage. (Used by the following deviceTypes: Humidifier)
|
|
260
|
+
auto?: boolean; //determines if a Humidifier is in Auto Mode or not. (Used by the following deviceTypes: Humidifier)
|
|
261
|
+
childLock?: boolean; //determines if a Humidifier's safety lock is on or not. (Used by the following deviceTypes: Humidifier)
|
|
262
|
+
sound?: boolean; //determines if a Humidifier is muted or not. (Used by the following deviceTypes: Humidifier)
|
|
263
|
+
lackWater?: boolean; //determines if the water tank is empty or not. (Used by the following deviceTypes: Humidifier)
|
|
264
|
+
version?: number; // the version of the device. (Used by the following deviceTypes: Blind Tilt)
|
|
265
|
+
direction?: string; //the opening direction of a Blind Tilt device. (Used by the following deviceTypes: Blind Tilt)
|
|
266
|
+
mode?: number; //available for devices. the fan mode. (Used by the following deviceTypes: Smart Fan)
|
|
267
|
+
speed?: number;//the fan speed. (Used by the following deviceTypes: Smart Fan)
|
|
268
|
+
shaking?: boolean; //determines if the fan is swinging or not. (Used by the following deviceTypes: Smart Fan)
|
|
269
|
+
shakeCenter?: string;//only available for Smart Fan devices. the fan's swing direciton. (Used by the following deviceTypes: Smart Fan)
|
|
270
|
+
shakeRange?: string;//only available for Smart Fan devices. the fan's swing range, 0~120°. (Used by the following deviceTypes: Smart Fan)
|
|
296
271
|
};
|
|
297
272
|
|
|
298
273
|
export type ad = {
|