@switchbot/homebridge-switchbot 2.4.1-beta.7 → 2.5.0-beta.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.
@@ -15,16 +15,16 @@ import { sleep } from '../utils';
15
15
  export class BlindTilt {
16
16
  // Services
17
17
  windowCoveringService: Service;
18
- lightSensorService?: Service;
19
18
  batteryService?: Service;
20
19
 
21
20
  // Characteristic Values
22
21
  CurrentPosition!: CharacteristicValue;
23
22
  PositionState!: CharacteristicValue;
24
23
  TargetPosition!: CharacteristicValue;
25
- CurrentAmbientLightLevel?: CharacteristicValue;
26
24
  BatteryLevel?: CharacteristicValue;
27
25
  StatusLowBattery?: CharacteristicValue;
26
+ CurrentHorizontalTiltAngle!: CharacteristicValue;
27
+ TargetHorizontalTiltAngle!: CharacteristicValue;
28
28
 
29
29
  // OpenAPI Others
30
30
  deviceStatus!: any; //deviceStatusResponse;
@@ -44,7 +44,6 @@ export class BlindTilt {
44
44
  battery: serviceData['battery'];
45
45
  position: serviceData['position'];
46
46
  inMotion: serviceData['inMotion'];
47
- lightLevel: serviceData['lightLevel'];
48
47
 
49
48
  // Target
50
49
  setNewTarget!: boolean;
@@ -142,24 +141,27 @@ export class BlindTilt {
142
141
  })
143
142
  .onSet(this.TargetPositionSet.bind(this));
144
143
 
145
- // Light Sensor Service
146
- if (device.curtain?.hide_lightsensor) {
147
- this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Light Sensor Service`);
148
- this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor);
149
- accessory.removeService(this.lightSensorService!);
150
- } else if (!this.lightSensorService) {
151
- this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Light Sensor Service`);
152
- (this.lightSensorService =
153
- this.accessory.getService(this.platform.Service.LightSensor) || this.accessory.addService(this.platform.Service.LightSensor)),
154
- `${accessory.displayName} Light Sensor`;
155
-
156
- this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
157
- if (!this.lightSensorService?.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
158
- this.lightSensorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Light Sensor`);
159
- }
160
- } else {
161
- this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Light Sensor Service Not Added`);
162
- }
144
+ this.windowCoveringService
145
+ .getCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle)
146
+ .setProps({
147
+ minStep: this.minStep(device),
148
+ minValue: -90,
149
+ maxValue: 90,
150
+ validValueRanges: [-90, 90],
151
+ })
152
+ .onGet(() => {
153
+ return this.CurrentHorizontalTiltAngle;
154
+ });
155
+
156
+ this.windowCoveringService
157
+ .getCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle)
158
+ .setProps({
159
+ minStep: this.minStep(device),
160
+ minValue: -90,
161
+ maxValue: 90,
162
+ validValueRanges: [-90, 90],
163
+ })
164
+ .onSet(this.TargetHorizontalTiltAngleSet.bind(this));
163
165
 
164
166
  // Battery Service
165
167
  if (!this.BLE) {
@@ -276,63 +278,47 @@ export class BlindTilt {
276
278
  `${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},` +
277
279
  ` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState},`,
278
280
  );
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
+ }
279
288
 
280
- if (!this.device.curtain?.hide_lightsensor) {
281
- this.set_minLux = this.minLux();
282
- this.set_maxLux = this.maxLux();
283
- this.spaceBetweenLevels = 9;
284
-
285
- // Brightness
286
- switch (this.lightLevel) {
287
- case 1:
288
- this.CurrentAmbientLightLevel = this.set_minLux;
289
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
290
- break;
291
- case 2:
292
- this.CurrentAmbientLightLevel = (this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels;
293
- this.debugLog(
294
- `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel},` +
295
- ` Calculation: ${(this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels}`,
296
- );
297
- break;
298
- case 3:
299
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 2;
300
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
301
- break;
302
- case 4:
303
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 3;
304
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
305
- break;
306
- case 5:
307
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 4;
308
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
309
- break;
310
- case 6:
311
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 5;
312
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
313
- break;
314
- case 7:
315
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 6;
316
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
317
- break;
318
- case 8:
319
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 7;
320
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
321
- break;
322
- case 9:
323
- this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 8;
324
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
325
- break;
326
- case 10:
327
- default:
328
- this.CurrentAmbientLightLevel = this.set_maxLux;
329
- this.debugLog();
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}`);
330
309
  }
331
- this.debugLog(
332
- `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel},`
333
- + ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
334
- );
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`);
335
316
  }
