@switchbot/homebridge-switchbot 2.8.0-beta.8 → 2.8.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 +4 -2
- package/README.md +1 -1
- package/dist/device/blindtilt.d.ts +1 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +7 -4
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +2 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +64 -50
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -0
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +7 -4
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +6 -3
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +43 -32
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +31 -34
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +2 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +8 -5
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +7 -4
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -0
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +8 -4
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -0
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +7 -4
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +2 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +9 -4
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +2 -0
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +10 -6
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -0
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +8 -4
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +44 -29
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +7 -4
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +2 -0
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +25 -0
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -0
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +67 -86
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +64 -63
- package/dist/platform.js.map +1 -1
- package/package.json +11 -11
- package/src/device/blindtilt.ts +8 -6
- package/src/device/bot.ts +64 -48
- package/src/device/ceilinglight.ts +11 -8
- package/src/device/colorbulb.ts +11 -8
- package/src/device/contact.ts +43 -29
- package/src/device/curtain.ts +32 -33
- package/src/device/hub.ts +9 -6
- package/src/device/humidifier.ts +9 -7
- package/src/device/iosensor.ts +9 -5
- package/src/device/lightstrip.ts +10 -7
- package/src/device/lock.ts +11 -5
- package/src/device/meter.ts +11 -6
- package/src/device/meterplus.ts +12 -8
- package/src/device/motion.ts +44 -26
- package/src/device/plug.ts +8 -5
- package/src/device/robotvacuumcleaner.ts +32 -3
- package/src/irdevice/airconditioner.ts +80 -94
- package/src/irdevice/airpurifier.ts +1 -1
- package/src/irdevice/camera.ts +1 -1
- package/src/irdevice/fan.ts +1 -1
- package/src/irdevice/light.ts +1 -1
- package/src/irdevice/other.ts +1 -1
- package/src/irdevice/tv.ts +1 -1
- package/src/irdevice/vacuumcleaner.ts +1 -1
- package/src/irdevice/waterheater.ts +1 -1
- package/src/platform.ts +73 -73
- package/src/settings.ts +1 -1
- package/.github/npm-version-script.js +0 -81
|
@@ -87,20 +87,11 @@ export class AirConditioner {
|
|
|
87
87
|
|
|
88
88
|
this.coolerService.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.CurrentTemperatureGet.bind(this));
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.
|
|
94
|
-
|
|
95
|
-
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
96
|
-
);
|
|
97
|
-
} else {
|
|
98
|
-
this.TargetHeaterCoolerState = 0 || 1 || 2;
|
|
99
|
-
this.ValidValues = [0, 1, 2];
|
|
100
|
-
this.debugLog(
|
|
101
|
-
`${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},` +
|
|
102
|
-
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
103
|
-
);
|
|
90
|
+
this.ValidValues = this.hide_automode ? [1, 2] : [0, 1, 2];
|
|
91
|
+
|
|
92
|
+
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
93
|
+
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
94
|
+
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
104
95
|
}
|
|
105
96
|
|
|
106
97
|
if (this.meter) {
|
|
@@ -120,6 +111,8 @@ export class AirConditioner {
|
|
|
120
111
|
this.coolerService
|
|
121
112
|
.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
|
|
122
113
|
.setProps({
|
|
114
|
+
minValue: 0,
|
|
115
|
+
maxValue: 35,
|
|
123
116
|
minStep: 0.5,
|
|
124
117
|
})
|
|
125
118
|
.onGet(this.ThresholdTemperatureGet.bind(this))
|
|
@@ -128,6 +121,8 @@ export class AirConditioner {
|
|
|
128
121
|
this.coolerService
|
|
129
122
|
.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
130
123
|
.setProps({
|
|
124
|
+
minValue: 0,
|
|
125
|
+
maxValue: 35,
|
|
131
126
|
minStep: 0.5,
|
|
132
127
|
})
|
|
133
128
|
.onGet(this.ThresholdTemperatureGet.bind(this))
|
|
@@ -230,23 +225,31 @@ export class AirConditioner {
|
|
|
230
225
|
}
|
|
231
226
|
const parameter = `${this.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
232
227
|
|
|
228
|
+
await this.UpdateCurrentHeaterCoolerState();
|
|
229
|
+
const bodyChange = JSON.stringify({
|
|
230
|
+
command: 'setAll',
|
|
231
|
+
parameter: `${parameter}`,
|
|
232
|
+
commandType: 'command',
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
await this.pushChanges(bodyChange);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private async UpdateCurrentHeaterCoolerState() {
|
|
233
239
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
234
240
|
await this.context();
|
|
235
|
-
if (this.ThresholdTemperature < this.
|
|
241
|
+
if (this.ThresholdTemperature < this.CurrentTemperature &&
|
|
242
|
+
this.TargetHeaterCoolerState !== this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
236
243
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
237
|
-
} else if (this.ThresholdTemperature > this.
|
|
244
|
+
} else if (this.ThresholdTemperature > this.CurrentTemperature &&
|
|
245
|
+
this.TargetHeaterCoolerState !== this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
238
246
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
247
|
+
} else {
|
|
248
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
239
249
|
}
|
|
240
250
|
} else {
|
|
241
251
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
242
252
|
}
|
|
243
|
-
const bodyChange = JSON.stringify({
|
|
244
|
-
command: 'setAll',
|
|
245
|
-
parameter: `${parameter}`,
|
|
246
|
-
commandType: 'command',
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
await this.pushChanges(bodyChange);
|
|
250
253
|
}
|
|
251
254
|
|
|
252
255
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
@@ -259,7 +262,7 @@ export class AirConditioner {
|
|
|
259
262
|
method: 'POST',
|
|
260
263
|
headers: this.platform.generateHeaders(),
|
|
261
264
|
});
|
|
262
|
-
const deviceStatus = await body.json();
|
|
265
|
+
const deviceStatus: any = await body.json();
|
|
263
266
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
264
267
|
this.statusCode(statusCode);
|
|
265
268
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
@@ -285,39 +288,29 @@ export class AirConditioner {
|
|
|
285
288
|
}
|
|
286
289
|
|
|
287
290
|
async CurrentTemperatureGet(): Promise<CharacteristicValue> {
|
|
288
|
-
if (this.meter) {
|
|
289
|
-
this.CurrentTemperature =
|
|
290
|
-
this.meter.context?.CurrentTemperature ||
|
|
291
|
-
this.meter.getService(this.platform.Service.TemperatureSensor)?.getCharacteristic(this.platform.Characteristic.CurrentTemperature).value ||
|
|
292
|
-
24;
|
|
291
|
+
if (this.meter?.context?.CurrentTemperature) {
|
|
292
|
+
this.accessory.context.CurrentTemperature = this.meter.context.CurrentTemperature;
|
|
293
293
|
this.debugLog(
|
|
294
294
|
`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
295
|
-
+ `Using CurrentTemperature from ${this.meter.context
|
|
295
|
+
+ `Using CurrentTemperature from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`,
|
|
296
296
|
);
|
|
297
|
-
} else if (this.CurrentTemperature === undefined) {
|
|
298
|
-
this.CurrentTemperature = 24;
|
|
299
|
-
} else {
|
|
300
|
-
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
301
297
|
}
|
|
298
|
+
|
|
299
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
302
300
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
303
301
|
return this.CurrentTemperature;
|
|
304
302
|
}
|
|
305
303
|
|
|
306
304
|
async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
|
|
307
|
-
if (this.meter) {
|
|
308
|
-
this.CurrentRelativeHumidity =
|
|
309
|
-
this.meter.context?.CurrentRelativeHumidity ||
|
|
310
|
-
this.meter.getService(this.platform.Service.HumiditySensor)?.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).value ||
|
|
311
|
-
0;
|
|
305
|
+
if (this.meter?.context?.CurrentRelativeHumidity) {
|
|
306
|
+
this.accessory.context.CurrentRelativeHumidity = this.meter.context.CurrentRelativeHumidity;
|
|
312
307
|
this.debugLog(
|
|
313
308
|
`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
314
|
-
+ `Using CurrentRelativeHumidity from ${this.meter.context
|
|
309
|
+
+ `Using CurrentRelativeHumidity from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`,
|
|
315
310
|
);
|
|
316
|
-
} else if (this.CurrentRelativeHumidity === undefined) {
|
|
317
|
-
this.CurrentRelativeHumidity = 0;
|
|
318
|
-
} else {
|
|
319
|
-
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
|
|
320
311
|
}
|
|
312
|
+
|
|
313
|
+
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
321
314
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
322
315
|
return this.CurrentRelativeHumidity as CharacteristicValue;
|
|
323
316
|
}
|
|
@@ -338,7 +331,9 @@ export class AirConditioner {
|
|
|
338
331
|
} else {
|
|
339
332
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
340
333
|
}
|
|
341
|
-
this.RotationSpeed =
|
|
334
|
+
this.RotationSpeed = value;
|
|
335
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
336
|
+
`Set RotationSpeed: ${this.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
342
337
|
this.pushAirConditionerStatusChanges();
|
|
343
338
|
}
|
|
344
339
|
|
|
@@ -360,25 +355,12 @@ export class AirConditioner {
|
|
|
360
355
|
}
|
|
361
356
|
|
|
362
357
|
async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
} else if (this.ValidValues === this.valid12) {
|
|
370
|
-
this.TargetHeaterCoolerState =
|
|
371
|
-
this.platform.Characteristic.TargetHeaterCoolerState.COOL || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
372
|
-
this.debugLog(
|
|
373
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
374
|
-
` ValidValues: ${this.ValidValues}`,
|
|
375
|
-
);
|
|
376
|
-
} else {
|
|
377
|
-
this.debugLog(
|
|
378
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
379
|
-
` ValidValues: ${this.ValidValues}`,
|
|
380
|
-
);
|
|
381
|
-
}
|
|
358
|
+
const targetState = this.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
|
|
359
|
+
this.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
|
|
360
|
+
this.debugLog(
|
|
361
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Get (${this.getTargetHeaterCoolerStateName()})` +
|
|
362
|
+
` TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`,
|
|
363
|
+
);
|
|
382
364
|
return this.TargetHeaterCoolerState;
|
|
383
365
|
}
|
|
384
366
|
|
|
@@ -420,27 +402,29 @@ export class AirConditioner {
|
|
|
420
402
|
}
|
|
421
403
|
|
|
422
404
|
async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
} else if (this.ThresholdTemperature > this.accessory.context.CurrentTemperature) {
|
|
430
|
-
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
431
|
-
this.debugLog(
|
|
432
|
-
`${this.device.remoteType}: ${this.accessory.displayName}` + ` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
} else {
|
|
436
|
-
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
437
|
-
this.debugLog(
|
|
438
|
-
`${this.device.remoteType}: ${this.accessory.displayName}` + ` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
439
|
-
);
|
|
440
|
-
}
|
|
405
|
+
await this.UpdateCurrentHeaterCoolerState();
|
|
406
|
+
this.debugLog(
|
|
407
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
408
|
+
` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
409
|
+
);
|
|
410
|
+
|
|
441
411
|
return this.CurrentHeaterCoolerState;
|
|
442
412
|
}
|
|
443
413
|
|
|
414
|
+
|
|
415
|
+
private getTargetHeaterCoolerStateName(): string {
|
|
416
|
+
switch (this.TargetHeaterCoolerState) {
|
|
417
|
+
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
|
|
418
|
+
return 'AUTO';
|
|
419
|
+
case this.platform.Characteristic.TargetHeaterCoolerState.HEAT:
|
|
420
|
+
return 'HEAT';
|
|
421
|
+
case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
|
|
422
|
+
return 'COOL';
|
|
423
|
+
default:
|
|
424
|
+
return this.TargetHeaterCoolerState.toString();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
444
428
|
async ThresholdTemperatureGet(): Promise<CharacteristicValue> {
|
|
445
429
|
await this.context();
|
|
446
430
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.ThresholdTemperature}`);
|
|
@@ -650,18 +634,23 @@ export class AirConditioner {
|
|
|
650
634
|
} else {
|
|
651
635
|
this.Active = this.accessory.context.Active;
|
|
652
636
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
} else if (this.CurrentTemperature) {
|
|
656
|
-
this.CurrentTemperature;
|
|
657
|
-
} else if (this.accessory.context.CurrentTemperature === undefined) {
|
|
637
|
+
|
|
638
|
+
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
658
639
|
this.CurrentTemperature = 24;
|
|
659
640
|
} else {
|
|
660
|
-
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
641
|
+
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
661
642
|
}
|
|
662
643
|
|
|
663
|
-
if (this.ThresholdTemperature === undefined) {
|
|
644
|
+
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
664
645
|
this.ThresholdTemperature = 24;
|
|
646
|
+
} else {
|
|
647
|
+
this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
651
|
+
this.RotationSpeed = 4;
|
|
652
|
+
} else {
|
|
653
|
+
this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
665
654
|
}
|
|
666
655
|
|
|
667
656
|
if (this.device.irair?.hide_automode) {
|
|
@@ -672,14 +661,11 @@ export class AirConditioner {
|
|
|
672
661
|
this.accessory.context.hide_automode = this.hide_automode;
|
|
673
662
|
}
|
|
674
663
|
|
|
675
|
-
if (this.device.irair?.meterUuid) {
|
|
676
|
-
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === this.device.irair?.meterUuid);
|
|
677
|
-
}
|
|
678
664
|
if (this.meter) {
|
|
679
|
-
if (this.CurrentRelativeHumidity === undefined) {
|
|
665
|
+
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
680
666
|
this.CurrentRelativeHumidity = 0;
|
|
681
667
|
} else {
|
|
682
|
-
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
|
|
668
|
+
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
683
669
|
}
|
|
684
670
|
}
|
|
685
671
|
}
|
|
@@ -218,7 +218,7 @@ export class AirPurifier {
|
|
|
218
218
|
method: 'POST',
|
|
219
219
|
headers: this.platform.generateHeaders(),
|
|
220
220
|
});
|
|
221
|
-
const deviceStatus = await body.json();
|
|
221
|
+
const deviceStatus: any = await body.json();
|
|
222
222
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
223
223
|
this.statusCode(statusCode);
|
|
224
224
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -123,7 +123,7 @@ export class Camera {
|
|
|
123
123
|
method: 'POST',
|
|
124
124
|
headers: this.platform.generateHeaders(),
|
|
125
125
|
});
|
|
126
|
-
const deviceStatus = await body.json();
|
|
126
|
+
const deviceStatus: any = await body.json();
|
|
127
127
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
128
128
|
this.statusCode(statusCode);
|
|
129
129
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -243,7 +243,7 @@ export class Fan {
|
|
|
243
243
|
method: 'POST',
|
|
244
244
|
headers: this.platform.generateHeaders(),
|
|
245
245
|
});
|
|
246
|
-
const deviceStatus = await body.json();
|
|
246
|
+
const deviceStatus: any = await body.json();
|
|
247
247
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
248
248
|
this.statusCode(statusCode);
|
|
249
249
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
package/src/irdevice/light.ts
CHANGED
|
@@ -147,7 +147,7 @@ export class Light {
|
|
|
147
147
|
method: 'POST',
|
|
148
148
|
headers: this.platform.generateHeaders(),
|
|
149
149
|
});
|
|
150
|
-
const deviceStatus = await body.json();
|
|
150
|
+
const deviceStatus: any = await body.json();
|
|
151
151
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
152
152
|
this.statusCode(statusCode);
|
|
153
153
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
package/src/irdevice/other.ts
CHANGED
|
@@ -142,7 +142,7 @@ export class Others {
|
|
|
142
142
|
method: 'POST',
|
|
143
143
|
headers: this.platform.generateHeaders(),
|
|
144
144
|
});
|
|
145
|
-
const deviceStatus = await body.json();
|
|
145
|
+
const deviceStatus: any = await body.json();
|
|
146
146
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
147
147
|
this.statusCode(statusCode);
|
|
148
148
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -375,7 +375,7 @@ export class TV {
|
|
|
375
375
|
method: 'POST',
|
|
376
376
|
headers: this.platform.generateHeaders(),
|
|
377
377
|
});
|
|
378
|
-
const deviceStatus = await body.json();
|
|
378
|
+
const deviceStatus: any = await body.json();
|
|
379
379
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
380
380
|
this.statusCode(statusCode);
|
|
381
381
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
@@ -119,7 +119,7 @@ export class VacuumCleaner {
|
|
|
119
119
|
method: 'POST',
|
|
120
120
|
headers: this.platform.generateHeaders(),
|
|
121
121
|
});
|
|
122
|
-
const deviceStatus = await body.json();
|
|
122
|
+
const deviceStatus: any = await body.json();
|
|
123
123
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
124
124
|
this.statusCode(statusCode);
|
|
125
125
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
@@ -128,7 +128,7 @@ export class WaterHeater {
|
|
|
128
128
|
method: 'POST',
|
|
129
129
|
headers: this.platform.generateHeaders(),
|
|
130
130
|
});
|
|
131
|
-
const deviceStatus = await body.json();
|
|
131
|
+
const deviceStatus: any = await body.json();
|
|
132
132
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
133
133
|
this.statusCode(statusCode);
|
|
134
134
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
package/src/platform.ts
CHANGED
|
@@ -300,18 +300,42 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
300
300
|
const { body, statusCode, headers } = await request(Devices, {
|
|
301
301
|
headers: this.generateHeaders(),
|
|
302
302
|
});
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
303
|
+
if (statusCode === 200) {
|
|
304
|
+
const devicesAPI: any = await body.json();
|
|
305
|
+
this.debugLog(`Devices: ${JSON.stringify(devicesAPI.body)}`);
|
|
306
|
+
this.debugLog(`Headers: ${JSON.stringify(headers)}`);
|
|
307
|
+
// SwitchBot Devices
|
|
308
|
+
const deviceLists = devicesAPI.body.deviceList;
|
|
309
|
+
if (!this.config.options?.devices) {
|
|
310
|
+
this.debugLog(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
311
|
+
if (deviceLists.length === 0) {
|
|
312
|
+
this.debugLog(`SwitchBot API Currently Doesn't Have Any Devices With Cloud Services Enabled: ${JSON.stringify(devicesAPI.body)}`);
|
|
313
|
+
} else {
|
|
314
|
+
const devices = deviceLists.map((v: any) => v);
|
|
315
|
+
for (const device of devices) {
|
|
316
|
+
if (device.deviceType) {
|
|
317
|
+
if (device.configDeviceName) {
|
|
318
|
+
device.deviceName = device.configDeviceName;
|
|
319
|
+
}
|
|
320
|
+
this.createDevice(device);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
} else if (this.config.credentials?.token && this.config.options.devices) {
|
|
325
|
+
this.debugLog(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
326
|
+
const deviceConfigs = this.config.options?.devices;
|
|
327
|
+
|
|
328
|
+
const mergeBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
|
|
329
|
+
a1.map((itm: { deviceId: string }) => ({
|
|
330
|
+
...a2.find(
|
|
331
|
+
(item: { deviceId: string }) =>
|
|
332
|
+
item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item,
|
|
333
|
+
),
|
|
334
|
+
...itm,
|
|
335
|
+
}));
|
|
336
|
+
|
|
337
|
+
const devices = mergeBydeviceId(deviceLists, deviceConfigs);
|
|
338
|
+
this.debugLog(`SwitchBot Devices: ${JSON.stringify(devices)}`);
|
|
315
339
|
for (const device of devices) {
|
|
316
340
|
if (device.deviceType) {
|
|
317
341
|
if (device.configDeviceName) {
|
|
@@ -320,72 +344,51 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
320
344
|
this.createDevice(device);
|
|
321
345
|
}
|
|
322
346
|
}
|
|
347
|
+
} else {
|
|
348
|
+
this.errorLog('SwitchBot Token Supplied, Issue with Auth.');
|
|
323
349
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const mergeBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
|
|
329
|
-
a1.map((itm: { deviceId: string }) => ({
|
|
330
|
-
...a2.find(
|
|
331
|
-
(item: { deviceId: string }) =>
|
|
332
|
-
item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item,
|
|
333
|
-
),
|
|
334
|
-
...itm,
|
|
335
|
-
}));
|
|
336
|
-
|
|
337
|
-
const devices = mergeBydeviceId(deviceLists, deviceConfigs);
|
|
338
|
-
this.debugLog(`SwitchBot Devices: ${JSON.stringify(devices)}`);
|
|
339
|
-
for (const device of devices) {
|
|
340
|
-
if (device.deviceType) {
|
|
341
|
-
if (device.configDeviceName) {
|
|
342
|
-
device.deviceName = device.configDeviceName;
|
|
343
|
-
}
|
|
344
|
-
this.createDevice(device);
|
|
345
|
-
}
|
|
350
|
+
if (devicesAPI.body.deviceList.length !== 0) {
|
|
351
|
+
this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
352
|
+
} else {
|
|
353
|
+
this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
346
354
|
}
|
|
347
|
-
} else {
|
|
348
|
-
this.errorLog('SwitchBot Token Supplied, Issue with Auth.');
|
|
349
|
-
}
|
|
350
|
-
if (devicesAPI.body.deviceList.length !== 0) {
|
|
351
|
-
this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
352
|
-
} else {
|
|
353
|
-
this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
354
|
-
}
|
|
355
355
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
356
|
+
// IR Devices
|
|
357
|
+
const irDeviceLists = devicesAPI.body.infraredRemoteList;
|
|
358
|
+
if (!this.config.options?.irdevices) {
|
|
359
|
+
this.debugLog(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
360
|
+
const devices = irDeviceLists.map((v: any) => v);
|
|
361
|
+
for (const device of devices) {
|
|
362
|
+
if (device.remoteType) {
|
|
363
|
+
this.createIRDevice(device);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
this.debugLog(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
368
|
+
const irDeviceConfig = this.config.options?.irdevices;
|
|
369
|
+
|
|
370
|
+
const mergeIRBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
|
|
371
|
+
a1.map((itm: { deviceId: string }) => ({
|
|
372
|
+
...a2.find(
|
|
373
|
+
(item: { deviceId: string }) =>
|
|
374
|
+
item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item,
|
|
375
|
+
),
|
|
376
|
+
...itm,
|
|
377
|
+
}));
|
|
378
|
+
|
|
379
|
+
const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
|
|
380
|
+
this.debugLog(`IR Devices: ${JSON.stringify(devices)}`);
|
|
381
|
+
for (const device of devices) {
|
|
363
382
|
this.createIRDevice(device);
|
|
364
383
|
}
|
|
365
384
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const mergeIRBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
|
|
371
|
-
a1.map((itm: { deviceId: string }) => ({
|
|
372
|
-
...a2.find(
|
|
373
|
-
(item: { deviceId: string }) =>
|
|
374
|
-
item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item,
|
|
375
|
-
),
|
|
376
|
-
...itm,
|
|
377
|
-
}));
|
|
378
|
-
|
|
379
|
-
const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
|
|
380
|
-
this.debugLog(`IR Devices: ${JSON.stringify(devices)}`);
|
|
381
|
-
for (const device of devices) {
|
|
382
|
-
this.createIRDevice(device);
|
|
385
|
+
if (devicesAPI.body.infraredRemoteList.length !== 0) {
|
|
386
|
+
this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
387
|
+
} else {
|
|
388
|
+
this.debugLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
383
389
|
}
|
|
384
|
-
}
|
|
385
|
-
if (devicesAPI.body.infraredRemoteList.length !== 0) {
|
|
386
|
-
this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
387
390
|
} else {
|
|
388
|
-
this.
|
|
391
|
+
this.statusCode(statusCode);
|
|
389
392
|
}
|
|
390
393
|
} catch (e: any) {
|
|
391
394
|
this.debugErrorLog(
|
|
@@ -1665,9 +1668,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1665
1668
|
// the cached devices we stored in the `configureAccessory` method above
|
|
1666
1669
|
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
1667
1670
|
|
|
1668
|
-
if (device.irair?.meterType && device.irair?.meterId) {
|
|
1669
|
-
device.irair.meterUuid = this.api.hap.uuid.generate(`${device.irair.meterId}-${device.irair.meterType}`);
|
|
1670
|
-
}
|
|
1671
1671
|
if (existingAccessory) {
|
|
1672
1672
|
// the accessory already exists
|
|
1673
1673
|
if (!device.hide_device && device.hubDeviceId) {
|
package/src/settings.ts
CHANGED
|
@@ -286,7 +286,7 @@ export type deviceStatus = {
|
|
|
286
286
|
childLock?: boolean; //determines if a Humidifier's safety lock is on or not. (Used by the following deviceTypes: Humidifier)
|
|
287
287
|
sound?: boolean; //determines if a Humidifier is muted or not. (Used by the following deviceTypes: Humidifier)
|
|
288
288
|
lackWater?: boolean; //determines if the water tank is empty or not. (Used by the following deviceTypes: Humidifier)
|
|
289
|
-
version?: number; //the version of the device. (Used by the following deviceTypes: Blind Tilt)
|
|
289
|
+
version?: number; //the version of the device. (Used by the following deviceTypes: Blind Tilt, Meter, MeterPlus, IOSensor)
|
|
290
290
|
direction?: string; //the opening direction of a Blind Tilt device. (Used by the following deviceTypes: Blind Tilt)
|
|
291
291
|
runStatus?: string; //'static' when not moving. (Used by the following deviceTypes: Blind Tilt)
|
|
292
292
|
mode?: number; //available for devices. the fan mode. (Used by the following deviceTypes: Smart Fan)
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#!/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require("fs");
|
|
8
|
-
const semver = require("semver");
|
|
9
|
-
const child_process = require("child_process");
|
|
10
|
-
const assert = require("assert");
|
|
11
|
-
|
|
12
|
-
const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
|
|
13
|
-
|
|
14
|
-
// Load the contents of the package.json file
|
|
15
|
-
const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
16
|
-
|
|
17
|
-
let refArgument = process.argv[2];
|
|
18
|
-
let tagArgument = process.argv[3] || "latest";
|
|
19
|
-
|
|
20
|
-
if (refArgument == null) {
|
|
21
|
-
console.error("ref argument is missing");
|
|
22
|
-
console.error("Usage: npm-version-script.js <ref> [tag]");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Queries the NPM registry for the latest version for the provided tag.
|
|
28
|
-
* @param tag The tag to query for.
|
|
29
|
-
* @returns {string} Returns the version.
|
|
30
|
-
*/
|
|
31
|
-
function getTagVersionFromNpm(tag) {
|
|
32
|
-
try {
|
|
33
|
-
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
|
|
34
|
-
} catch (e) {
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function desiredTargetVersion(ref) {
|
|
40
|
-
// ref is a GitHub action ref string
|
|
41
|
-
if (ref.startsWith("refs/pull/")) {
|
|
42
|
-
throw Error("The version script was executed inside a PR!");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
assert(ref.startsWith("refs/heads/"))
|
|
46
|
-
let branchName = ref.slice("refs/heads/".length);
|
|
47
|
-
|
|
48
|
-
let results = branchName.match(BRANCH_VERSION_PATTERN);
|
|
49
|
-
if (results != null) {
|
|
50
|
-
if (results[1] !== tagArgument) {
|
|
51
|
-
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return results[2];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// legacy mode were we use the `betaVersion` property in the package.json
|
|
58
|
-
if (branchName === "beta" && packageJSON.betaVersion) {
|
|
59
|
-
return packageJSON.betaVersion
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// derive the base version from the branch ref
|
|
66
|
-
const baseVersion = desiredTargetVersion(refArgument);
|
|
67
|
-
|
|
68
|
-
// query the npm registry for the latest version of the provided tag name
|
|
69
|
-
const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
|
|
70
|
-
const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
71
|
-
|
|
72
|
-
let publishTag;
|
|
73
|
-
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
|
|
74
|
-
publishTag = latestReleasedVersion; // set the current latest beta to be incremented
|
|
75
|
-
} else {
|
|
76
|
-
publishTag = baseVersion; // start of with a new beta version
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// save the package.json
|
|
80
|
-
packageJSON.version = publishTag;
|
|
81
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
|