@switchbot/homebridge-switchbot 3.5.0-beta.9 → 3.5.1-beta.0

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 (177) hide show
  1. package/.vscode/settings.json +4 -1
  2. package/CHANGELOG.md +4 -1
  3. package/config.schema.json +164 -22
  4. package/dist/device/blindtilt.d.ts +21 -96
  5. package/dist/device/blindtilt.d.ts.map +1 -1
  6. package/dist/device/blindtilt.js +457 -866
  7. package/dist/device/blindtilt.js.map +1 -1
  8. package/dist/device/bot.d.ts +27 -72
  9. package/dist/device/bot.d.ts.map +1 -1
  10. package/dist/device/bot.js +851 -913
  11. package/dist/device/bot.js.map +1 -1
  12. package/dist/device/ceilinglight.d.ts +15 -69
  13. package/dist/device/ceilinglight.d.ts.map +1 -1
  14. package/dist/device/ceilinglight.js +316 -742
  15. package/dist/device/ceilinglight.js.map +1 -1
  16. package/dist/device/colorbulb.d.ts +15 -76
  17. package/dist/device/colorbulb.d.ts.map +1 -1
  18. package/dist/device/colorbulb.js +380 -833
  19. package/dist/device/colorbulb.js.map +1 -1
  20. package/dist/device/contact.d.ts +14 -66
  21. package/dist/device/contact.d.ts.map +1 -1
  22. package/dist/device/contact.js +267 -602
  23. package/dist/device/contact.js.map +1 -1
  24. package/dist/device/curtain.d.ts +18 -89
  25. package/dist/device/curtain.d.ts.map +1 -1
  26. package/dist/device/curtain.js +469 -897
  27. package/dist/device/curtain.js.map +1 -1
  28. package/dist/device/device.d.ts +76 -0
  29. package/dist/device/device.d.ts.map +1 -0
  30. package/dist/device/device.js +846 -0
  31. package/dist/device/device.js.map +1 -0
  32. package/dist/device/fan.d.ts +63 -0
  33. package/dist/device/fan.d.ts.map +1 -0
  34. package/dist/device/fan.js +645 -0
  35. package/dist/device/fan.js.map +1 -0
  36. package/dist/device/hub.d.ts +19 -58
  37. package/dist/device/hub.d.ts.map +1 -1
  38. package/dist/device/hub.js +304 -640
  39. package/dist/device/hub.js.map +1 -1
  40. package/dist/device/humidifier.d.ts +11 -66
  41. package/dist/device/humidifier.d.ts.map +1 -1
  42. package/dist/device/humidifier.js +300 -710
  43. package/dist/device/humidifier.js.map +1 -1
  44. package/dist/device/iosensor.d.ts +12 -64
  45. package/dist/device/iosensor.d.ts.map +1 -1
  46. package/dist/device/iosensor.js +225 -643
  47. package/dist/device/iosensor.js.map +1 -1
  48. package/dist/device/lightstrip.d.ts +12 -70
  49. package/dist/device/lightstrip.d.ts.map +1 -1
  50. package/dist/device/lightstrip.js +371 -742
  51. package/dist/device/lightstrip.js.map +1 -1
  52. package/dist/device/lock.d.ts +17 -63
  53. package/dist/device/lock.d.ts.map +1 -1
  54. package/dist/device/lock.js +309 -642
  55. package/dist/device/lock.js.map +1 -1
  56. package/dist/device/meter.d.ts +15 -64
  57. package/dist/device/meter.d.ts.map +1 -1
  58. package/dist/device/meter.js +223 -638
  59. package/dist/device/meter.js.map +1 -1
  60. package/dist/device/meterplus.d.ts +15 -65
  61. package/dist/device/meterplus.d.ts.map +1 -1
  62. package/dist/device/meterplus.js +216 -644
  63. package/dist/device/meterplus.js.map +1 -1
  64. package/dist/device/motion.d.ts +12 -69
  65. package/dist/device/motion.d.ts.map +1 -1
  66. package/dist/device/motion.js +209 -588
  67. package/dist/device/motion.js.map +1 -1
  68. package/dist/device/plug.d.ts +10 -57
  69. package/dist/device/plug.d.ts.map +1 -1
  70. package/dist/device/plug.js +141 -532
  71. package/dist/device/plug.js.map +1 -1
  72. package/dist/device/robotvacuumcleaner.d.ts +13 -63
  73. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  74. package/dist/device/robotvacuumcleaner.js +252 -609
  75. package/dist/device/robotvacuumcleaner.js.map +1 -1
  76. package/dist/device/waterdetector.d.ts +11 -63
  77. package/dist/device/waterdetector.d.ts.map +1 -1
  78. package/dist/device/waterdetector.js +179 -521
  79. package/dist/device/waterdetector.js.map +1 -1
  80. package/dist/homebridge-ui/public/index.html +22 -16
  81. package/dist/homebridge-ui/server.js +1 -1
  82. package/dist/homebridge-ui/server.js.map +1 -1
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +2 -2
  86. package/dist/index.js.map +1 -1
  87. package/dist/irdevice/airconditioner.d.ts +10 -50
  88. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  89. package/dist/irdevice/airconditioner.js +337 -482
  90. package/dist/irdevice/airconditioner.js.map +1 -1
  91. package/dist/irdevice/airpurifier.d.ts +8 -39
  92. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  93. package/dist/irdevice/airpurifier.js +108 -333
  94. package/dist/irdevice/airpurifier.js.map +1 -1
  95. package/dist/irdevice/camera.d.ts +7 -36
  96. package/dist/irdevice/camera.d.ts.map +1 -1
  97. package/dist/irdevice/camera.js +47 -299
  98. package/dist/irdevice/camera.js.map +1 -1
  99. package/dist/irdevice/fan.d.ts +7 -43
  100. package/dist/irdevice/fan.d.ts.map +1 -1
  101. package/dist/irdevice/fan.js +95 -364
  102. package/dist/irdevice/fan.js.map +1 -1
  103. package/dist/irdevice/irdevice.d.ts +46 -0
  104. package/dist/irdevice/irdevice.d.ts.map +1 -0
  105. package/dist/irdevice/irdevice.js +393 -0
  106. package/dist/irdevice/irdevice.js.map +1 -0
  107. package/dist/irdevice/light.d.ts +12 -45
  108. package/dist/irdevice/light.d.ts.map +1 -1
  109. package/dist/irdevice/light.js +121 -376
  110. package/dist/irdevice/light.js.map +1 -1
  111. package/dist/irdevice/other.d.ts +19 -48
  112. package/dist/irdevice/other.d.ts.map +1 -1
  113. package/dist/irdevice/other.js +441 -584
  114. package/dist/irdevice/other.js.map +1 -1
  115. package/dist/irdevice/tv.d.ts +8 -40
  116. package/dist/irdevice/tv.d.ts.map +1 -1
  117. package/dist/irdevice/tv.js +94 -353
  118. package/dist/irdevice/tv.js.map +1 -1
  119. package/dist/irdevice/vacuumcleaner.d.ts +7 -36
  120. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  121. package/dist/irdevice/vacuumcleaner.js +48 -299
  122. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  123. package/dist/irdevice/waterheater.d.ts +7 -36
  124. package/dist/irdevice/waterheater.d.ts.map +1 -1
  125. package/dist/irdevice/waterheater.js +50 -305
  126. package/dist/irdevice/waterheater.js.map +1 -1
  127. package/dist/platform.d.ts +22 -8
  128. package/dist/platform.d.ts.map +1 -1
  129. package/dist/platform.js +342 -191
  130. package/dist/platform.js.map +1 -1
  131. package/dist/settings.d.ts +66 -18
  132. package/dist/settings.d.ts.map +1 -1
  133. package/dist/settings.js +16 -552
  134. package/dist/settings.js.map +1 -1
  135. package/dist/utils.d.ts +95 -0
  136. package/dist/utils.d.ts.map +1 -1
  137. package/dist/utils.js +657 -1
  138. package/dist/utils.js.map +1 -1
  139. package/eslint.config.js +96 -0
  140. package/package.json +20 -16
  141. package/src/custom.d.ts +2 -1
  142. package/src/device/blindtilt.ts +488 -937
  143. package/src/device/bot.ts +907 -1016
  144. package/src/device/ceilinglight.ts +330 -798
  145. package/src/device/colorbulb.ts +394 -904
  146. package/src/device/contact.ts +298 -637
  147. package/src/device/curtain.ts +496 -954
  148. package/src/device/device.ts +872 -0
  149. package/src/device/fan.ts +692 -0
  150. package/src/device/hub.ts +338 -671
  151. package/src/device/humidifier.ts +330 -777
  152. package/src/device/iosensor.ts +258 -671
  153. package/src/device/lightstrip.ts +394 -809
  154. package/src/device/lock.ts +345 -700
  155. package/src/device/meter.ts +256 -666
  156. package/src/device/meterplus.ts +248 -672
  157. package/src/device/motion.ts +234 -622
  158. package/src/device/plug.ts +152 -572
  159. package/src/device/robotvacuumcleaner.ts +273 -653
  160. package/src/device/waterdetector.ts +198 -549
  161. package/src/homebridge-ui/public/index.html +22 -16
  162. package/src/homebridge-ui/server.ts +1 -1
  163. package/src/index.ts +4 -3
  164. package/src/irdevice/airconditioner.ts +368 -540
  165. package/src/irdevice/airpurifier.ts +134 -369
  166. package/src/irdevice/camera.ts +60 -324
  167. package/src/irdevice/fan.ts +111 -392
  168. package/src/irdevice/irdevice.ts +406 -0
  169. package/src/irdevice/light.ts +159 -425
  170. package/src/irdevice/other.ts +509 -661
  171. package/src/irdevice/tv.ts +123 -388
  172. package/src/irdevice/vacuumcleaner.ts +61 -324
  173. package/src/irdevice/waterheater.ts +63 -333
  174. package/src/platform.ts +395 -259
  175. package/src/settings.ts +120 -610
  176. package/src/utils.ts +661 -1
  177. package/src/device/waterdetector.json +0 -11