317
+ this.debugLog(
318
+ `${this.device.deviceType}: ${this.accessory.displayName} CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle},` +
319
+ ` TargetHorizontalTiltAngle: ${this.TargetHorizontalTiltAngle}, PositionState: ${this.PositionState},`,
320
+ );
321
+
336
322
  // Battery
337
323
  this.BatteryLevel = Number(this.battery);
338
324
  if (this.BatteryLevel < 10) {
@@ -382,21 +368,46 @@ export class BlindTilt {
382
368
  `${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},` +
383
369
  ` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState},`,
384
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
+ }
385
378
 
386
- if (!this.device.curtain?.hide_lightsensor) {
387
- this.set_minLux = this.minLux();
388
- this.set_maxLux = this.maxLux();
389
- // Brightness
390
- switch (this.brightness) {
391
- case 'dim':
392
- this.CurrentAmbientLightLevel = this.set_minLux;
393
- break;
394
- case 'bright':
395
- default:
396
- this.CurrentAmbientLightLevel = this.set_maxLux;
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}`);
397
399
  }
398
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
400
+ } else {
401
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Standby,`
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`);
399
406
  }
407
+ this.debugLog(
408
+ `${this.device.deviceType}: ${this.accessory.displayName} CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle},` +
409
+ ` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState},`,
410
+ );
400
411
  }
401
412
 
402
413
  async refreshStatus(): Promise<void> {
@@ -441,12 +452,10 @@ export class BlindTilt {
441
452
  this.battery = ad.serviceData.battery;
442
453
  this.inMotion = ad.serviceData.inMotion;
443
454
  this.position = ad.serviceData.position;
444
- this.lightLevel = ad.serviceData.lightLevel;
445
455
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
446
456
  this.debugLog(
447
457
  `${this.device.deviceType}: ${this.accessory.displayName} calibration: ${ad.serviceData.calibration}, ` +
448
- `position: ${ad.serviceData.position}, lightLevel: ${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}, ` +
449
- `inMotion: ${ad.serviceData.inMotion}`);
458
+ `position: ${ad.serviceData.position}, inMotion: ${ad.serviceData.inMotion}, battery: ${ad.serviceData.battery}`);
450
459
 
451
460
  if (this.serviceData) {
452
461
  this.connected = true;
@@ -742,6 +751,56 @@ export class BlindTilt {
742
751
  this.doBlindTiltUpdate.next();
743
752
  }
744
753
 
754
+ /**
755
+ * Handle requests to set the value of the "Target Position" characteristic
756
+ */
757
+ async TargetHorizontalTiltAngleSet(value: CharacteristicValue): Promise<void> {
758
+ if (this.TargetHorizontalTiltAngle === this.accessory.context.TargetHorizontalTiltAngle) {
759
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set TargetHorizontalTiltAngle: ${value}`);
760
+ } else {
761
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetHorizontalTiltAngle: ${value}`);
762
+ }
763
+
764
+ this.TargetHorizontalTiltAngle = value;
765
+ if (this.device.mqttURL) {
766
+ this.mqttPublish('TargetHorizontalTiltAngle', this.TargetHorizontalTiltAngle);
767
+ }
768
+
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
+ this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.PositionState);
787
+ this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
788
+
789
+ /**
790
+ * If Blind Tilt movement time is short, the moving flag from backend is always false.
791
+ * The minimum time depends on the network control latency.
792
+ */
793
+ clearTimeout(this.setNewTargetTimer);
794
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateRate: ${this.updateRate}`);
795
+ if (this.setNewTarget) {
796
+ this.setNewTargetTimer = setTimeout(() => {
797
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} setNewTarget ${this.setNewTarget} timeout`);
798
+ this.setNewTarget = false;
799
+ }, this.updateRate * 1000);
800
+ }
801
+ this.doBlindTiltUpdate.next();
802
+ }
803
+
745
804
  async updateHomeKitCharacteristics(): Promise<void> {
746
805
  await this.setMinMax();
747
806
  if (this.CurrentPosition === undefined || Number.isNaN(this.CurrentPosition)) {
@@ -774,18 +833,27 @@ export class BlindTilt {
774
833
  this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.TargetPosition, Number(this.TargetPosition));
775
834
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: ${this.TargetPosition}`);
776
835
  }
