@switchbot/homebridge-switchbot 2.8.0-beta.1 → 2.8.0-beta.11
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/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 +53 -44
- 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 +29 -4
- 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.map +1 -1
- package/dist/irdevice/airconditioner.js +7 -5
- 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 +3 -2
- package/dist/platform.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +8 -6
- package/src/device/bot.ts +53 -41
- package/src/device/ceilinglight.ts +12 -6
- package/src/device/colorbulb.ts +10 -5
- package/src/device/contact.ts +44 -30
- package/src/device/curtain.ts +32 -33
- package/src/device/hub.ts +30 -4
- package/src/device/humidifier.ts +8 -5
- package/src/device/iosensor.ts +10 -6
- package/src/device/lightstrip.ts +10 -5
- package/src/device/lock.ts +12 -5
- package/src/device/meter.ts +12 -7
- package/src/device/meterplus.ts +61 -54
- package/src/device/motion.ts +45 -27
- package/src/device/plug.ts +8 -5
- package/src/device/robotvacuumcleaner.ts +31 -2
- package/src/irdevice/airconditioner.ts +7 -5
- package/src/irdevice/airpurifier.ts +5 -5
- package/src/irdevice/camera.ts +5 -5
- package/src/irdevice/fan.ts +5 -5
- package/src/irdevice/light.ts +5 -5
- package/src/irdevice/other.ts +5 -5
- package/src/irdevice/tv.ts +5 -5
- package/src/irdevice/vacuumcleaner.ts +5 -5
- package/src/irdevice/waterheater.ts +5 -5
- package/src/platform.ts +3 -2
- package/src/settings.ts +1 -1
package/src/device/plug.ts
CHANGED
|
@@ -15,6 +15,7 @@ export class Plug {
|
|
|
15
15
|
On!: CharacteristicValue;
|
|
16
16
|
|
|
17
17
|
// OpenAPI Others
|
|
18
|
+
Version: deviceStatus['version'];
|
|
18
19
|
power: deviceStatus['power'];
|
|
19
20
|
deviceStatus!: any; //deviceStatusResponse;
|
|
20
21
|
|
|
@@ -53,8 +54,8 @@ export class Plug {
|
|
|
53
54
|
this.logs(device);
|
|
54
55
|
this.scan(device);
|
|
55
56
|
this.refreshRate(device);
|
|
56
|
-
this.config(device);
|
|
57
57
|
this.context();
|
|
58
|
+
this.config(device);
|
|
58
59
|
|
|
59
60
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
60
61
|
this.doPlugUpdate = new Subject();
|
|
@@ -583,10 +584,12 @@ export class Plug {
|
|
|
583
584
|
);
|
|
584
585
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
585
586
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
586
|
-
if (
|
|
587
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
588
|
-
} else if (device.firmware) {
|
|
587
|
+
if (device.firmware) {
|
|
589
588
|
FirmwareRevision = device.firmware;
|
|
589
|
+
} else if (device.version) {
|
|
590
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
591
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
592
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
590
593
|
} else {
|
|
591
594
|
FirmwareRevision = this.platform.version;
|
|
592
595
|
}
|
|
@@ -638,7 +641,7 @@ export class Plug {
|
|
|
638
641
|
config['maxRetry'] = device.maxRetry;
|
|
639
642
|
}
|
|
640
643
|
if (Object.entries(config).length !== 0) {
|
|
641
|
-
this.
|
|
644
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
642
645
|
}
|
|
643
646
|
}
|
|
644
647
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable brace-style */
|
|
1
2
|
import { Context } from 'vm';
|
|
2
3
|
import { request } from 'undici';
|
|
3
4
|
import { sleep } from '../utils';
|
|
@@ -19,6 +20,8 @@ export class RobotVacuumCleaner {
|
|
|
19
20
|
StatusLowBattery?: CharacteristicValue;
|
|
20
21
|
|
|
21
22
|
// OpenAPI Others
|
|
23
|
+
Version: deviceStatus['version'];
|
|
24
|
+
Battery: deviceStatus['battery'];
|
|
22
25
|
power: deviceStatus['power'];
|
|
23
26
|
deviceStatus!: any; //deviceStatusResponse;
|
|
24
27
|
|
|
@@ -51,8 +54,8 @@ export class RobotVacuumCleaner {
|
|
|
51
54
|
this.logs(device);
|
|
52
55
|
this.scan(device);
|
|
53
56
|
this.refreshRate(device);
|
|
54
|
-
this.config(device);
|
|
55
57
|
this.context();
|
|
58
|
+
this.config(device);
|
|
56
59
|
|
|
57
60
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
58
61
|
this.doRobotVacuumCleanerUpdate = new Subject();
|
|
@@ -107,6 +110,21 @@ export class RobotVacuumCleaner {
|
|
|
107
110
|
})
|
|
108
111
|
.onSet(this.BrightnessSet.bind(this));
|
|
109
112
|
|
|
113
|
+
// Battery Service
|
|
114
|
+
if (!this.batteryService) {
|
|
115
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
|
|
116
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
|
|
117
|
+
`${accessory.displayName} Battery`;
|
|
118
|
+
|
|
119
|
+
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
120
|
+
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
121
|
+
this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
|
|
122
|
+
}
|
|
123
|
+
this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
|
|
124
|
+
} else {
|
|
125
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
|
|
126
|
+
}
|
|
127
|
+
|
|
110
128
|
// Update Homekit
|
|
111
129
|
this.updateHomeKitCharacteristics();
|
|
112
130
|
|
|
@@ -186,6 +204,15 @@ export class RobotVacuumCleaner {
|
|
|
186
204
|
this.On = false;
|
|
187
205
|
}
|
|
188
206
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
207
|
+
|
|
208
|
+
// Battery
|
|
209
|
+
this.BatteryLevel = Number(this.Battery);
|
|
210
|
+
if (this.BatteryLevel < 15) {
|
|
211
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
212
|
+
} else {
|
|
213
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
214
|
+
}
|
|
215
|
+
this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
|
|
189
216
|
}
|
|
190
217
|
|
|
191
218
|
/**
|
|
@@ -282,6 +309,8 @@ export class RobotVacuumCleaner {
|
|
|
282
309
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
283
310
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
284
311
|
this.power = deviceStatus.body.power;
|
|
312
|
+
this.Battery = deviceStatus.body.battery;
|
|
313
|
+
this.Version = deviceStatus.body.version;
|
|
285
314
|
this.openAPIparseStatus();
|
|
286
315
|
this.updateHomeKitCharacteristics();
|
|
287
316
|
} catch (e: any) {
|
|
@@ -758,7 +787,7 @@ export class RobotVacuumCleaner {
|
|
|
758
787
|
config['maxRetry'] = device.maxRetry;
|
|
759
788
|
}
|
|
760
789
|
if (Object.entries(config).length !== 0) {
|
|
761
|
-
this.
|
|
790
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
762
791
|
}
|
|
763
792
|
}
|
|
764
793
|
|
|
@@ -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
|
|
@@ -252,7 +252,7 @@ export class AirConditioner {
|
|
|
252
252
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
253
253
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
254
254
|
if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
|
|
255
|
-
this.
|
|
255
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
256
256
|
try {
|
|
257
257
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
258
258
|
body: bodyChange,
|
|
@@ -291,7 +291,8 @@ export class AirConditioner {
|
|
|
291
291
|
this.meter.getService(this.platform.Service.TemperatureSensor)?.getCharacteristic(this.platform.Characteristic.CurrentTemperature).value ||
|
|
292
292
|
24;
|
|
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
297
|
} else if (this.CurrentTemperature === undefined) {
|
|
297
298
|
this.CurrentTemperature = 24;
|
|
@@ -309,7 +310,8 @@ export class AirConditioner {
|
|
|
309
310
|
this.meter.getService(this.platform.Service.HumiditySensor)?.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).value ||
|
|
310
311
|
0;
|
|
311
312
|
this.debugLog(
|
|
312
|
-
`${this.device.remoteType}: ${this.accessory.displayName}
|
|
313
|
+
`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
314
|
+
+ `Using CurrentRelativeHumidity from ${this.meter.context?.deviceType} (${this.meter.context?.deviceID})`,
|
|
313
315
|
);
|
|
314
316
|
} else if (this.CurrentRelativeHumidity === undefined) {
|
|
315
317
|
this.CurrentRelativeHumidity = 0;
|
|
@@ -715,7 +717,7 @@ export class AirConditioner {
|
|
|
715
717
|
config['disablePushDetail'] = device.disablePushDetail;
|
|
716
718
|
}
|
|
717
719
|
if (Object.entries(config).length !== 0) {
|
|
718
|
-
this.
|
|
720
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
719
721
|
}
|
|
720
722
|
}
|
|
721
723
|
|
|
@@ -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,7 +211,7 @@ 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,
|
|
@@ -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,7 +116,7 @@ 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,
|
|
@@ -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,7 +236,7 @@ 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,
|
|
@@ -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,7 +140,7 @@ 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,
|
|
@@ -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,7 +135,7 @@ 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,
|
|
@@ -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,7 +368,7 @@ 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,
|
|
@@ -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,7 +112,7 @@ 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,
|
|
@@ -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
|
|
|
@@ -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 WaterHeater {
|
|
|
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
|
|
@@ -121,7 +121,7 @@ export class WaterHeater {
|
|
|
121
121
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
122
122
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
123
123
|
if (this.device.connectionType === 'OpenAPI') {
|
|
124
|
-
this.
|
|
124
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
125
125
|
try {
|
|
126
126
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
127
127
|
body: bodyChange,
|
|
@@ -303,7 +303,7 @@ export class WaterHeater {
|
|
|
303
303
|
config['disablePushOff'] = device.disablePushOff;
|
|
304
304
|
}
|
|
305
305
|
if (Object.entries(config).length !== 0) {
|
|
306
|
-
this.
|
|
306
|
+
this.debugWarnLog({ log: [`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`] });
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
|
package/src/platform.ts
CHANGED
|
@@ -138,7 +138,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
138
138
|
platformConfig['pushRate'] = this.config.options.pushRate;
|
|
139
139
|
}
|
|
140
140
|
if (Object.entries(platformConfig).length !== 0) {
|
|
141
|
-
this.
|
|
141
|
+
this.debugWarnLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
if (this.config.options) {
|
|
@@ -245,7 +245,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
245
245
|
} else {
|
|
246
246
|
// eslint-disable-next-line no-useless-escape, max-len
|
|
247
247
|
this.warnLog(
|
|
248
|
-
'This plugin has been updated to use OpenAPI v1.1, config is set with openToken,
|
|
248
|
+
'This plugin has been updated to use OpenAPI v1.1, config is set with openToken, '
|
|
249
|
+
+ '"openToken" config has been moved to the "token" config, please restart Homebridge.',
|
|
249
250
|
);
|
|
250
251
|
}
|
|
251
252
|
|
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)
|