package/src/settings.ts CHANGED
@@ -1,10 +1,9 @@
1
- /* Copyright(C) 2017-2023, donavanbecker (https://github.com/donavanbecker). All rights reserved.
1
+ /* Copyright(C) 2017-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
2
  *
3
3
  * settings.ts: @switchbot/homebridge-switchbot platform class.
4
4
  */
5
- /* eslint-disable max-len */
6
- import { MacAddress, PlatformConfig } from 'homebridge';
7
- import { IClientOptions } from 'async-mqtt';
5
+ import type { IClientOptions } from 'async-mqtt';
6
+ import type { MacAddress, PlatformConfig } from 'homebridge';
8
7
  /**
9
8
  * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
10
9
  */
@@ -20,6 +19,26 @@ export const PLUGIN_NAME = '@switchbot/homebridge-switchbot';
20
19
  */
21
20
  export const Devices = 'https://api.switch-bot.com/v1.1/devices';
22
21
 
22
+ /**
23
+ * This is the updateWebhook url used to access SwitchBot API
24
+ */
25
+ export const setupWebhook = 'https://api.switch-bot.com/v1.1/webhook/setupWebhook';
26
+
27
+ /**
28
+ * This is the updateWebhook url used to access SwitchBot API
29
+ */
30
+ export const queryWebhook = 'https://api.switch-bot.com/v1.1/webhook/queryWebhook';
31
+
32
+ /**
33
+ * This is the updateWebhook url used to access SwitchBot API
34
+ */
35
+ export const updateWebhook = 'https://api.switch-bot.com/v1.1/webhook/updateWebhook';
36
+
37
+ /**
38
+ * This is the deleteWebhook url used to access SwitchBot API
39
+ */
40
+ export const deleteWebhook = 'https://api.switch-bot.com/v1.1/webhook/deleteWebhook';
41
+
23
42
  //Config
