@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.
Files changed (136) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/config.schema.json +67 -1
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +10 -5
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +10 -5
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts.map +1 -1
  10. package/dist/device/ceilinglight.js +36 -10
  11. package/dist/device/ceilinglight.js.map +1 -1
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +24 -5
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/contact.d.ts.map +1 -1
  16. package/dist/device/contact.js +8 -3
  17. package/dist/device/contact.js.map +1 -1
  18. package/dist/device/curtain.d.ts.map +1 -1
  19. package/dist/device/curtain.js +8 -3
  20. package/dist/device/curtain.js.map +1 -1
  21. package/dist/device/device.d.ts +2 -1
  22. package/dist/device/device.d.ts.map +1 -1
  23. package/dist/device/device.js +23 -6
  24. package/dist/device/device.js.map +1 -1
  25. package/dist/device/fan.d.ts +51 -0
  26. package/dist/device/fan.d.ts.map +1 -0
  27. package/dist/device/fan.js +499 -0
  28. package/dist/device/fan.js.map +1 -0
  29. package/dist/device/hub.d.ts.map +1 -1
  30. package/dist/device/hub.js +33 -25
  31. package/dist/device/hub.js.map +1 -1
  32. package/dist/device/humidifier.d.ts.map +1 -1
  33. package/dist/device/humidifier.js +8 -3
  34. package/dist/device/humidifier.js.map +1 -1
  35. package/dist/device/iosensor.d.ts.map +1 -1
  36. package/dist/device/iosensor.js +26 -18
  37. package/dist/device/iosensor.js.map +1 -1
  38. package/dist/device/lightstrip.d.ts.map +1 -1
  39. package/dist/device/lightstrip.js +42 -5
  40. package/dist/device/lightstrip.js.map +1 -1
  41. package/dist/device/lock.d.ts.map +1 -1
  42. package/dist/device/lock.js +8 -3
  43. package/dist/device/lock.js.map +1 -1
  44. package/dist/device/meter.d.ts.map +1 -1
  45. package/dist/device/meter.js +26 -18
  46. package/dist/device/meter.js.map +1 -1
  47. package/dist/device/meterplus.d.ts.map +1 -1
  48. package/dist/device/meterplus.js +8 -3
  49. package/dist/device/meterplus.js.map +1 -1
  50. package/dist/device/motion.d.ts.map +1 -1
  51. package/dist/device/motion.js +8 -3
  52. package/dist/device/motion.js.map +1 -1
  53. package/dist/device/plug.d.ts.map +1 -1
  54. package/dist/device/plug.js +8 -3
  55. package/dist/device/plug.js.map +1 -1
  56. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  57. package/dist/device/robotvacuumcleaner.js +10 -5
  58. package/dist/device/robotvacuumcleaner.js.map +1 -1
  59. package/dist/device/waterdetector.d.ts.map +1 -1
  60. package/dist/device/waterdetector.js +15 -8
  61. package/dist/device/waterdetector.js.map +1 -1
  62. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  63. package/dist/irdevice/airconditioner.js +3 -2
  64. package/dist/irdevice/airconditioner.js.map +1 -1
  65. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  66. package/dist/irdevice/airpurifier.js +3 -2
  67. package/dist/irdevice/airpurifier.js.map +1 -1
  68. package/dist/irdevice/camera.d.ts.map +1 -1
  69. package/dist/irdevice/camera.js +3 -2
  70. package/dist/irdevice/camera.js.map +1 -1
  71. package/dist/irdevice/fan.d.ts +1 -1
  72. package/dist/irdevice/fan.d.ts.map +1 -1
  73. package/dist/irdevice/fan.js +4 -3
  74. package/dist/irdevice/fan.js.map +1 -1
  75. package/dist/irdevice/irdevice.d.ts +2 -1
  76. package/dist/irdevice/irdevice.d.ts.map +1 -1
  77. package/dist/irdevice/irdevice.js +9 -2
  78. package/dist/irdevice/irdevice.js.map +1 -1
  79. package/dist/irdevice/light.d.ts.map +1 -1
  80. package/dist/irdevice/light.js +3 -2
  81. package/dist/irdevice/light.js.map +1 -1
  82. package/dist/irdevice/other.d.ts.map +1 -1
  83. package/dist/irdevice/other.js +3 -2
  84. package/dist/irdevice/other.js.map +1 -1
  85. package/dist/irdevice/tv.d.ts.map +1 -1
  86. package/dist/irdevice/tv.js +3 -2
  87. package/dist/irdevice/tv.js.map +1 -1
  88. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  89. package/dist/irdevice/vacuumcleaner.js +3 -2
  90. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  91. package/dist/irdevice/waterheater.d.ts.map +1 -1
  92. package/dist/irdevice/waterheater.js +3 -2
  93. package/dist/irdevice/waterheater.js.map +1 -1
  94. package/dist/platform.d.ts +2 -1
  95. package/dist/platform.d.ts.map +1 -1
  96. package/dist/platform.js +68 -5
  97. package/dist/platform.js.map +1 -1
  98. package/dist/settings.d.ts +22 -4
  99. package/dist/settings.d.ts.map +1 -1
  100. package/dist/utils.d.ts +10 -5
  101. package/dist/utils.d.ts.map +1 -1
  102. package/dist/utils.js +23 -9
  103. package/dist/utils.js.map +1 -1
  104. package/package.json +3 -3
  105. package/src/device/blindtilt.ts +10 -5
  106. package/src/device/bot.ts +10 -5
  107. package/src/device/ceilinglight.ts +36 -10
  108. package/src/device/colorbulb.ts +26 -7
  109. package/src/device/contact.ts +10 -5
  110. package/src/device/curtain.ts +22 -17
  111. package/src/device/device.ts +24 -6
  112. package/src/device/fan.ts +548 -0
  113. package/src/device/hub.ts +31 -23
  114. package/src/device/humidifier.ts +9 -4
  115. package/src/device/iosensor.ts +28 -20
  116. package/src/device/lightstrip.ts +41 -7
  117. package/src/device/lock.ts +13 -8
  118. package/src/device/meter.ts +30 -22
  119. package/src/device/meterplus.ts +12 -7
  120. package/src/device/motion.ts +9 -4
  121. package/src/device/plug.ts +9 -4
  122. package/src/device/robotvacuumcleaner.ts +15 -10
  123. package/src/device/waterdetector.ts +15 -8
  124. package/src/irdevice/airconditioner.ts +5 -4
  125. package/src/irdevice/airpurifier.ts +5 -4
  126. package/src/irdevice/camera.ts +4 -3
  127. package/src/irdevice/fan.ts +4 -3
  128. package/src/irdevice/irdevice.ts +11 -3
  129. package/src/irdevice/light.ts +3 -2
  130. package/src/irdevice/other.ts +47 -46
  131. package/src/irdevice/tv.ts +3 -2
  132. package/src/irdevice/vacuumcleaner.ts +3 -2
  133. package/src/irdevice/waterheater.ts +3 -2
  134. package/src/platform.ts +71 -5
  135. package/src/settings.ts +34 -9
  136. 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
- //BLE Mac Address
275
- bleMac?: string;
276
- //Device Model
277
- model?: string;
278
- //Device BLE Model
279
- bleModel?: string;
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. (Used by the following deviceTypes: Blind Tilt, Meter, MeterPlus, IOSensor)
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 = 'WoWaterDetector',
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
- Credit:
83
- https://github.com/WickyNilliams/pure-color
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);