@switchbot/homebridge-switchbot 2.4.1-beta.7 → 2.5.0-beta.1
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 +5 -1
- package/dist/device/blindtilt.d.ts +9 -8
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +114 -150
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +2 -0
- 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 +8 -8
- package/src/device/blindtilt.ts +119 -160
- package/src/device/curtain.ts +2 -0
- package/src/settings.ts +39 -64
package/config.schema.json
CHANGED
|
@@ -80,6 +80,10 @@
|
|
|
80
80
|
"title": "Curtain",
|
|
81
81
|
"enum": ["Curtain"]
|
|
82
82
|
},
|
|
83
|
+
{
|
|
84
|
+
"title": "Blind Tilt",
|
|
85
|
+
"enum": ["Blind Tilt"]
|
|
86
|
+
},
|
|
83
87
|
{
|
|
84
88
|
"title": "Plug",
|
|
85
89
|
"enum": ["Plug"]
|
|
@@ -418,7 +422,7 @@
|
|
|
418
422
|
}
|
|
419
423
|
},
|
|
420
424
|
"hide_lightsensor": {
|
|
421
|
-
"title": "Hide
|
|
425
|
+
"title": "Hide Light Sensor",
|
|
422
426
|
"type": "boolean",
|
|
423
427
|
"condition": {
|
|
424
428
|
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);"
|
|
@@ -13,20 +13,19 @@ export declare class BlindTilt {
|
|
|
13
13
|
private accessory;
|
|
14
14
|
device: device & devicesConfig;
|
|
15
15
|
windowCoveringService: Service;
|
|
16
|
-
lightSensorService?: Service;
|
|
17
16
|
batteryService?: Service;
|
|
18
17
|
CurrentPosition: CharacteristicValue;
|
|
19
18
|
PositionState: CharacteristicValue;
|
|
20
19
|
TargetPosition: CharacteristicValue;
|
|
21
|
-
|
|
22
|
-
BatteryLevel?: CharacteristicValue;
|
|
20
|
+
BatteryLevel: CharacteristicValue;
|
|
23
21
|
StatusLowBattery?: CharacteristicValue;
|
|
22
|
+
CurrentHorizontalTiltAngle: CharacteristicValue;
|
|
23
|
+
TargetHorizontalTiltAngle: CharacteristicValue;
|
|
24
24
|
deviceStatus: any;
|
|
25
25
|
slidePosition: deviceStatus['slidePosition'];
|
|
26
26
|
moving: deviceStatus['moving'];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Mode: string;
|
|
27
|
+
Battery: deviceStatus['battery'];
|
|
28
|
+
direction: deviceStatus['direction'];
|
|
30
29
|
connected?: boolean;
|
|
31
30
|
switchbot: switchbot;
|
|
32
31
|
serviceData: serviceData;
|
|
@@ -36,7 +35,6 @@ export declare class BlindTilt {
|
|
|
36
35
|
battery: serviceData['battery'];
|
|
37
36
|
position: serviceData['position'];
|
|
38
37
|
inMotion: serviceData['inMotion'];
|
|
39
|
-
lightLevel: serviceData['lightLevel'];
|
|
40
38
|
setNewTarget: boolean;
|
|
41
39
|
setNewTargetTimer: NodeJS.Timeout;
|
|
42
40
|
mqttClient: MqttClient | null;
|
|
@@ -78,6 +76,10 @@ export declare class BlindTilt {
|
|
|
78
76
|
* Handle requests to set the value of the "Target Position" characteristic
|
|
79
77
|
*/
|
|
80
78
|
TargetPositionSet(value: CharacteristicValue): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Handle requests to set the value of the "Target Position" characteristic
|
|
81
|
+
*/
|
|
82
|
+
TargetHorizontalTiltAngleSet(value: CharacteristicValue): Promise<void>;
|
|
81
83
|
updateHomeKitCharacteristics(): Promise<void>;
|
|
82
84
|
mqttPublish(topic: string, message: any): void;
|
|
83
85
|
setupMqtt(device: device & devicesConfig): Promise<void>;
|
|
@@ -85,7 +87,6 @@ export declare class BlindTilt {
|
|
|
85
87
|
getCustomBLEAddress(switchbot: any): Promise<void>;
|
|
86
88
|
BLEPushConnection(): Promise<void>;
|
|
87
89
|
BLERefreshConnection(switchbot: any): Promise<void>;
|
|
88
|
-
SilentPerformance(): Promise<void>;
|
|
89
90
|
setMinMax(): Promise<void>;
|
|
90
91
|
minStep(device: device & devicesConfig): number;
|
|
91
92
|
minLux(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blindtilt.d.ts","sourceRoot":"","sources":["../../src/device/blindtilt.ts"],"names":[],"mappings":";;;AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AAGzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAA0B,MAAM,aAAa,CAAC;AAGtH,qBAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"blindtilt.d.ts","sourceRoot":"","sources":["../../src/device/blindtilt.ts"],"names":[],"mappings":";;;AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AAGzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,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AAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BrD,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBzD;;OAEG;IACH,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,YAAY,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAQjC,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM7B,aAAa,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAQlC,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAU7B,qBAAqB,IAAI,OAAO;CAGjC"}
|
package/dist/device/blindtilt.js
CHANGED
|
@@ -77,28 +77,33 @@ class BlindTilt {
|
|
|
77
77
|
.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
78
78
|
.setProps({
|
|
79
79
|
minStep: this.minStep(device),
|
|
80
|
+
minValue: 0,
|
|
81
|
+
maxValue: 100,
|
|
80
82
|
validValueRanges: [0, 100],
|
|
81
83
|
})
|
|
82
84
|
.onSet(this.TargetPositionSet.bind(this));
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
85
|
+
this.windowCoveringService
|
|
86
|
+
.getCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle)
|
|
87
|
+
.setProps({
|
|
88
|
+
minStep: 180,
|
|
89
|
+
minValue: -90,
|
|
90
|
+
maxValue: 90,
|
|
91
|
+
validValues: [-90, 90],
|
|
92
|
+
validValueRanges: [-90, 90],
|
|
93
|
+
})
|
|
94
|
+
.onGet(() => {
|
|
95
|
+
return this.CurrentHorizontalTiltAngle;
|
|
96
|
+
});
|
|
97
|
+
this.windowCoveringService
|
|
98
|
+
.getCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle)
|
|
99
|
+
.setProps({
|
|
100
|
+
minStep: 180,
|
|
101
|
+
minValue: -90,
|
|
102
|
+
maxValue: 90,
|
|
103
|
+
validValues: [-90, 90],
|
|
104
|
+
validValueRanges: [-90, 90],
|
|
105
|
+
})
|
|
106
|
+
.onSet(this.TargetHorizontalTiltAngleSet.bind(this));
|
|
102
107
|
// Battery Service
|
|
103
108
|
if (!this.BLE) {
|
|
104
109
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
|
|
@@ -210,57 +215,6 @@ class BlindTilt {
|
|
|
210
215
|
}
|
|
211
216
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},` +
|
|
212
217
|
` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState},`);
|
|
213
|
-
if (!this.device.curtain?.hide_lightsensor) {
|
|
214
|
-
this.set_minLux = this.minLux();
|
|
215
|
-
this.set_maxLux = this.maxLux();
|
|
216
|
-
this.spaceBetweenLevels = 9;
|
|
217
|
-
// Brightness
|
|
218
|
-
switch (this.lightLevel) {
|
|
219
|
-
case 1:
|
|
220
|
-
this.CurrentAmbientLightLevel = this.set_minLux;
|
|
221
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
|
|
222
|
-
break;
|
|
223
|
-
case 2:
|
|
224
|
-
this.CurrentAmbientLightLevel = (this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels;
|
|
225
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel},` +
|
|
226
|
-
` Calculation: ${(this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels}`);
|
|
227
|
-
break;
|
|
228
|
-
case 3:
|
|
229
|
-
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 2;
|
|
230
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
|
|
231
|
-
break;
|
|
232
|
-
case 4:
|
|
233
|
-
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 3;
|
|
234
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
|
|
235
|
-
break;
|
|
236
|
-
case 5:
|
|
237
|
-
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 4;
|
|
238
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
|
|
239
|
-
break;
|
|
240
|
-
case 6:
|
|
241
|
-
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 5;
|
|
242
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
|
|
243
|
-
break;
|
|
244
|
-
case 7:
|
|
245
|
-
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 6;
|
|
246
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
|
|
247
|
-
break;
|
|
248
|
-
case 8:
|
|
249
|
-
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 7;
|
|
250
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
|
|
251
|
-
break;
|
|
252
|
-
case 9:
|
|
253
|
-
this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 8;
|
|
254
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
|
|
255
|
-
break;
|
|
256
|
-
case 10:
|
|
257
|
-
default:
|
|
258
|
-
this.CurrentAmbientLightLevel = this.set_maxLux;
|
|
259
|
-
this.debugLog();
|
|
260
|
-
}
|
|
261
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel},`
|
|
262
|
-
+ ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
263
|
-
}
|
|
264
218
|
// Battery
|
|
265
219
|
this.BatteryLevel = Number(this.battery);
|
|
266
220
|
if (this.BatteryLevel < 10) {
|
|
@@ -308,22 +262,18 @@ class BlindTilt {
|
|
|
308
262
|
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
309
263
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Stopped`);
|
|
310
264
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (!this.device.curtain?.hide_lightsensor) {
|
|
314
|
-
this.set_minLux = this.minLux();
|
|
315
|
-
this.set_maxLux = this.maxLux();
|
|
316
|
-
// Brightness
|
|
317
|
-
switch (this.brightness) {
|
|
318
|
-
case 'dim':
|
|
319
|
-
this.CurrentAmbientLightLevel = this.set_minLux;
|
|
320
|
-
break;
|
|
321
|
-
case 'bright':
|
|
322
|
-
default:
|
|
323
|
-
this.CurrentAmbientLightLevel = this.set_maxLux;
|
|
324
|
-
}
|
|
325
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
265
|
+
if (this.direction === 'Up') {
|
|
266
|
+
this.CurrentHorizontalTiltAngle = 90;
|
|
326
267
|
}
|
|
268
|
+
else if (this.direction === 'Down') {
|
|
269
|
+
this.CurrentHorizontalTiltAngle = -90;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
this.CurrentHorizontalTiltAngle = 0;
|
|
273
|
+
}
|
|
274
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},` +
|
|
275
|
+
` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState},` +
|
|
276
|
+
` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
|
|
327
277
|
}
|
|
328
278
|
async refreshStatus() {
|
|
329
279
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
@@ -355,7 +305,6 @@ class BlindTilt {
|
|
|
355
305
|
if (switchbot !== false) {
|
|
356
306
|
switchbot
|
|
357
307
|
.startScan({
|
|
358
|
-
model: 'c',
|
|
359
308
|
id: this.device.bleMac,
|
|
360
309
|
})
|
|
361
310
|
.then(async () => {
|
|
@@ -369,11 +318,9 @@ class BlindTilt {
|
|
|
369
318
|
this.battery = ad.serviceData.battery;
|
|
370
319
|
this.inMotion = ad.serviceData.inMotion;
|
|
371
320
|
this.position = ad.serviceData.position;
|
|
372
|
-
this.lightLevel = ad.serviceData.lightLevel;
|
|
373
321
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${(0, super_stringify_1.default)(ad.serviceData)}`);
|
|
374
322
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} calibration: ${ad.serviceData.calibration}, ` +
|
|
375
|
-
`position: ${ad.serviceData.position},
|
|
376
|
-
`inMotion: ${ad.serviceData.inMotion}`);
|
|
323
|
+
`position: ${ad.serviceData.position}, inMotion: ${ad.serviceData.inMotion}, battery: ${ad.serviceData.battery}`);
|
|
377
324
|
if (this.serviceData) {
|
|
378
325
|
this.connected = true;
|
|
379
326
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
@@ -435,9 +382,10 @@ class BlindTilt {
|
|
|
435
382
|
try {
|
|
436
383
|
this.deviceStatus = JSON.parse(rawData);
|
|
437
384
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${(0, super_stringify_1.default)(this.deviceStatus)}`);
|
|
438
|
-
this.slidePosition = this.deviceStatus.body.slidePosition;
|
|
385
|
+
this.slidePosition = this.deviceStatus.body.slidePosition; // "slidePosition": 0 = Closed Down | 100 = Closed Up | 50 = Fully Open
|
|
439
386
|
this.moving = this.deviceStatus.body.moving;
|
|
440
|
-
this.
|
|
387
|
+
this.Battery = this.deviceStatus.body.battery;
|
|
388
|
+
this.direction = this.deviceStatus.body.direction; // "Up"/"Down"
|
|
441
389
|
this.openAPIparseStatus();
|
|
442
390
|
this.updateHomeKitCharacteristics();
|
|
443
391
|
}
|
|
@@ -490,12 +438,6 @@ class BlindTilt {
|
|
|
490
438
|
.join(':')
|
|
491
439
|
.toLowerCase();
|
|
492
440
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
493
|
-
this.SilentPerformance();
|
|
494
|
-
const adjustedMode = this.setPositionMode || null;
|
|
495
|
-
if (adjustedMode === null) {
|
|
496
|
-
this.Mode = 'Default Mode';
|
|
497
|
-
}
|
|
498
|
-
this.debugLog(`${this.accessory.displayName} Mode: ${this.Mode}`);
|
|
499
441
|
if (switchbot !== false) {
|
|
500
442
|
switchbot
|
|
501
443
|
.discover({ model: 'c', quick: true, id: this.device.bleMac })
|
|
@@ -504,7 +446,7 @@ class BlindTilt {
|
|
|
504
446
|
return await this.retry({
|
|
505
447
|
max: await this.maxRetry(),
|
|
506
448
|
fn: () => {
|
|
507
|
-
return device_list[0].runToPos(100 - Number(this.TargetPosition)
|
|
449
|
+
return device_list[0].runToPos(100 - Number(this.TargetPosition));
|
|
508
450
|
},
|
|
509
451
|
});
|
|
510
452
|
})
|
|
@@ -563,27 +505,39 @@ class BlindTilt {
|
|
|
563
505
|
const sign = signTerm.toString('base64');
|
|
564
506
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
565
507
|
this.debugLog(`Pushing ${this.TargetPosition}`);
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
508
|
+
let command = '';
|
|
509
|
+
let parameter = '';
|
|
510
|
+
if (this.TargetHorizontalTiltAngle === 90 && this.TargetPosition === 100) {
|
|
511
|
+
command = 'fullyOpen';
|
|
512
|
+
parameter = 'default';
|
|
569
513
|
}
|
|
570
|
-
else {
|
|
571
|
-
|
|
514
|
+
else if (this.TargetHorizontalTiltAngle === -90 && this.TargetPosition === 100) {
|
|
515
|
+
command = 'fullyOpen';
|
|
516
|
+
parameter = 'default';
|
|
572
517
|
}
|
|
573
|
-
if (this.
|
|
574
|
-
|
|
518
|
+
else if (this.TargetHorizontalTiltAngle === 90 && this.TargetPosition === 0) {
|
|
519
|
+
command = 'closeUp';
|
|
520
|
+
parameter = 'default';
|
|
575
521
|
}
|
|
576
|
-
else if (this.
|
|
577
|
-
|
|
522
|
+
else if (this.TargetHorizontalTiltAngle === -90 && this.TargetPosition === 0) {
|
|
523
|
+
command = 'closeDown';
|
|
524
|
+
parameter = 'default';
|
|
578
525
|
}
|
|
579
526
|
else {
|
|
580
|
-
|
|
527
|
+
let direction = '';
|
|
528
|
+
const position = this.TargetPosition;
|
|
529
|
+
if (this.TargetHorizontalTiltAngle === 90) {
|
|
530
|
+
direction = 'up';
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
direction = 'down';
|
|
534
|
+
}
|
|
535
|
+
command = 'setPosition';
|
|
536
|
+
parameter = `${direction};${position}`;
|
|
581
537
|
}
|
|
582
|
-
this.debugLog(`${this.accessory.displayName} Mode: ${this.Mode}`);
|
|
583
|
-
const adjustedMode = this.setPositionMode || 'ff';
|
|
584
538
|
const body = (0, super_stringify_1.default)({
|
|
585
|
-
'command':
|
|
586
|
-
'parameter':
|
|
539
|
+
'command': `${command}`,
|
|
540
|
+
'parameter': `${parameter}`,
|
|
587
541
|
'commandType': 'command',
|
|
588
542
|
});
|
|
589
543
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
@@ -672,6 +626,37 @@ class BlindTilt {
|
|
|
672
626
|
}
|
|
673
627
|
this.doBlindTiltUpdate.next();
|
|
674
628
|
}
|
|
629
|
+
/**
|
|
630
|
+
* Handle requests to set the value of the "Target Position" characteristic
|
|
631
|
+
*/
|
|
632
|
+
async TargetHorizontalTiltAngleSet(value) {
|
|
633
|
+
if (this.TargetHorizontalTiltAngle === this.accessory.context.TargetHorizontalTiltAngle) {
|
|
634
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set TargetHorizontalTiltAngle: ${value}`);
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetHorizontalTiltAngle: ${value}`);
|
|
638
|
+
}
|
|
639
|
+
this.TargetHorizontalTiltAngle = value;
|
|
640
|
+
this.accessory.context.TargetHorizontalTiltAngle = this.TargetHorizontalTiltAngle;
|
|
641
|
+
if (this.device.mqttURL) {
|
|
642
|
+
this.mqttPublish('TargetHorizontalTiltAngle', this.TargetHorizontalTiltAngle);
|
|
643
|
+
}
|
|
644
|
+
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.PositionState);
|
|
645
|
+
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
|
|
646
|
+
/**
|
|
647
|
+
* If Blind Tilt movement time is short, the moving flag from backend is always false.
|
|
648
|
+
* The minimum time depends on the network control latency.
|
|
649
|
+
*/
|
|
650
|
+
clearTimeout(this.setNewTargetTimer);
|
|
651
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateRate: ${this.updateRate}`);
|
|
652
|
+
if (this.setNewTarget) {
|
|
653
|
+
this.setNewTargetTimer = setTimeout(() => {
|
|
654
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} setNewTarget ${this.setNewTarget} timeout`);
|
|
655
|
+
this.setNewTarget = false;
|
|
656
|
+
}, this.updateRate * 1000);
|
|
657
|
+
}
|
|
658
|
+
this.doBlindTiltUpdate.next();
|
|
659
|
+
}
|
|
675
660
|
async updateHomeKitCharacteristics() {
|
|
676
661
|
await this.setMinMax();
|
|
677
662
|
if (this.CurrentPosition === undefined || Number.isNaN(this.CurrentPosition)) {
|
|
@@ -707,19 +692,17 @@ class BlindTilt {
|
|
|
707
692
|
this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.TargetPosition, Number(this.TargetPosition));
|
|
708
693
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: ${this.TargetPosition}`);
|
|
709
694
|
}
|
|
710
|
-
if (
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
this.mqttPublish('CurrentAmbientLightLevel', this.CurrentAmbientLightLevel);
|
|
717
|
-
}
|
|
718
|
-
this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
|
|
719
|
-
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
|
|
720
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
721
|
-
+ ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
695
|
+
if (this.TargetHorizontalTiltAngle === undefined || Number.isNaN(this.TargetHorizontalTiltAngle)) {
|
|
696
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} TargetHorizontalTiltAngle: ${this.TargetHorizontalTiltAngle}`);
|
|
697
|
+
}
|
|
698
|
+
else {
|
|
699
|
+
if (this.device.mqttURL) {
|
|
700
|
+
this.mqttPublish('TargetHorizontalTiltAngle', this.TargetHorizontalTiltAngle);
|
|
722
701
|
}
|
|
702
|
+
this.accessory.context.TargetHorizontalTiltAngle = this.TargetHorizontalTiltAngle;
|
|
703
|
+
this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle, Number(this.TargetHorizontalTiltAngle));
|
|
704
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
705
|
+
+ ` TargetHorizontalTiltAngle: ${this.TargetHorizontalTiltAngle}`);
|
|
723
706
|
}
|
|
724
707
|
if (this.BLE) {
|
|
725
708
|
if (this.BatteryLevel === undefined) {
|
|
@@ -817,28 +800,6 @@ class BlindTilt {
|
|
|
817
800
|
await this.openAPIRefreshStatus();
|
|
818
801
|
}
|
|
819
802
|
}
|
|
820
|
-
async SilentPerformance() {
|
|
821
|
-
if (this.TargetPosition > 50) {
|
|
822
|
-
if (this.device.curtain?.setOpenMode === '1') {
|
|
823
|
-
this.setPositionMode = 1;
|
|
824
|
-
this.Mode = 'Silent Mode';
|
|
825
|
-
}
|
|
826
|
-
else {
|
|
827
|
-
this.setPositionMode = 0;
|
|
828
|
-
this.Mode = 'Performance Mode';
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
else {
|
|
832
|
-
if (this.device.curtain?.setCloseMode === '1') {
|
|
833
|
-
this.setPositionMode = 1;
|
|
834
|
-
this.Mode = 'Silent Mode';
|
|
835
|
-
}
|
|
836
|
-
else {
|
|
837
|
-
this.setPositionMode = 0;
|
|
838
|
-
this.Mode = 'Performance Mode';
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
803
|
async setMinMax() {
|
|
843
804
|
if (this.device.curtain?.set_min) {
|
|
844
805
|
if (this.CurrentPosition <= this.device.curtain?.set_min) {
|
|
@@ -856,7 +817,7 @@ class BlindTilt {
|
|
|
856
817
|
this.set_minStep = device.curtain?.set_minStep;
|
|
857
818
|
}
|
|
858
819
|
else {
|
|
859
|
-
this.set_minStep =
|
|
820
|
+
this.set_minStep = 90;
|
|
860
821
|
}
|
|
861
822
|
return this.set_minStep;
|
|
862
823
|
}
|
|
@@ -950,9 +911,6 @@ class BlindTilt {
|
|
|
950
911
|
this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
951
912
|
this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
952
913
|
this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
953
|
-
if (!this.device.curtain?.hide_lightsensor) {
|
|
954
|
-
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
|
|
955
|
-
}
|
|
956
914
|
if (this.BLE) {
|
|
957
915
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
958
916
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
@@ -989,6 +947,12 @@ class BlindTilt {
|
|
|
989
947
|
else {
|
|
990
948
|
this.TargetPosition = this.accessory.context.TargetPosition;
|
|
991
949
|
}
|
|
950
|
+
if (this.TargetHorizontalTiltAngle === undefined) {
|
|
951
|
+
this.TargetHorizontalTiltAngle = 0;
|
|
952
|
+
}
|
|
953
|
+
else {
|
|
954
|
+
this.TargetHorizontalTiltAngle = this.accessory.context.TargetHorizontalTiltAngle;
|
|
955
|
+
}
|
|
992
956
|
if (this.PositionState === undefined) {
|
|
993
957
|
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
994
958
|
}
|