24
43
  export interface SwitchBotPlatformConfig extends PlatformConfig {
25
44
  credentials?: credentials;
@@ -35,10 +54,13 @@ export type credentials = {
35
54
 
36
55
  export type options = {
37
56
  refreshRate?: number;
57
+ updateRate?: number;
38
58
  pushRate?: number;
59
+ maxRetries?: number;
60
+ delayBetweenRetries?: number;
39
61
  logging?: string;
40
- devices?: Array<devicesConfig>;
41
- irdevices?: Array<irDevicesConfig>;
62
+ devices?: devicesConfig[];
63
+ irdevices?: irDevicesConfig[];
42
64
  webhookURL?: string;
43
65
  mqttURL?: string;
44
66
  mqttOptions?: IClientOptions;
@@ -46,11 +68,17 @@ export type options = {
46
68
  };
47
69
 
48
70
  export interface devicesConfig extends device {
71
+ bleMac?: string;
72
+ model?: string;
73
+ bleModel?: string;
74
+ bleModelName?: string;
49
75
  configDeviceType: string;
50
76
  configDeviceName?: string;
51
77
  deviceId: string;
52
78
  external?: boolean;
53
79
  refreshRate?: number;
80
+ updateRate?: number;
81
+ pushRate?: number;
54
82
  firmware?: string;
55
83
  logging?: string;
56
84
  connectionType?: string;
@@ -59,6 +87,8 @@ export interface devicesConfig extends device {
59
87
  hide_device?: boolean;
60
88
  offline?: boolean;
61
89
  maxRetry?: number;
90
+ maxRetries?: number;
91
+ delayBetweenRetries?: number;
62
92
  disableCaching?: boolean;
63
93
  mqttURL?: string;
64
94
  mqttOptions?: IClientOptions;
@@ -67,6 +97,7 @@ export interface devicesConfig extends device {
67
97
  webhook?: boolean;
68
98
  bot?: bot;
69
99
  meter?: meter;
100
+ iosensor?: iosensor;
70
101
  humidifier?: humidifier;
71
102
  curtain?: curtain;
72
103
  blindTilt?: blindTilt;
@@ -83,6 +114,13 @@ export interface devicesConfig extends device {
83
114
 
84
115
  export type meter = {
85
116
  hide_temperature?: boolean;
117
+ convertUnitTo?: string;
118
+ hide_humidity?: boolean;
119
+ };
120
+
121
+ export type iosensor = {
122
+ hide_temperature?: boolean;
123
+ convertUnitTo?: string;
86
124
  hide_humidity?: boolean;
87
125
  };
88
126
 
@@ -105,7 +143,6 @@ export type curtain = {
105
143
  hide_lightsensor?: boolean;
106
144
  set_minLux?: number;
107
145
  set_maxLux?: number;
108
- updateRate?: number;
109
146
  set_max?: number;
110
147
  set_min?: number;
111
148
  set_minStep?: number;
@@ -118,7 +155,6 @@ export type blindTilt = {
118
155
  hide_lightsensor?: boolean;
119
156
  set_minLux?: number;
120
157
  set_maxLux?: number;
121
- updateRate?: number;
122
158
  set_max?: number;
123
159
  set_min?: number;
124
160
  set_minStep?: number;
@@ -165,6 +201,7 @@ export type lock = {
165
201
 
166
202
  export type hub = {
167
203
  hide_temperature?: boolean;
204
+ convertUnitTo?: string;
168
205
  hide_humidity?: boolean;
169
206
  hide_lightsensor?: boolean;
170
207
  };
@@ -230,7 +267,7 @@ export type body = {
230
267
 
231
268
  //a list of physical devices.
232
269
  export type deviceList = {
233
- device: Array<device>;
270
+ device: device[];
234
271
  };
235
272
 
236
273
  export type device = {
@@ -245,9 +282,9 @@ export type device = {
245
282
  //device's parent Hub ID.
246
283
  hubDeviceId: string;
247
284
  //only available for Curtain devices. a list of Curtain device IDs such that the Curtain devices are being paired or grouped.
248
- curtainDevicesIds?: Array<string>;
285
+ curtainDevicesIds?: string[];
249
286
  //only available for Blind Titl devices. a list of Blind Tilt device IDs such that the Blind Tilt devices are being paired or grouped.
250
- blindTiltDevicesIds?: Array<string>;
287
+ blindTiltDevicesIds?: string[];
251
288
  //only available for Curtain/Lock devices. determines if the open position and the close position of a device have been properly calibrated or not
252
289
  calibrate?: boolean;
253
290
  //only available for Curtain devices. determines if a Curtain is paired with or grouped with another Curtain or not.
@@ -261,14 +298,28 @@ export type device = {
261
298
  //the current position, 0-100
262
299
  slidePosition?: string;
263
300
  //the version of the device
264
- version?: number;
265
- //BLE Mac Address
266
- bleMac?: string;
301
+ version?: string;
302
+ // Fan Mode: direct mode: direct; natural mode: "natural"; sleep mode: "sleep"; ultra quiet mode: "baby"
303
+ mode: string;
304
+ //the current battery level
305
+ battery: number;
306
+ //ON/OFF state
307
+ power: string;
308
+ //set nightlight status. turn off: off; mode 1: 1; mode 2: 2
309
+ nightStatus: number;
310
+ //set horizontal oscillation. turn on: on; turn off: off
311
+ oscillation: string;
312
+ //set vertical oscillation. turn on: on; turn off: off
313
+ verticalOscillation: string;
314
+ //battery charge status. charging or uncharged
315
+ chargingStatus: string;
316
+ //fan speed. 1~100
317
+ fanSpeed: number;
267
318
  };
268
319
 
269
320
  //a list of virtual infrared remote devices.
270
321
  export type infraredRemoteList = {
271
- device: Array<irdevice>;
322
+ device: irdevice[];
272
323
  };
273
324
 
274
325
  export type irdevice = {
@@ -276,49 +327,62 @@ export type irdevice = {
276
327
  deviceName: string; //device name
277
328
  remoteType: string; //device type
278
329
  hubDeviceId: string; //remote device's parent Hub ID
330
+ model: string; //device model
279
331
  };
280
332
 
281
333
  export type deviceStatus = {
334
+ statusCode: number;
335
+ message: string;
336
+ body: deviceStatusBody;
337
+ };
338
+
339
+ export type deviceStatusBody = {
282
340
  //v1.1 of API
283
- 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)
284
- 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)
285
- 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)
286
- 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)
287
- calibrate?: boolean; //determines if device has been calibrated or not. (Used by the following deviceTypes: Curtain, Lock, Blind Tilt)
288
- group?: boolean; //determines if a device is paired with or grouped with another device or not. (Used by the following deviceTypes: Curtain, Blind Tilt)
289
- moving?: boolean; //determines if a device is moving or not. (Used by the following deviceTypes: Curtain, Blind Tilt)
290
- slidePosition?: number; //the current position (0-100) the percentage of the distance between the calibrated open position and closed position. (Used by the following deviceTypes: Curtain, Blind Tilt)
291
- temperature?: number; //temperature in celsius (Used by the following deviceTypes: Meter, Meter Plus, Humidifier, IOSensor)
292
- humidity?: number; //humidity percentage. (Used by the following deviceTypes: Meter, Meter Plus, Humidifier, IOSensor)
293
- lockState?: string; //determines if locked or not. (Used by the following deviceTypes: Lock)
294
- doorState?: string; //determines if the door is closed or not. (Used by the following deviceTypes: Lock)
295
- moveDetected?: boolean; //determines if motion is detected. (Used by the following deviceTypes: Motion Sensor, Contact Sensor)
296
- brightness?: string | number; //the ambient brightness picked up by the sensor. bright or dim. (Used by the following deviceTypes: Motion Sensor, Contact Sensor) | the brightness value, range from 1 to 100. (Used by the following deviceTypes: Ceiling Light, Ceiling Light Pro, Strip Light, Color Bulb)
297
- openState?: string; //the open state of the sensor. open, close, or timeOutNotClose. (Used by the following deviceTypes: Contact Sensor)
298
- colorTemperature?: number; //the color temperature value, range from 2700 to 6500. (Used by the following deviceTypes: Ceiling Light, Ceiling Light Pro, Color Bulb)
299
- voltage?: number; //the voltage of the device, measured in Volt. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
300
- weight?: number; //the power consumed in a day, measured in Watts. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
301
- electricityOfDay?: number; //the duration that the device has been used during a day, measured in minutes. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
302
- electricCurrent?: number; //the current of the device at the moment, measured in Amp. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
303
- color?: string; //the color value, RGB "255:255:255". (Used by the following deviceTypes: Strip Light, Color Bulb)
304
- workingStatus?: string; //the working status of the device. StandBy, Clearing, Paused, GotoChargeBase, Charging, ChargeDone, Dormant, InTrouble, InRemoteControl, or InDustCollecting. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus)
305
- onlineStatus?: string; //the connection status of the device. online or offline. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus)
306
- battery?: number; //the current battery level. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Blind Tilt, IOSensor)
307
- deviceName?: string; //device name. (Used by the following deviceTypes: Robot Vacuum Cleaner S1 Plus)
308
- nebulizationEfficiency?: number; //atomization efficiency percentage. (Used by the following deviceTypes: Humidifier)
309
- auto?: boolean; //determines if a Humidifier is in Auto Mode or not. (Used by the following deviceTypes: Humidifier)
310
- childLock?: boolean; //determines if a Humidifier's safety lock is on or not. (Used by the following deviceTypes: Humidifier)
311
- sound?: boolean; //determines if a Humidifier is muted or not. (Used by the following deviceTypes: Humidifier)
312
- lackWater?: boolean; //determines if the water tank is empty or not. (Used by the following deviceTypes: Humidifier)
313
- version?: number; //the version of the device. (Used by the following deviceTypes: Blind Tilt, Meter, MeterPlus, IOSensor)
314
- direction?: string; //the opening direction of a Blind Tilt device. (Used by the following deviceTypes: Blind Tilt)
315
- runStatus?: string; //'static' when not moving. (Used by the following deviceTypes: Blind Tilt)
316
- mode?: number; //available for devices. the fan mode. (Used by the following deviceTypes: Smart Fan)
317
- speed?: number; //the fan speed. (Used by the following deviceTypes: Smart Fan)
318
- shaking?: boolean; //determines if the fan is swinging or not. (Used by the following deviceTypes: Smart Fan)
319
- shakeCenter?: string; //the fan's swing direction. (Used by the following deviceTypes: Smart Fan)
320
- shakeRange?: string; //the fan's swing range, 0~120°. (Used by the following deviceTypes: Smart Fan)
321
- status?: number //the leak status. 0 for no leak, 1 for leak. (Used by the following deviceTypes: Water Detector)
341
+ deviceId: string;
342
+ deviceType: string;
343
+ hubDeviceId: string;
344
+ power?: string;
345
+ calibrate?: boolean;
346
+ group?: boolean;
347
+ moving?: boolean;
348
+ slidePosition?: number;
349
+ temperature?: number;
350
+ humidity?: number;
351
+ lockState?: string;
352
+ doorState?: string;
353
+ moveDetected?: boolean;
354
+ brightness?: string | number;
355
+ openState?: string;
356
+ colorTemperature?: number;
357
+ voltage?: number;
358
+ weight?: number;
359
+ electricityOfDay?: number;
360
+ electricCurrent?: number;
361
+ color?: string;
362
+ workingStatus?: string;
363
+ onlineStatus?: string;
364
+ battery?: number;
365
+ deviceName?: string;
366
+ nebulizationEfficiency?: number;
367
+ auto?: boolean;
368
+ childLock?: boolean;
369
+ sound?: boolean;
370
+ lackWater?: boolean;
371
+ version?: number;
372
+ direction?: string;
373
+ runStatus?: string;
374
+ mode?: number | string;
375
+ speed?: number;
376
+ shaking?: boolean;
377
+ shakeCenter?: string;
378
+ shakeRange?: string;
379
+ status?: number;
380
+ lightLevel?: number;
381
+ nightStatus: number;
382
+ oscillation: string;
383
+ verticalOscillation: string;
384
+ chargingStatus: string;
385
+ fanSpeed: number;
322
386
  };
323
387
 
324
388
  export type ad = {
@@ -355,14 +419,14 @@ export type serviceData = {
355
419
  battery?: number;
356
420
  //Humidifier's humidity level percentage
357
421
  percentage?: boolean | string;
358
- //Humidifier's humidity level percentage
422
+ //Humidifier's state
359
423
  onState?: boolean;
360
424
  //Humidifier's AutoMode
361
425
  autoMode?: boolean;
362
426
  //Meter Temperature Levels
363
427
  temperature?: temperature;
364
428
  // Fahrenheit enabled for Meter
365
- fahrenheit: boolean;
429
+ fahrenheit?: boolean;
366
430
  // Humidity level for Meter
367
431
  humidity?: number;
368
432
  //Motion Detected for Contact or Motion Sensors
@@ -406,557 +470,3 @@ export type switchbot = {
406
470
  wait: (arg0: number) => any;
407
471
  };
408
472
 
409
- export function rgb2hs(r: any, g: any, b: any) {
410
- /*
411
- Credit:
412
- https://github.com/WickyNilliams/pure-color
413
- */
414
- r = parseInt(r);
415
- g = parseInt(g);
416
- b = parseInt(b);
417
- const min = Math.min(r, g, b);
418
- const max = Math.max(r, g, b);
419
- const delta = max - min;
420
- let h;
421
- let s;
422
- if (max === 0) {
423
- s = 0;
424
- } else {
425
- s = (delta / max) * 100;
426
- }
427
- if (max === min) {
428
- h = 0;
429
- } else if (r === max) {
430
- h = (g - b) / delta;
431
- } else if (g === max) {
432
- h = 2 + (b - r) / delta;
433
- } else if (b === max) {
434
- h = 4 + (r - g) / delta;
435
- }
436
- h = Math.min(h * 60, 360);
437
-
438
- if (h < 0) {
439
- h += 360;
440
- }
441
- return [Math.round(h), Math.round(s)];
442
- }
443
-
444
- export function hs2rgb(h: any, s: any) {
445
- /*
446
- Credit:
447
- https://github.com/WickyNilliams/pure-color
448
- */
449
- h = parseInt(h) / 60;
450
- s = parseInt(s) / 100;
451
- const f = h - Math.floor(h);
452
- const p = 255 * (1 - s);
453
- const q = 255 * (1 - s * f);
454
- const t = 255 * (1 - s * (1 - f));
455
- let rgb;
456
- switch (Math.floor(h) % 6) {
457
- case 0:
458
- rgb = [255, t, p];
459
- break;
460
- case 1:
461
- rgb = [q, 255, p];
462
- break;
463
- case 2:
464
- rgb = [p, 255, t];
465
- break;
466
- case 3:
467
- rgb = [p, q, 255];
468
- break;
469
- case 4:
470
- rgb = [t, p, 255];
471
- break;
472
- case 5:
473
- rgb = [255, p, q];
474
- break;
475
- }
476
- if (rgb[0] === 255) {
477
- rgb[1] *= 0.8;
478
- rgb[2] *= 0.8;
479
- if (rgb[1] <= 25 && rgb[2] <= 25) {
480
- rgb[1] = 0;
481
- rgb[2] = 0;
482
- }
483
- }
484
- return [Math.round(rgb[0]), Math.round(rgb[1]), Math.round(rgb[2])];
485
- }
486
-
487
- export function k2rgb(k: number) {
488
- // Set kelvin to nearest 100, between 2000 and 7100
489
- k = Math.round(k / 100) * 100;
490
- k = Math.max(Math.min(k, 7100), 2000);
491
-
492
- // k should now appear in our table of kelvin to rgb
493
- const values = {
494
- 2000: [255, 141, 11],
495
- 2100: [255, 146, 29],
496
- 2200: [255, 147, 44],
497
- 2300: [255, 152, 54],
498
- 2400: [255, 157, 63],
499
- 2500: [255, 166, 69],
500
- 2600: [255, 170, 77],
501
- 2700: [255, 174, 84],
502
- 2800: [255, 173, 94],
503
- 2900: [255, 177, 101],
504
- 3000: [255, 180, 107],
505
- 3100: [255, 189, 111],
506
- 3200: [255, 187, 120],
507
- 3300: [255, 195, 124],
508
- 3400: [255, 198, 130],
509
- 3500: [255, 201, 135],
510
- 3600: [255, 203, 141],
511
- 3700: [255, 206, 146],
512
- 3800: [255, 204, 153],
513
- 3900: [255, 206, 159],
514
- 4000: [255, 213, 161],
515
- 4100: [255, 215, 166],
516
- 4200: [255, 217, 171],
517
- 4300: [255, 219, 175],
518
- 4400: [255, 221, 180],
519
- 4500: [255, 223, 184],
520
- 4600: [255, 225, 188],
521
- 4700: [255, 226, 192],
522
- 4800: [255, 228, 196],
523
- 4900: [255, 229, 200],
524
- 5000: [255, 231, 204],
525
- 5100: [255, 230, 210],
526
- 5200: [255, 234, 211],
527
- 5300: [255, 235, 215],
528
- 5400: [255, 237, 218],
529
- 5500: [255, 236, 224],
530
- 5700: [255, 240, 228],
531
- 5800: [255, 241, 231],
532
- 5900: [255, 243, 234],
533
- 6000: [255, 244, 237],
534
- 6100: [255, 245, 240],
535
- 6200: [255, 246, 243],
536
- 6300: [255, 247, 247],
537
- 6400: [255, 248, 251],
538
- 6500: [255, 249, 253],
539
- 6600: [254, 249, 255],
540
- 6700: [252, 247, 255],
541
- 6800: [249, 246, 255],
542
- 6900: [247, 245, 255],
543
- 7000: [245, 243, 255],
544
- 7100: [243, 242, 255],
545
- };
546
-
547
- // Return the value
548
- return values[k];
549
- }
550
-
551
- export function m2hs(m) {
552
- /*
553
- Credit:
554
- https://github.com/homebridge/HAP-NodeJS
555
- */
556
- const table = {
557
- 100: [19, 222.1],
558
- 101: [18.7, 222.2],
559
- 102: [18.4, 222.3],
560
- 103: [18.2, 222.3],
561
- 104: [17.9, 222.4],
562
- 105: [17.6, 222.5],
563
- 106: [17.3, 222.7],
564
- 107: [17, 222.8],
565
- 108: [16.7, 222.9],
566
- 109: [16.4, 223],
567
- 110: [16.1, 223.2],
568
- 111: [15.8, 223.3],
569
- 112: [15.4, 223.4],
570
- 113: [15.2, 223.6],
571
- 114: [14.9, 223.8],
572
- 115: [14.7, 223.9],
573
- 116: [14.3, 224.1],
574
- 117: [14.1, 224.2],
575
- 118: [13.8, 224.4],
576
- 119: [13.5, 224.6],
577
- 120: [13.2, 224.8],
578
- 121: [12.9, 225],
579
- 122: [12.5, 225.3],
580
- 123: [12.2, 225.6],
581
- 124: [11.8, 225.9],
582
- 125: [11.4, 226.3],
583
- 126: [11.1, 226.7],
584
- 127: [10.7, 227.1],
585
- 128: [10.3, 227.6],
586
- 129: [9.9, 228],
587
- 130: [9.6, 228.5],
588
- 131: [9.3, 229.1],
589
- 132: [8.9, 229.6],
590
- 133: [8.5, 230.2],
591
- 134: [8.2, 230.9],
592
- 135: [7.8, 231.6],
593
- 136: [7.5, 232.5],
594
- 137: [7.1, 233.5],
595
- 138: [6.7, 234.6],
596
- 139: [6.3, 235.8],
597
- 140: [6, 237.1],
598
- 141: [5.6, 238.9],
599
- 142: [5.2, 240.9],
600
- 143: [5, 242.9],
601
- 144: [4.8, 244.9],
602
- 145: [4.6, 246.9],
603
- 146: [4.4, 249.3],
604
- 147: [4.3, 251.9],
605
- 148: [4.1, 254.9],
606
- 149: [3.9, 258],
607
- 150: [3.7, 261.8],
608
- 151: [3.4, 265.9],
609
- 152: [3.2, 271],
610
- 153: [3, 276.4],
611
- 154: [2.8, 283.6],
612
- 155: [2.6, 290.4],
613
- 156: [2.3, 295.3],
614
- 157: [2.1, 300],
615
- 158: [1.9, 300],
616
- 159: [1.6, 300],
617
- 160: [1.4, 195.8],
618
- 161: [1.2, 84.3],
619
- 162: [1.3, 58.2],
620
- 163: [1.5, 55.9],
621
- 164: [1.7, 53.2],
622
- 165: [1.9, 50.2],
623
- 166: [2.1, 47.1],
624
- 167: [2.4, 44.5],
625
- 168: [2.6, 42.6],
626
- 169: [2.9, 40.9],
627
- 170: [3.1, 39.5],
628
- 171: [3.4, 38.3],
629
- 172: [3.7, 37.3],
630
- 173: [3.9, 36.5],
631
- 174: [4.2, 35.7],
632
- 175: [4.4, 35.1],
633
- 176: [4.6, 34.5],
634
- 177: [4.9, 34],
635
- 178: [5.1, 33.5],
636
- 179: [5.3, 33],
637
- 180: [5.6, 32.7],
638
- 181: [5.8, 32.3],
639
- 182: [6, 32],
640
- 183: [6.3, 31.7],
641
- 184: [6.5, 31.4],
642
- 185: [6.7, 31.2],
643
- 186: [7, 30.9],
644
- 187: [7.2, 30.7],
645
- 188: [7.4, 30.5],
646
- 189: [7.6, 30.3],
647
- 190: [7.9, 30.1],
648
- 191: [8.1, 29.9],
649
- 192: [8.4, 29.7],
650
- 193: [8.6, 29.6],
651
- 194: [8.9, 29.5],
652
- 195: [9.1, 29.3],
653
- 196: [9.4, 29.2],
654
- 197: [9.6, 29.1],
655
- 198: [9.8, 29],
656
- 199: [10, 28.9],
657
- 200: [10.2, 28.7],
658
- 201: [10.5, 28.7],
659
- 202: [10.7, 28.6],
660
- 203: [11, 28.5],
661
- 204: [11.2, 28.4],
662
- 205: [11.4, 28.3],
663
- 206: [11.6, 28.3],
664
- 207: [11.8, 28.2],
665
- 208: [12.1, 28.1],
666
- 209: [12.3, 28.1],
667
- 210: [12.5, 28],
668
- 211: [12.7, 28],
669
- 212: [12.9, 27.9],
670
- 213: [13.2, 27.8],
671
- 214: [13.4, 27.8],
672
- 215: [13.6, 27.7],
673
- 216: [13.8, 27.7],
674
- 217: [14, 27.7],
675
- 218: [14.3, 27.6],
676
- 219: [14.5, 27.6],
677
- 220: [14.7, 27.5],
678
- 221: [14.9, 27.5],
679
- 222: [15.1, 27.5],
680
- 223: [15.3, 27.4],
681
- 224: [15.5, 27.4],
682
- 225: [15.8, 27.4],
683
- 226: [16, 27.3],
684
- 227: [16.2, 27.3],
685
- 228: [16.4, 27.3],
686
- 229: [16.6, 27.3],
687
- 230: [16.8, 27.2],
688
- 231: [17, 27.2],
689
- 232: [17.2, 27.2],
690
- 233: [17.4, 27.2],
691
- 234: [17.6, 27.2],
692
- 235: [17.8, 27.1],
693
- 236: [18, 27.1],
694
- 237: [18.2, 27.1],
695
- 238: [18.4, 27.1],
696
- 239: [18.7, 27.1],
697
- 240: [18.8, 27],
698
- 241: [19, 27],
699
- 242: [19.2, 27],
700
- 243: [19.4, 27],
701
- 244: [19.6, 27],
702
- 245: [19.8, 27],
703
- 246: [20, 27],
704
- 247: [20.3, 26.9],
705
- 248: [20.5, 26.9],
706
- 249: [20.6, 26.9],
707
- 250: [20.8, 26.9],
708
- 251: [21, 26.9],
709
- 252: [21.3, 26.9],
710
- 253: [21.5, 26.9],
711
- 254: [21.6, 26.9],
712
- 255: [21.8, 26.8],
713
- 256: [22, 26.8],
714
- 257: [22.2, 26.8],
715
- 258: [22.4, 26.8],
716
- 259: [22.6, 26.8],
717
- 260: [22.8, 26.8],
718
- 261: [23, 26.8],
719
- 262: [23.2, 26.8],
720
- 263: [23.4, 26.8],
721
- 264: [23.6, 26.8],
722
- 265: [23.8, 26.8],
723
- 266: [24, 26.8],
724
- 267: [24.1, 26.8],
725
- 268: [24.3, 26.8],
726
- 269: [24.5, 26.8],
727
- 270: [24.7, 26.8],
728
- 271: [24.8, 26.8],
729
- 272: [25.1, 26.7],
730
- 273: [25.3, 26.7],
731
- 274: [25.4, 26.7],
732
- 275: [25.6, 26.7],
733
- 276: [25.8, 26.7],
734
- 277: [26, 26.7],
735
- 278: [26.1, 26.7],
736
- 279: [26.3, 26.7],
737
- 280: [26.5, 26.7],
738
- 281: [26.7, 26.7],
739
- 282: [26.9, 26.7],
740
- 283: [27.1, 26.7],
741
- 284: [27.3, 26.7],
742
- 285: [27.5, 26.7],
743
- 286: [27.7, 26.7],
744
- 287: [27.8, 26.7],
745
- 288: [28, 26.7],
746
- 289: [28.2, 26.7],
747
- 290: [28.4, 26.7],
748
- 291: [28.6, 26.7],
749
- 292: [28.8, 26.7],
750
- 293: [28.9, 26.7],
751
- 294: [29.1, 26.7],
752
- 295: [29.3, 26.7],
753
- 296: [29.5, 26.7],
754
- 297: [29.6, 26.7],
755
- 298: [29.8, 26.7],
756
- 299: [30, 26.7],
757
- 300: [30.2, 26.7],
758
- 301: [30.4, 26.7],
759
- 302: [30.5, 26.7],
760
- 303: [30.7, 26.7],
761
- 304: [30.9, 26.7],
762
- 305: [31.1, 26.7],
763
- 306: [31.2, 26.7],
764
- 307: [31.4, 26.7],
765
- 308: [31.6, 26.7],
766
- 309: [31.8, 26.8],
767
- 310: [31.9, 26.8],
768
- 311: [32.1, 26.8],
769
- 312: [32.3, 26.8],
770
- 313: [32.5, 26.8],
771
- 314: [32.6, 26.8],
772
- 315: [32.8, 26.8],
773
- 316: [33, 26.8],
774
- 317: [33.2, 26.8],
775
- 318: [33.3, 26.8],
776
- 319: [33.5, 26.8],
777
- 320: [33.7, 26.8],
778
- 321: [33.8, 26.8],
779
- 322: [34, 26.8],
780
- 323: [34.2, 26.8],
781
- 324: [34.4, 26.8],
782
- 325: [34.5, 26.8],
783
- 326: [34.7, 26.8],
784
- 327: [34.9, 26.8],
785
- 328: [35.1, 26.8],
786
- 329: [35.2, 26.8],
787
- 330: [35.4, 26.8],
788
- 331: [35.5, 26.8],
789
- 332: [35.7, 26.8],
790
- 333: [35.9, 26.8],
791
- 334: [36.1, 26.8],
792
- 335: [36.3, 26.9],
793
- 336: [36.5, 26.9],
794
- 337: [36.7, 26.9],
795
- 338: [36.9, 26.9],
796
- 339: [37.1, 26.9],
797
- 340: [37.2, 26.9],
798
- 341: [37.4, 26.9],
799
- 342: [37.5, 26.9],
800
- 343: [37.7, 26.9],
801
- 344: [37.9, 26.9],
802
- 345: [38.1, 26.9],
803
- 346: [38.3, 26.9],
804
- 347: [38.5, 26.9],
805
- 348: [38.7, 26.9],
806
- 349: [38.9, 26.9],
807
- 350: [39, 26.9],
808
- 351: [39.2, 26.9],
809
- 352: [39.3, 27],
810
- 353: [39.5, 27],
811
- 354: [39.7, 27],
812
- 355: [39.9, 27],
813
- 356: [40.1, 27],
814
- 357: [40.2, 27],
815
- 358: [40.4, 27],
816
- 359: [40.6, 27],
817
- 360: [40.8, 27],
818
- 361: [40.9, 27],
819
- 362: [41.1, 27],
820
- 363: [41.2, 27],
821
- 364: [41.4, 27],
822
- 365: [41.6, 27],
823
- 366: [41.8, 27],
824
- 367: [42, 27],
825
- 368: [42.1, 27.1],
826
- 369: [42.3, 27.1],
827
- 370: [42.4, 27.1],
828
- 371: [42.6, 27.1],
829
- 372: [42.8, 27.1],
830
- 373: [43, 27.1],
831
- 374: [43.1, 27.1],
832
- 375: [43.2, 27.1],
833
- 376: [43.4, 27.1],
834
- 377: [43.6, 27.1],
835
- 378: [43.8, 27.1],
836
- 379: [43.9, 27.1],
837
- 380: [44.1, 27.1],
838
- 381: [44.3, 27.2],
839
- 382: [44.4, 27.2],
840
- 383: [44.6, 27.2],
841
- 384: [44.7, 27.2],
842
- 385: [44.9, 27.2],
843
- 386: [45.1, 27.2],
844
- 387: [45.3, 27.2],
845
- 388: [45.5, 27.2],
846
- 389: [45.6, 27.2],
847
- 390: [45.8, 27.2],
848
- 391: [46, 27.2],
849
- 392: [46.2, 27.2],
850
- 393: [46.4, 27.3],
851
- 394: [46.5, 27.3],
852
- 395: [46.7, 27.3],
853
- 396: [46.9, 27.3],
854
- 397: [47.1, 27.3],
855
- 398: [47.2, 27.3],
856
- 399: [47.4, 27.3],
857
- 400: [47.6, 27.3],
858
- 401: [47.7, 27.3],
859
- 402: [47.9, 27.3],
860
- 403: [48.1, 27.3],
861
- 404: [48.3, 27.3],
862
- 405: [48.5, 27.4],
863
- 406: [48.7, 27.4],
864
- 407: [48.8, 27.4],
865
- 408: [49, 27.4],
866
- 409: [49.2, 27.4],
867
- 410: [49.4, 27.4],
868
- 411: [49.6, 27.4],
869
- 412: [49.7, 27.4],
870
- 413: [49.9, 27.4],
871
- 414: [50.1, 27.4],
872
- 415: [50.2, 27.4],
873
- 416: [50.4, 27.4],
874
- 417: [50.6, 27.5],
875
- 418: [50.7, 27.5],
876
- 419: [50.9, 27.5],
877
- 420: [51.1, 27.5],
878
- 421: [51.2, 27.5],
879
- 422: [51.4, 27.5],
880
- 423: [51.6, 27.5],
881
- 424: [51.7, 27.5],
882
- 425: [51.9, 27.5],
883
- 426: [52.1, 27.5],
884
- 427: [51.2, 27.6],
885
- 428: [52.4, 27.6],
886
- 429: [52.5, 27.6],
887
- 430: [52.7, 27.6],
888
- 431: [52.9, 27.6],
889
- 432: [53.1, 27.6],
890
- 433: [53.2, 27.6],
891
- 434: [53.4, 27.6],
892
- 435: [53.6, 27.6],
893
- 436: [53.7, 27.6],
894
- 437: [53.9, 27.6],
895
- 438: [54.1, 27.7],
896
- 439: [54.2, 27.7],
897
- 440: [54.3, 27.7],
898
- 441: [54.5, 27.7],
899
- 442: [54.7, 27.7],
900
- 443: [54.8, 27.7],
901
- 444: [55, 27.7],
902
- 445: [55.2, 27.7],
903
- 446: [55.3, 27.7],
904
- 447: [55.5, 27.7],
905
- 448: [55.7, 27.7],
906
- 449: [55.8, 27.8],
907
- 450: [56, 27.8],
908
- 451: [56.2, 27.8],
909
- 452: [56.3, 27.8],
910
- 453: [56.5, 27.8],
911
- 454: [56.7, 27.8],
912
- 455: [56.8, 27.8],
913
- 456: [57, 27.8],
914
- 457: [57.2, 27.8],
915
- 458: [57.3, 27.9],
916
- 459: [57.4, 27.9],
917
- 460: [57.6, 27.9],
918
- 461: [57.8, 27.9],
919
- 462: [57.9, 27.9],
920
- 463: [58.1, 27.9],
921
- 464: [58.3, 27.9],
922
- 465: [58.4, 27.9],
923
- 466: [58.6, 27.9],
924
- 467: [58.8, 27.9],
925
- 468: [59, 28],
926
- 469: [59.1, 28],
927
- 470: [59.2, 28],
928
- 471: [59.4, 28],
929
- 472: [59.6, 28],
930
- 473: [59.7, 28],
931
- 474: [60, 28],
932
- 475: [60.1, 28],
933
- 476: [60.2, 28],
934
- 477: [60.4, 28],
935
- 478: [60.6, 28.1],
936
- 479: [60.7, 28.1],
937
- 480: [60.9, 28.1],
938
- 481: [60.1, 28.1],
939
- 482: [60.3, 28.1],
940
- 483: [61.4, 28.1],
941
- 484: [61.5, 28.1],
942
- 485: [61.7, 28.1],
943
- 486: [61.9, 28.1],
944
- 487: [62, 28.2],
945
- 488: [62.2, 28.2],
946
- 489: [62.3, 28.2],
947
- 490: [62.5, 28.2],
948
- 491: [62.7, 28.2],
949
- 492: [62.8, 28.2],
950
- 493: [63, 28.2],
951
- 494: [63.2, 28.2],
952
- 495: [63.3, 28.2],
953
- 496: [63.4, 28.2],
954
- 497: [63.6, 28.2],
955
- 498: [63.8, 28.3],
956
- 499: [63.9, 28.3],
957
- 500: [64.1, 28.3],
958
- };
959
- const input = Math.min(Math.max(Math.round(m), 140), 500);
960
- const toReturn = table[input];
961
- return [Math.round(toReturn[1]), Math.round(toReturn[0])];
962
- }