@switchbot/homebridge-switchbot 3.5.0 → 3.5.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/npm-version-script.cjs +81 -0
- package/config.schema.json +4 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +64 -189
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +34 -68
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +65 -158
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +47 -159
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +42 -105
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +61 -182
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +41 -2
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +182 -5
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +76 -145
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +7 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +54 -17
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +55 -104
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +27 -46
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +56 -120
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +36 -66
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +27 -46
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +26 -45
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +24 -43
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +32 -66
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +43 -88
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +23 -43
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +10 -28
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +8 -20
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +8 -20
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +8 -20
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +7 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +28 -0
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +8 -20
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +8 -20
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +8 -20
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +8 -20
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +8 -20
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +4 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +19 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +20 -1
- package/dist/utils.js.map +1 -1
- package/package.json +8 -8
- package/src/device/blindtilt.ts +71 -186
- package/src/device/bot.ts +32 -68
- package/src/device/ceilinglight.ts +67 -153
- package/src/device/colorbulb.ts +51 -155
- package/src/device/contact.ts +49 -104
- package/src/device/curtain.ts +70 -177
- package/src/device/device.ts +207 -8
- package/src/device/fan.ts +75 -147
- package/src/device/hub.ts +55 -19
- package/src/device/humidifier.ts +52 -104
- package/src/device/iosensor.ts +25 -46
- package/src/device/lightstrip.ts +54 -121
- package/src/device/lock.ts +35 -67
- package/src/device/meter.ts +25 -46
- package/src/device/meterplus.ts +24 -45
- package/src/device/motion.ts +22 -43
- package/src/device/plug.ts +30 -66
- package/src/device/robotvacuumcleaner.ts +40 -89
- package/src/device/waterdetector.ts +22 -43
- package/src/irdevice/airconditioner.ts +10 -26
- package/src/irdevice/airpurifier.ts +8 -20
- package/src/irdevice/camera.ts +8 -20
- package/src/irdevice/fan.ts +8 -20
- package/src/irdevice/irdevice.ts +29 -0
- package/src/irdevice/light.ts +8 -20
- package/src/irdevice/other.ts +8 -20
- package/src/irdevice/tv.ts +8 -20
- package/src/irdevice/vacuumcleaner.ts +8 -20
- package/src/irdevice/waterheater.ts +8 -20
- package/src/settings.ts +4 -2
- package/src/utils.ts +20 -1
package/src/irdevice/other.ts
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
*
|
|
3
3
|
* other.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
|
-
import { request } from 'undici';
|
|
6
|
-
import { Devices } from '../settings.js';
|
|
7
5
|
import { irdeviceBase } from './irdevice.js';
|
|
8
6
|
|
|
9
7
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
@@ -535,29 +533,19 @@ export class Others extends irdeviceBase {
|
|
|
535
533
|
if (this.device.connectionType === 'OpenAPI') {
|
|
536
534
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
537
535
|
try {
|
|
538
|
-
const { body, statusCode } = await
|
|
539
|
-
body: bodyChange,
|
|
540
|
-
method: 'POST',
|
|
541
|
-
headers: this.platform.generateHeaders(),
|
|
542
|
-
});
|
|
543
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
536
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
544
537
|
const deviceStatus: any = await body.json();
|
|
545
|
-
this.
|
|
546
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
538
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
547
539
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
548
|
-
this.
|
|
549
|
-
|
|
550
|
-
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
551
|
-
+ ` request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
552
|
-
this.updateHomeKitCharacteristics();
|
|
540
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
541
|
+
await this.updateHomeKitCharacteristics();
|
|
553
542
|
} else {
|
|
554
|
-
this.statusCode(statusCode);
|
|
555
|
-
this.statusCode(deviceStatus.statusCode);
|
|
543
|
+
await this.statusCode(statusCode);
|
|
544
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
556
545
|
}
|
|
557
546
|
} catch (e: any) {
|
|
558
|
-
this.apiError(e);
|
|
559
|
-
this.
|
|
560
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
547
|
+
await this.apiError(e);
|
|
548
|
+
await this.pushChangeError(e);
|
|
561
549
|
}
|
|
562
550
|
} else {
|
|
563
551
|
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
*
|
|
3
3
|
* tv.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
|
-
import { request } from 'undici';
|
|
6
|
-
import { Devices } from '../settings.js';
|
|
7
5
|
import { irdeviceBase } from './irdevice.js';
|
|
8
6
|
|
|
9
7
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
@@ -367,29 +365,19 @@ export class TV extends irdeviceBase {
|
|
|
367
365
|
if (this.device.connectionType === 'OpenAPI') {
|
|
368
366
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
369
367
|
try {
|
|
370
|
-
const { body, statusCode } = await
|
|
371
|
-
body: bodyChange,
|
|
372
|
-
method: 'POST',
|
|
373
|
-
headers: this.platform.generateHeaders(),
|
|
374
|
-
});
|
|
375
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
368
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
376
369
|
const deviceStatus: any = await body.json();
|
|
377
|
-
this.
|
|
378
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
370
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
379
371
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
380
|
-
this.
|
|
381
|
-
|
|
382
|
-
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
383
|
-
+ ` request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
384
|
-
this.updateHomeKitCharacteristics();
|
|
372
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
373
|
+
await this.updateHomeKitCharacteristics();
|
|
385
374
|
} else {
|
|
386
|
-
this.statusCode(statusCode);
|
|
387
|
-
this.statusCode(deviceStatus.statusCode);
|
|
375
|
+
await this.statusCode(statusCode);
|
|
376
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
388
377
|
}
|
|
389
378
|
} catch (e: any) {
|
|
390
|
-
this.apiError(e);
|
|
391
|
-
this.
|
|
392
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
379
|
+
await this.apiError(e);
|
|
380
|
+
await this.pushChangeError(e);
|
|
393
381
|
}
|
|
394
382
|
} else {
|
|
395
383
|
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
*
|
|
3
3
|
* vacuumcleaner.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
|
-
import { request } from 'undici';
|
|
6
|
-
import { Devices } from '../settings.js';
|
|
7
5
|
import { irdeviceBase } from './irdevice.js';
|
|
8
6
|
|
|
9
7
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
@@ -101,29 +99,19 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
101
99
|
if (this.device.connectionType === 'OpenAPI') {
|
|
102
100
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
103
101
|
try {
|
|
104
|
-
const { body, statusCode } = await
|
|
105
|
-
body: bodyChange,
|
|
106
|
-
method: 'POST',
|
|
107
|
-
headers: this.platform.generateHeaders(),
|
|
108
|
-
});
|
|
109
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
102
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
110
103
|
const deviceStatus: any = await body.json();
|
|
111
|
-
this.
|
|
112
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
104
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
113
105
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
114
|
-
this.
|
|
115
|
-
|
|
116
|
-
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
117
|
-
+ ` request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
118
|
-
this.updateHomeKitCharacteristics();
|
|
106
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
107
|
+
await this.updateHomeKitCharacteristics();
|
|
119
108
|
} else {
|
|
120
|
-
this.statusCode(statusCode);
|
|
121
|
-
this.statusCode(deviceStatus.statusCode);
|
|
109
|
+
await this.statusCode(statusCode);
|
|
110
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
122
111
|
}
|
|
123
112
|
} catch (e: any) {
|
|
124
|
-
this.apiError(e);
|
|
125
|
-
this.
|
|
126
|
-
+ ` with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
113
|
+
await this.apiError(e);
|
|
114
|
+
await this.pushChangeError(e);
|
|
127
115
|
}
|
|
128
116
|
} else {
|
|
129
117
|
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
*
|
|
3
3
|
* waterheater.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
|
-
import { request } from 'undici';
|
|
6
|
-
import { Devices } from '../settings.js';
|
|
7
5
|
import { irdeviceBase } from './irdevice.js';
|
|
8
6
|
|
|
9
7
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
@@ -103,29 +101,19 @@ export class WaterHeater extends irdeviceBase {
|
|
|
103
101
|
if (this.device.connectionType === 'OpenAPI') {
|
|
104
102
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
105
103
|
try {
|
|
106
|
-
const { body, statusCode } = await
|
|
107
|
-
body: bodyChange,
|
|
108
|
-
method: 'POST',
|
|
109
|
-
headers: this.platform.generateHeaders(),
|
|
110
|
-
});
|
|
111
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
104
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
112
105
|
const deviceStatus: any = await body.json();
|
|
113
|
-
this.
|
|
114
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
106
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
115
107
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
119
|
-
+ ` request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
120
|
-
this.updateHomeKitCharacteristics();
|
|
108
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
109
|
+
await this.updateHomeKitCharacteristics();
|
|
121
110
|
} else {
|
|
122
|
-
this.statusCode(statusCode);
|
|
123
|
-
this.statusCode(deviceStatus.statusCode);
|
|
111
|
+
await this.statusCode(statusCode);
|
|
112
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
124
113
|
}
|
|
125
114
|
} catch (e: any) {
|
|
126
|
-
this.apiError(e);
|
|
127
|
-
this.
|
|
128
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
115
|
+
await this.apiError(e);
|
|
116
|
+
await this.pushChangeError(e);
|
|
129
117
|
}
|
|
130
118
|
} else {
|
|
131
119
|
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
package/src/settings.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { IClientOptions } from 'async-mqtt';
|
|
6
6
|
import type { MacAddress, PlatformConfig } from 'homebridge';
|
|
7
|
+
import type { SwitchBotBLEModel, SwitchBotBLEModelName } from './utils';
|
|
7
8
|
/**
|
|
8
9
|
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
9
10
|
*/
|
|
@@ -70,7 +71,8 @@ export type options = {
|
|
|
70
71
|
export interface devicesConfig extends device {
|
|
71
72
|
bleMac?: string;
|
|
72
73
|
model?: string;
|
|
73
|
-
bleModel?:
|
|
74
|
+
bleModel?: SwitchBotBLEModel;
|
|
75
|
+
bleModelName?: SwitchBotBLEModelName;
|
|
74
76
|
configDeviceType: string;
|
|
75
77
|
configDeviceName?: string;
|
|
76
78
|
deviceId: string;
|
|
@@ -425,7 +427,7 @@ export type serviceData = {
|
|
|
425
427
|
//Meter Temperature Levels
|
|
426
428
|
temperature?: temperature;
|
|
427
429
|
// Fahrenheit enabled for Meter
|
|
428
|
-
fahrenheit
|
|
430
|
+
fahrenheit?: boolean;
|
|
429
431
|
// Humidity level for Meter
|
|
430
432
|
humidity?: number;
|
|
431
433
|
//Motion Detected for Contact or Motion Sensors
|
package/src/utils.ts
CHANGED
|
@@ -51,6 +51,7 @@ export enum SwitchBotBLEModel {
|
|
|
51
51
|
Humidifier = 'e',
|
|
52
52
|
Meter = 'T',
|
|
53
53
|
MeterPlus = 'i',
|
|
54
|
+
Hub2 = 'v',
|
|
54
55
|
OutdoorMeter = 'w',
|
|
55
56
|
MotionSensor = 's',
|
|
56
57
|
ContactSensor = 'd',
|
|
@@ -59,13 +60,31 @@ export enum SwitchBotBLEModel {
|
|
|
59
60
|
PlugMiniUS = 'g',
|
|
60
61
|
PlugMiniJP = 'j',
|
|
61
62
|
Lock = 'o',
|
|
62
|
-
Remote = '',
|
|
63
63
|
CeilingLight = 'q', // Currently only available in Japan.
|
|
64
64
|
CeilingLightPro = 'n', // Currently only available in Japan.
|
|
65
65
|
BlindTilt = 'x',
|
|
66
66
|
Unknown = 'Unknown',
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
export enum SwitchBotBLEModelName {
|
|
70
|
+
Bot = 'WoHand',
|
|
71
|
+
Hub2 = 'WoHub2',
|
|
72
|
+
ColorBulb = 'WoBulb',
|
|
73
|
+
Curtain = 'WoCurtain',
|
|
74
|
+
Curtain3 = 'WoCurtain3',
|
|
75
|
+
Humidifier = 'WoHumi',
|
|
76
|
+
Meter = 'WoSensorTH',
|
|
77
|
+
Lock = 'WoSmartLock',
|
|
78
|
+
PlugMini = 'WoPlugMini',
|
|
79
|
+
StripLight = 'WoStrip',
|
|
80
|
+
MeterPlus = 'WoSensorTHPlus',
|
|
81
|
+
OutdoorMeter = 'WoIOSensorTH',
|
|
82
|
+
ContactSensor = 'WoContact',
|
|
83
|
+
MotionSensor = 'WoMotion',
|
|
84
|
+
BlindTilt = 'WoBlindTilt',
|
|
85
|
+
Unknown = 'Unknown',
|
|
86
|
+
}
|
|
87
|
+
|
|
69
88
|
export enum BlindTiltMappingMode {
|
|
70
89
|
OnlyUp = 'only_up',
|
|
71
90
|
OnlyDown = 'only_down',
|