@switchbot/homebridge-switchbot 2.8.0-beta.2 → 2.8.0-beta.20
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 +9 -6
- 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 +66 -52
- 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 +12 -9
- 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 +8 -5
- 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 +45 -34
- 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 +33 -36
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +3 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +30 -5
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +9 -6
- 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 +10 -6
- 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 +9 -6
- 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 +11 -6
- 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 +12 -8
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +4 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +56 -54
- 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 +46 -31
- 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 +9 -6
- 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 +27 -2
- 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 +71 -88
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +3 -3
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +3 -3
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -2
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +3 -3
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +3 -3
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +3 -3
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +2 -2
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +3 -3
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +3 -3
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +3 -3
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +67 -65
- package/dist/platform.js.map +1 -1
- package/package.json +11 -11
- package/src/device/blindtilt.ts +10 -8
- package/src/device/bot.ts +66 -50
- package/src/device/ceilinglight.ts +17 -11
- package/src/device/colorbulb.ts +15 -10
- package/src/device/contact.ts +45 -31
- package/src/device/curtain.ts +34 -35
- package/src/device/hub.ts +32 -6
- package/src/device/humidifier.ts +12 -9
- package/src/device/iosensor.ts +11 -7
- package/src/device/lightstrip.ts +14 -9
- package/src/device/lock.ts +14 -7
- package/src/device/meter.ts +13 -8
- package/src/device/meterplus.ts +62 -55
- package/src/device/motion.ts +46 -28
- package/src/device/plug.ts +10 -7
- package/src/device/robotvacuumcleaner.ts +34 -5
- package/src/irdevice/airconditioner.ts +84 -96
- package/src/irdevice/airpurifier.ts +6 -6
- package/src/irdevice/camera.ts +6 -6
- package/src/irdevice/fan.ts +6 -6
- package/src/irdevice/light.ts +6 -6
- package/src/irdevice/other.ts +6 -6
- package/src/irdevice/tv.ts +6 -6
- package/src/irdevice/vacuumcleaner.ts +6 -6
- package/src/irdevice/waterheater.ts +6 -6
- package/src/platform.ts +76 -75
- package/src/settings.ts +1 -1
|
@@ -50,11 +50,11 @@ export class AirConditioner {
|
|
|
50
50
|
) {
|
|
51
51
|
// default placeholders
|
|
52
52
|
this.logs({ device });
|
|
53
|
-
this.config({ device });
|
|
54
53
|
this.context();
|
|
55
54
|
this.disablePushOnChanges({ device });
|
|
56
55
|
this.disablePushOffChanges({ device });
|
|
57
56
|
this.disablePushDetailChanges({ device });
|
|
57
|
+
this.config({ device });
|
|
58
58
|
|
|
59
59
|
// set accessory information
|
|
60
60
|
accessory
|
|
@@ -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,37 +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
|
-
`${this.device.remoteType}: ${this.accessory.displayName}
|
|
294
|
+
`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
295
|
+
+ `Using CurrentTemperature from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`,
|
|
295
296
|
);
|
|
296
|
-
} else if (this.CurrentTemperature === undefined) {
|
|
297
|
-
this.CurrentTemperature = 24;
|
|
298
|
-
} else {
|
|
299
|
-
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
300
297
|
}
|
|
298
|
+
|
|
299
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
301
300
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
302
301
|
return this.CurrentTemperature;
|
|
303
302
|
}
|
|
304
303
|
|
|
305
304
|
async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
|
|
306
|
-
if (this.meter) {
|
|
307
|
-
this.CurrentRelativeHumidity =
|
|
308
|
-
this.meter.context?.CurrentRelativeHumidity ||
|
|
309
|
-
this.meter.getService(this.platform.Service.HumiditySensor)?.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).value ||
|
|
310
|
-
0;
|
|
305
|
+
if (this.meter?.context?.CurrentRelativeHumidity) {
|
|
306
|
+
this.accessory.context.CurrentRelativeHumidity = this.meter.context.CurrentRelativeHumidity;
|
|
311
307
|
this.debugLog(
|
|
312
|
-
`${this.device.remoteType}: ${this.accessory.displayName}
|
|
308
|
+
`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
309
|
+
+ `Using CurrentRelativeHumidity from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`,
|
|
313
310
|
);
|
|
314
|
-
} else if (this.CurrentRelativeHumidity === undefined) {
|
|
315
|
-
this.CurrentRelativeHumidity = 0;
|
|
316
|
-
} else {
|
|
317
|
-
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
|
|
318
311
|
}
|
|
312
|
+
|
|
313
|
+
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
319
314
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
320
315
|
return this.CurrentRelativeHumidity as CharacteristicValue;
|
|
321
316
|
}
|
|
@@ -336,7 +331,9 @@ export class AirConditioner {
|
|
|
336
331
|
} else {
|
|
337
332
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
338
333
|
}
|
|
339
|
-
this.RotationSpeed =
|
|
334
|
+
this.RotationSpeed = value;
|
|
335
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
336
|
+
`Set RotationSpeed: ${this.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
340
337
|
this.pushAirConditionerStatusChanges();
|
|
341
338
|
}
|
|
342
339
|
|
|
@@ -358,25 +355,12 @@ export class AirConditioner {
|
|
|
358
355
|
}
|
|
359
356
|
|
|
360
357
|
async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
} else if (this.ValidValues === this.valid12) {
|
|
368
|
-
this.TargetHeaterCoolerState =
|
|
369
|
-
this.platform.Characteristic.TargetHeaterCoolerState.COOL || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
370
|
-
this.debugLog(
|
|
371
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
372
|
-
` ValidValues: ${this.ValidValues}`,
|
|
373
|
-
);
|
|
374
|
-
} else {
|
|
375
|
-
this.debugLog(
|
|
376
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
377
|
-
` ValidValues: ${this.ValidValues}`,
|
|
378
|
-
);
|
|
379
|
-
}
|
|
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
|
+
);
|
|
380
364
|
return this.TargetHeaterCoolerState;
|
|
381
365
|
}
|
|
382
366
|
|
|
@@ -418,27 +402,29 @@ export class AirConditioner {
|
|
|
418
402
|
}
|
|
419
403
|
|
|
420
404
|
async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
} else if (this.ThresholdTemperature > this.accessory.context.CurrentTemperature) {
|
|
428
|
-
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
429
|
-
this.debugLog(
|
|
430
|
-
`${this.device.remoteType}: ${this.accessory.displayName}` + ` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
} else {
|
|
434
|
-
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
435
|
-
this.debugLog(
|
|
436
|
-
`${this.device.remoteType}: ${this.accessory.displayName}` + ` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
437
|
-
);
|
|
438
|
-
}
|
|
405
|
+
await this.UpdateCurrentHeaterCoolerState();
|
|
406
|
+
this.debugLog(
|
|
407
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
408
|
+
` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
409
|
+
);
|
|
410
|
+
|
|
439
411
|
return this.CurrentHeaterCoolerState;
|
|
440
412
|
}
|
|
441
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
|
+
|
|
442
428
|
async ThresholdTemperatureGet(): Promise<CharacteristicValue> {
|
|
443
429
|
await this.context();
|
|
444
430
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.ThresholdTemperature}`);
|
|
@@ -648,18 +634,23 @@ export class AirConditioner {
|
|
|
648
634
|
} else {
|
|
649
635
|
this.Active = this.accessory.context.Active;
|
|
650
636
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
} else if (this.CurrentTemperature) {
|
|
654
|
-
this.CurrentTemperature;
|
|
655
|
-
} else if (this.accessory.context.CurrentTemperature === undefined) {
|
|
637
|
+
|
|
638
|
+
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
656
639
|
this.CurrentTemperature = 24;
|
|
657
640
|
} else {
|
|
658
|
-
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
641
|
+
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
659
642
|
}
|
|
660
643
|
|
|
661
|
-
if (this.ThresholdTemperature === undefined) {
|
|
644
|
+
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
662
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;
|
|
663
654
|
}
|
|
664
655
|
|
|
665
656
|
if (this.device.irair?.hide_automode) {
|
|
@@ -670,14 +661,11 @@ export class AirConditioner {
|
|
|
670
661
|
this.accessory.context.hide_automode = this.hide_automode;
|
|
671
662
|
}
|
|
672
663
|
|
|
673
|
-
if (this.device.irair?.meterUuid) {
|
|
674
|
-
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === this.device.irair?.meterUuid);
|
|
675
|
-
}
|
|
676
664
|
if (this.meter) {
|
|
677
|
-
if (this.CurrentRelativeHumidity === undefined) {
|
|
665
|
+
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
678
666
|
this.CurrentRelativeHumidity = 0;
|
|
679
667
|
} else {
|
|
680
|
-
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
|
|
668
|
+
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
681
669
|
}
|
|
682
670
|
}
|
|
683
671
|
}
|
|
@@ -715,7 +703,7 @@ export class AirConditioner {
|
|
|
715
703
|
config['disablePushDetail'] = device.disablePushDetail;
|
|
716
704
|
}
|
|
717
705
|
if (Object.entries(config).length !== 0) {
|
|
718
|
-
this.
|
|
706
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
719
707
|
}
|
|
720
708
|
}
|
|
721
709
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
1
2
|
import { request } from 'undici';
|
|
2
3
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import { irDevicesConfig, irdevice
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
|
+
import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -45,10 +45,10 @@ export class AirPurifier {
|
|
|
45
45
|
) {
|
|
46
46
|
// default placeholders
|
|
47
47
|
this.logs(device);
|
|
48
|
-
this.config(device);
|
|
49
48
|
this.context();
|
|
50
49
|
this.disablePushOnChanges({ device });
|
|
51
50
|
this.disablePushOffChanges({ device });
|
|
51
|
+
this.config(device);
|
|
52
52
|
|
|
53
53
|
// set accessory information
|
|
54
54
|
accessory
|
|
@@ -211,14 +211,14 @@ export class AirPurifier {
|
|
|
211
211
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
212
212
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
213
213
|
if (this.device.connectionType === 'OpenAPI') {
|
|
214
|
-
this.
|
|
214
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
215
215
|
try {
|
|
216
216
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
217
217
|
body: bodyChange,
|
|
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)}`);
|
|
@@ -420,7 +420,7 @@ export class AirPurifier {
|
|
|
420
420
|
config['disablePushOff'] = device.disablePushOff;
|
|
421
421
|
}
|
|
422
422
|
if (Object.entries(config).length !== 0) {
|
|
423
|
-
this.
|
|
423
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
1
2
|
import { request } from 'undici';
|
|
2
3
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import { irDevicesConfig, irdevice
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
|
+
import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -27,10 +27,10 @@ export class Camera {
|
|
|
27
27
|
) {
|
|
28
28
|
// default placeholders
|
|
29
29
|
this.logs(device);
|
|
30
|
-
this.config(device);
|
|
31
30
|
this.context();
|
|
32
31
|
this.disablePushOnChanges({ device });
|
|
33
32
|
this.disablePushOffChanges({ device });
|
|
33
|
+
this.config(device);
|
|
34
34
|
|
|
35
35
|
// set accessory information
|
|
36
36
|
accessory
|
|
@@ -116,14 +116,14 @@ export class Camera {
|
|
|
116
116
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
117
117
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
118
118
|
if (this.device.connectionType === 'OpenAPI') {
|
|
119
|
-
this.
|
|
119
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
120
120
|
try {
|
|
121
121
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
122
122
|
body: bodyChange,
|
|
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)}`);
|
|
@@ -298,7 +298,7 @@ export class Camera {
|
|
|
298
298
|
config['disablePushOff'] = device.disablePushOff;
|
|
299
299
|
}
|
|
300
300
|
if (Object.entries(config).length !== 0) {
|
|
301
|
-
this.
|
|
301
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
1
2
|
import { request } from 'undici';
|
|
2
3
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import {
|
|
4
|
-
import { irdevice, irDevicesConfig, Devices } from '../settings';
|
|
4
|
+
import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -37,10 +37,10 @@ export class Fan {
|
|
|
37
37
|
) {
|
|
38
38
|
// default placeholders
|
|
39
39
|
this.logs(device);
|
|
40
|
-
this.config(device);
|
|
41
40
|
this.context();
|
|
42
41
|
this.disablePushOnChanges({ device });
|
|
43
42
|
this.disablePushOffChanges({ device });
|
|
43
|
+
this.config(device);
|
|
44
44
|
|
|
45
45
|
// set accessory information
|
|
46
46
|
accessory
|
|
@@ -236,14 +236,14 @@ export class Fan {
|
|
|
236
236
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
237
237
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
238
238
|
if (this.device.connectionType === 'OpenAPI') {
|
|
239
|
-
this.
|
|
239
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
240
240
|
try {
|
|
241
241
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
242
242
|
body: bodyChange,
|
|
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)}`);
|
|
@@ -434,7 +434,7 @@ export class Fan {
|
|
|
434
434
|
config['disablePushOff'] = device.disablePushOff;
|
|
435
435
|
}
|
|
436
436
|
if (Object.entries(config).length !== 0) {
|
|
437
|
-
this.
|
|
437
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
|
package/src/irdevice/light.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
1
2
|
import { request } from 'undici';
|
|
2
3
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import { irDevicesConfig, irdevice
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
|
+
import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -27,10 +27,10 @@ export class Light {
|
|
|
27
27
|
) {
|
|
28
28
|
// default placeholders
|
|
29
29
|
this.logs(device);
|
|
30
|
-
this.config(device);
|
|
31
30
|
this.context();
|
|
32
31
|
this.disablePushOnChanges({ device });
|
|
33
32
|
this.disablePushOffChanges({ device });
|
|
33
|
+
this.config(device);
|
|
34
34
|
|
|
35
35
|
// set accessory information
|
|
36
36
|
accessory
|
|
@@ -140,14 +140,14 @@ export class Light {
|
|
|
140
140
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
141
141
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
142
142
|
if (this.device.connectionType === 'OpenAPI') {
|
|
143
|
-
this.
|
|
143
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
144
144
|
try {
|
|
145
145
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
146
146
|
body: bodyChange,
|
|
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)}`);
|
|
@@ -323,7 +323,7 @@ export class Light {
|
|
|
323
323
|
config['disablePushOff'] = device.disablePushOff;
|
|
324
324
|
}
|
|
325
325
|
if (Object.entries(config).length !== 0) {
|
|
326
|
-
this.
|
|
326
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
|
package/src/irdevice/other.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
1
2
|
import { request } from 'undici';
|
|
2
3
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import { irDevicesConfig, irdevice
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
|
+
import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -29,10 +29,10 @@ export class Others {
|
|
|
29
29
|
// default placeholders
|
|
30
30
|
this.logs(device);
|
|
31
31
|
this.deviceType(device);
|
|
32
|
-
this.config(device);
|
|
33
32
|
this.context();
|
|
34
33
|
this.disablePushOnChanges({ device });
|
|
35
34
|
this.disablePushOffChanges({ device });
|
|
35
|
+
this.config(device);
|
|
36
36
|
|
|
37
37
|
// set accessory information
|
|
38
38
|
accessory
|
|
@@ -135,14 +135,14 @@ export class Others {
|
|
|
135
135
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
136
136
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
137
137
|
if (this.device.connectionType === 'OpenAPI') {
|
|
138
|
-
this.
|
|
138
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
139
139
|
try {
|
|
140
140
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
141
141
|
body: bodyChange,
|
|
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)}`);
|
|
@@ -329,7 +329,7 @@ export class Others {
|
|
|
329
329
|
config['disablePushOff'] = device.disablePushOff;
|
|
330
330
|
}
|
|
331
331
|
if (Object.entries(config).length !== 0) {
|
|
332
|
-
this.
|
|
332
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
1
2
|
import { request } from 'undici';
|
|
2
3
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import {
|
|
4
|
-
import { irdevice, irDevicesConfig, Devices } from '../settings';
|
|
4
|
+
import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -33,11 +33,11 @@ export class TV {
|
|
|
33
33
|
) {
|
|
34
34
|
// default placeholders
|
|
35
35
|
this.logs(device);
|
|
36
|
-
this.config(device);
|
|
37
36
|
this.context();
|
|
38
37
|
this.disablePushOnChanges({ device });
|
|
39
38
|
this.disablePushOffChanges({ device });
|
|
40
39
|
this.disablePushDetailChanges({ device });
|
|
40
|
+
this.config(device);
|
|
41
41
|
|
|
42
42
|
// set accessory information
|
|
43
43
|
accessory
|
|
@@ -368,14 +368,14 @@ export class TV {
|
|
|
368
368
|
async pushTVChanges(bodyChange: any): Promise<void> {
|
|
369
369
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTVChanges`);
|
|
370
370
|
if (this.device.connectionType === 'OpenAPI') {
|
|
371
|
-
this.
|
|
371
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
372
372
|
try {
|
|
373
373
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
374
374
|
body: bodyChange,
|
|
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)}`);
|
|
@@ -574,7 +574,7 @@ export class TV {
|
|
|
574
574
|
config['disablePushDetail'] = device.disablePushDetail;
|
|
575
575
|
}
|
|
576
576
|
if (Object.entries(config).length !== 0) {
|
|
577
|
-
this.
|
|
577
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
1
2
|
import { request } from 'undici';
|
|
2
3
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import { irDevicesConfig, irdevice
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
|
+
import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -27,10 +27,10 @@ export class VacuumCleaner {
|
|
|
27
27
|
) {
|
|
28
28
|
// default placeholders
|
|
29
29
|
this.logs(device);
|
|
30
|
-
this.config(device);
|
|
31
30
|
this.context();
|
|
32
31
|
this.disablePushOnChanges({ device });
|
|
33
32
|
this.disablePushOffChanges({ device });
|
|
33
|
+
this.config(device);
|
|
34
34
|
|
|
35
35
|
// set accessory information
|
|
36
36
|
accessory
|
|
@@ -112,14 +112,14 @@ export class VacuumCleaner {
|
|
|
112
112
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
113
113
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
114
114
|
if (this.device.connectionType === 'OpenAPI') {
|
|
115
|
-
this.
|
|
115
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
116
116
|
try {
|
|
117
117
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
118
118
|
body: bodyChange,
|
|
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)}`);
|
|
@@ -294,7 +294,7 @@ export class VacuumCleaner {
|
|
|
294
294
|
config['disablePushOff'] = device.disablePushOff;
|
|
295
295
|
}
|
|
296
296
|
if (Object.entries(config).length !== 0) {
|
|
297
|
-
this.
|
|
297
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
|