@switchbot/homebridge-switchbot 3.5.0-beta.27 → 3.5.0-beta.29
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 +1 -0
- package/config.schema.json +67 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +10 -5
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +10 -5
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +36 -10
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +24 -5
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +8 -3
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +8 -3
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +2 -1
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +23 -6
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +51 -0
- package/dist/device/fan.d.ts.map +1 -0
- package/dist/device/fan.js +499 -0
- package/dist/device/fan.js.map +1 -0
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +33 -25
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +8 -3
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +26 -18
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +42 -5
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +8 -3
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +26 -18
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +8 -3
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +8 -3
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +8 -3
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +10 -5
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +15 -8
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +3 -2
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +3 -2
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +3 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +4 -3
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +2 -1
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +9 -2
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +3 -2
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +3 -2
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +3 -2
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +3 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +3 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +2 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +68 -5
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +22 -4
- package/dist/settings.d.ts.map +1 -1
- package/dist/utils.d.ts +10 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +23 -9
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +10 -5
- package/src/device/bot.ts +10 -5
- package/src/device/ceilinglight.ts +36 -10
- package/src/device/colorbulb.ts +26 -7
- package/src/device/contact.ts +10 -5
- package/src/device/curtain.ts +22 -17
- package/src/device/device.ts +24 -6
- package/src/device/fan.ts +548 -0
- package/src/device/hub.ts +31 -23
- package/src/device/humidifier.ts +9 -4
- package/src/device/iosensor.ts +28 -20
- package/src/device/lightstrip.ts +41 -7
- package/src/device/lock.ts +13 -8
- package/src/device/meter.ts +30 -22
- package/src/device/meterplus.ts +12 -7
- package/src/device/motion.ts +9 -4
- package/src/device/plug.ts +9 -4
- package/src/device/robotvacuumcleaner.ts +15 -10
- package/src/device/waterdetector.ts +15 -8
- package/src/irdevice/airconditioner.ts +5 -4
- package/src/irdevice/airpurifier.ts +5 -4
- package/src/irdevice/camera.ts +4 -3
- package/src/irdevice/fan.ts +4 -3
- package/src/irdevice/irdevice.ts +11 -3
- package/src/irdevice/light.ts +3 -2
- package/src/irdevice/other.ts +47 -46
- package/src/irdevice/tv.ts +3 -2
- package/src/irdevice/vacuumcleaner.ts +3 -2
- package/src/irdevice/waterheater.ts +3 -2
- package/src/platform.ts +71 -5
- package/src/settings.ts +34 -9
- package/src/utils.ts +24 -9
package/src/settings.ts
CHANGED
|
@@ -48,6 +48,9 @@ export type options = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export interface devicesConfig extends device {
|
|
51
|
+
bleMac?: string;
|
|
52
|
+
model?: string;
|
|
53
|
+
bleModel?: string;
|
|
51
54
|
configDeviceType: string;
|
|
52
55
|
configDeviceName?: string;
|
|
53
56
|
deviceId: string;
|
|
@@ -89,11 +92,13 @@ export interface devicesConfig extends device {
|
|
|
89
92
|
|
|
90
93
|
export type meter = {
|
|
91
94
|
hide_temperature?: boolean;
|
|
95
|
+
convertUnitTo?: string;
|
|
92
96
|
hide_humidity?: boolean;
|
|
93
97
|
};
|
|
94
98
|
|
|
95
99
|
export type iosensor = {
|
|
96
100
|
hide_temperature?: boolean;
|
|
101
|
+
convertUnitTo?: string;
|
|
97
102
|
hide_humidity?: boolean;
|
|
98
103
|
};
|
|
99
104
|
|
|
@@ -174,6 +179,7 @@ export type lock = {
|
|
|
174
179
|
|
|
175
180
|
export type hub = {
|
|
176
181
|
hide_temperature?: boolean;
|
|
182
|
+
convertUnitTo?: string;
|
|
177
183
|
hide_humidity?: boolean;
|
|
178
184
|
hide_lightsensor?: boolean;
|
|
179
185
|
};
|
|
@@ -271,14 +277,28 @@ export type device = {
|
|
|
271
277
|
slidePosition?: string;
|
|
272
278
|
//the version of the device
|
|
273
279
|
version?: number;
|
|
274
|
-
//
|
|
275
|
-
|
|
276
|
-
//
|
|
277
|
-
|
|
278
|
-
//
|
|
279
|
-
|
|
280
|
+
// Fan Mode: direct mode: direct; natural mode: "natural"; sleep mode: "sleep"; ultra quiet mode: "baby"
|
|
281
|
+
mode: string;
|
|
282
|
+
//the current battery level
|
|
283
|
+
battery: number;
|
|
284
|
+
//ON/OFF state
|
|
285
|
+
power: string;
|
|
286
|
+
//set nightlight status. turn off: off; mode 1: 1; mode 2: 2
|
|
287
|
+
nightStatus: number;
|
|
288
|
+
//set horizontal oscillation. turn on: on; turn off: off
|
|
289
|
+
oscillation: string;
|
|
290
|
+
//set vertical oscillation. turn on: on; turn off: off
|
|
291
|
+
verticalOscillation: string;
|
|
292
|
+
//battery charge status. charging or uncharged
|
|
293
|
+
chargingStatus: string;
|
|
294
|
+
//fan speed. 1~100
|
|
295
|
+
fanSpeed: number;
|
|
280
296
|
};
|
|
281
297
|
|
|
298
|
+
// values defined but not displayed by API
|
|
299
|
+
export interface deviceInfo extends device {
|
|
300
|
+
}
|
|
301
|
+
|
|
282
302
|
//a list of virtual infrared remote devices.
|
|
283
303
|
export type infraredRemoteList = {
|
|
284
304
|
device: Array<irdevice>;
|
|
@@ -300,7 +320,7 @@ export type deviceStatus = {
|
|
|
300
320
|
|
|
301
321
|
export type deviceStatusBody = {
|
|
302
322
|
//v1.1 of API
|
|
303
|
-
deviceId: string; //device ID. (Used by the following deviceTypes: Bot, Curtain, Meter, Meter Plus, Lock, Keypad, Keypad Touch, Motion Sensor, Contact Sensor, Ceiling Light, Ceiling Light Pro, Plug Mini (US), Plug Mini (JP), Strip Light, Color Bulb, Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Humidifier, Blind Tilt)
|
|
323
|
+
deviceId: string; //device ID. (Used by the following deviceTypes: Bot, Curtain, Meter, Meter Plus, Lock, Keypad, Keypad Touch, Motion Sensor, Contact Sensor, Ceiling Light, Ceiling Light Pro, Plug Mini (US), Plug Mini (JP), Strip Light, Color Bulb, Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Humidifier, Blind Tilt, Battery Circulator Fan)
|
|
304
324
|
deviceType: string; //device type. (Used by the following deviceTypes: Bot, Curtain, Meter, Meter Plus, Lock, Keypad, Keypad Touch, Motion Sensor, Contact Sensor, Ceiling Light, Ceiling Light Pro, Plug Mini (US), Plug Mini (JP), Strip Light, Color Bulb, Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Humidifier, Blind Tilt)
|
|
305
325
|
hubDeviceId: string; //device's parent Hub ID. 000000000000 when the device itself is a Hub or it is connected through Wi-Fi. (Used by the following deviceTypes: Bot, Curtain, Meter, Meter Plus, Lock, Keypad, Keypad Touch, Motion Sensor, Contact Sensor, Ceiling Light, Ceiling Light Pro, Plug Mini (JP), Strip Light, Color Bulb, Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Humidifier, Blind Tilt)
|
|
306
326
|
power?: string; //ON/OFF state. (Used by the following deviceTypes: Bot, Ceiling Light, Ceiling Light Pro, PLug, Plug Mini (US), Plug Mini (JP), Strip Light, Color Bulb, Humidifier)
|
|
@@ -330,16 +350,21 @@ export type deviceStatusBody = {
|
|
|
330
350
|
childLock?: boolean; //determines if a Humidifier's safety lock is on or not. (Used by the following deviceTypes: Humidifier)
|
|
331
351
|
sound?: boolean; //determines if a Humidifier is muted or not. (Used by the following deviceTypes: Humidifier)
|
|
332
352
|
lackWater?: boolean; //determines if the water tank is empty or not. (Used by the following deviceTypes: Humidifier)
|
|
333
|
-
version?: number; //the version of the device.
|
|
353
|
+
version?: number; //the version of the device.
|
|
334
354
|
direction?: string; //the opening direction of a Blind Tilt device. (Used by the following deviceTypes: Blind Tilt)
|
|
335
355
|
runStatus?: string; //'static' when not moving. (Used by the following deviceTypes: Blind Tilt)
|
|
336
|
-
mode?: number; //available for devices. the fan mode. (Used by the following deviceTypes: Smart Fan)
|
|
356
|
+
mode?: number | string; //available for devices. the fan mode. (Used by the following deviceTypes: Smart Fan, Battery Circulator Fan):(direct mode: direct; natural mode: "natural"; sleep mode: "sleep"; ultra quiet mode: "baby")
|
|
337
357
|
speed?: number; //the fan speed. (Used by the following deviceTypes: Smart Fan)
|
|
338
358
|
shaking?: boolean; //determines if the fan is swinging or not. (Used by the following deviceTypes: Smart Fan)
|
|
339
359
|
shakeCenter?: string; //the fan's swing direction. (Used by the following deviceTypes: Smart Fan)
|
|
340
360
|
shakeRange?: string; //the fan's swing range, 0~120°. (Used by the following deviceTypes: Smart Fan)
|
|
341
361
|
status?: number //the leak status. 0 for no leak, 1 for leak. (Used by the following deviceTypes: Water Detector)
|
|
342
362
|
lightLevel?: number; //the light level. (Used by the following deviceTypes: Hub)
|
|
363
|
+
nightStatus: number // set nightlight status. turn off: off; mode 1: 1; mode 2: 2
|
|
364
|
+
oscillation: string // set horizontal oscillation. turn on: on; turn off: off
|
|
365
|
+
verticalOscillation: string // set vertical oscillation. turn on: on; turn off: off
|
|
366
|
+
chargingStatus: string // battery charge status. charging or uncharged
|
|
367
|
+
fanSpeed: number // fan speed. 1~100
|
|
343
368
|
};
|
|
344
369
|
|
|
345
370
|
export type ad = {
|
package/src/utils.ts
CHANGED
|
@@ -19,8 +19,8 @@ export enum SwitchBotModel {
|
|
|
19
19
|
ContactSensor = 'W1201500',
|
|
20
20
|
ColorBulb = 'W1401400',
|
|
21
21
|
StripLight = 'W1701100',
|
|
22
|
-
PlugMiniUS = 'W1901400',
|
|
23
|
-
PlugMiniJP = 'W2001400',
|
|
22
|
+
PlugMiniUS = 'W1901400/W1901401',
|
|
23
|
+
PlugMiniJP = 'W2001400/W2001401',
|
|
24
24
|
Lock = 'W1601700',
|
|
25
25
|
LockPro = 'W3500000',
|
|
26
26
|
Keypad = 'W2500010',
|
|
@@ -30,16 +30,17 @@ export enum SwitchBotModel {
|
|
|
30
30
|
WoSweeperMini = 'WoSweeperMini',
|
|
31
31
|
RobotVacuumCleanerS1 = 'W3011000', // Currently only available in Japan.
|
|
32
32
|
RobotVacuumCleanerS1Plus = 'W3011010', // Currently only available in Japan.
|
|
33
|
+
RobotVacuumCleanerS10 = 'W3211800',
|
|
33
34
|
Remote = 'Remote',
|
|
34
35
|
UniversalRemote = 'UniversalRemote',
|
|
35
|
-
CeilingLight = 'W2612230', // Currently only available in Japan.
|
|
36
|
-
CeilingLightPro = 'W2612210', // Currently only available in Japan.
|
|
36
|
+
CeilingLight = 'W2612230/W2612240', // Currently only available in Japan.
|
|
37
|
+
CeilingLightPro = 'W2612210/W2612220', // Currently only available in Japan.
|
|
37
38
|
IndoorCam = 'W1301200',
|
|
38
39
|
PanTiltCam = 'W1801200',
|
|
39
40
|
PanTiltCam2K = 'W3101100',
|
|
40
41
|
BlindTilt = 'W2701600',
|
|
41
42
|
BatteryCirculatorFan = 'W3800510',
|
|
42
|
-
WaterDetector = '
|
|
43
|
+
WaterDetector = 'W4402000',
|
|
43
44
|
Unknown = 'Unknown',
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -77,11 +78,25 @@ export function sleep(ms: number): Promise<void> {
|
|
|
77
78
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Converts the value to celsius if the temperature units are in Fahrenheit
|
|
83
|
+
**/
|
|
84
|
+
export function convertUnits(value: number, unit: string, convert?: string): number {
|
|
85
|
+
if (unit === 'CELSIUS' && convert === 'CELSIUS') {
|
|
86
|
+
return Math.round((value * 9) / 5 + 32);
|
|
87
|
+
} else if (unit === 'FAHRENHEIT' && convert === 'FAHRENHEIT') {
|
|
88
|
+
// celsius should be to the nearest 0.5 degree
|
|
89
|
+
return Math.round((5 / 9) * (value - 32) * 2) / 2;
|
|
90
|
+
}
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
80
95
|
export function rgb2hs(r: any, g: any, b: any) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Credit:
|
|
98
|
+
* https://github.com/WickyNilliams/pure-color
|
|
99
|
+
**/
|
|
85
100
|
r = parseInt(r);
|
|
86
101
|
g = parseInt(g);
|
|
87
102
|
b = parseInt(b);
|