777
- if (!this.device.curtain?.hide_lightsensor) {
778
- if (this.CurrentAmbientLightLevel === undefined || Number.isNaN(this.CurrentAmbientLightLevel)) {
779
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
780
- } else {
781
- if (this.device.mqttURL) {
782
- this.mqttPublish('CurrentAmbientLightLevel', this.CurrentAmbientLightLevel);
783
- }
784
- this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
785
- this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
786
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
787
- + ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
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);
788
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
+ if (this.TargetHorizontalTiltAngle === undefined || Number.isNaN(this.TargetHorizontalTiltAngle)) {
848
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} TargetHorizontalTiltAngle: ${this.TargetHorizontalTiltAngle}`);
849
+ } else {
850
+ if (this.device.mqttURL) {
851
+ this.mqttPublish('TargetHorizontalTiltAngle', this.TargetHorizontalTiltAngle);
852
+ }
853
+ this.accessory.context.TargetHorizontalTiltAngle = this.TargetHorizontalTiltAngle;
854
+ this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle, Number(this.TargetHorizontalTiltAngle));
855
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
856
+ + ` TargetHorizontalTiltAngle: ${this.TargetHorizontalTiltAngle}`);
789
857
  }
790
858
  if (this.BLE) {
791
859
  if (this.BatteryLevel === undefined) {
@@ -1020,9 +1088,6 @@ export class BlindTilt {
1020
1088
  this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
1021
1089
  this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.PositionState, e);
1022
1090
  this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
1023
- if (!this.device.curtain?.hide_lightsensor) {
1024
- this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
1025
- }
1026
1091
  if (this.BLE) {
1027
1092
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
1028
1093
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
@@ -1059,6 +1124,18 @@ export class BlindTilt {
1059
1124
  this.TargetPosition = this.accessory.context.TargetPosition;
1060
1125
  }
1061
1126
 
1127
+ if (this.CurrentHorizontalTiltAngle === undefined) {
1128
+ this.CurrentHorizontalTiltAngle = 0;
1129
+ } else {
1130
+ this.CurrentHorizontalTiltAngle = this.accessory.context.CurrentHorizontalTiltAngle;
1131
+ }
1132
+
1133
+ if (this.TargetHorizontalTiltAngle === undefined) {
1134
+ this.TargetHorizontalTiltAngle = 0;
1135
+ } else {
1136
+ this.TargetHorizontalTiltAngle = this.accessory.context.TargetHorizontalTiltAngle;
1137
+ }
1138
+
1062
1139
  if (this.PositionState === undefined) {
1063
1140
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
1064
1141
  } else {
@@ -138,6 +138,8 @@ export class Curtain {
138
138
  .getCharacteristic(this.platform.Characteristic.TargetPosition)
139
139
  .setProps({
140
140
  minStep: this.minStep(device),
141
+ minValue: 0,
142
+ maxValue: 100,
141
143
  validValueRanges: [0, 100],
142
144
  })
143
145
  .onSet(this.TargetPositionSet.bind(this));