@switchbot/homebridge-switchbot 3.5.1-beta.0 → 3.5.1-beta.10

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 (197) hide show
  1. package/README.md +16 -0
  2. package/dist/device/blindtilt.d.ts +15 -6
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +224 -370
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts +9 -4
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +197 -221
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts +10 -5
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +214 -292
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts +10 -5
  15. package/dist/device/colorbulb.d.ts.map +1 -1
  16. package/dist/device/colorbulb.js +335 -421
  17. package/dist/device/colorbulb.js.map +1 -1
  18. package/dist/device/contact.d.ts +9 -4
  19. package/dist/device/contact.d.ts.map +1 -1
  20. package/dist/device/contact.js +121 -200
  21. package/dist/device/contact.js.map +1 -1
  22. package/dist/device/curtain.d.ts +20 -7
  23. package/dist/device/curtain.d.ts.map +1 -1
  24. package/dist/device/curtain.js +229 -403
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/device.d.ts +41 -22
  27. package/dist/device/device.d.ts.map +1 -1
  28. package/dist/device/device.js +212 -181
  29. package/dist/device/device.js.map +1 -1
  30. package/dist/device/fan.d.ts +9 -4
  31. package/dist/device/fan.d.ts.map +1 -1
  32. package/dist/device/fan.js +204 -249
  33. package/dist/device/fan.js.map +1 -1
  34. package/dist/device/hub.d.ts +9 -5
  35. package/dist/device/hub.d.ts.map +1 -1
  36. package/dist/device/hub.js +107 -233
  37. package/dist/device/hub.js.map +1 -1
  38. package/dist/device/humidifier.d.ts +12 -4
  39. package/dist/device/humidifier.d.ts.map +1 -1
  40. package/dist/device/humidifier.js +193 -235
  41. package/dist/device/humidifier.js.map +1 -1
  42. package/dist/device/iosensor.d.ts +9 -4
  43. package/dist/device/iosensor.d.ts.map +1 -1
  44. package/dist/device/iosensor.js +92 -159
  45. package/dist/device/iosensor.js.map +1 -1
  46. package/dist/device/lightstrip.d.ts +10 -5
  47. package/dist/device/lightstrip.d.ts.map +1 -1
  48. package/dist/device/lightstrip.js +288 -370
  49. package/dist/device/lightstrip.js.map +1 -1
  50. package/dist/device/lock.d.ts +10 -5
  51. package/dist/device/lock.d.ts.map +1 -1
  52. package/dist/device/lock.js +172 -219
  53. package/dist/device/lock.js.map +1 -1
  54. package/dist/device/meter.d.ts +9 -4
  55. package/dist/device/meter.d.ts.map +1 -1
  56. package/dist/device/meter.js +94 -160
  57. package/dist/device/meter.js.map +1 -1
  58. package/dist/device/meterplus.d.ts +9 -4
  59. package/dist/device/meterplus.d.ts.map +1 -1
  60. package/dist/device/meterplus.js +95 -157
  61. package/dist/device/meterplus.js.map +1 -1
  62. package/dist/device/motion.d.ts +9 -4
  63. package/dist/device/motion.d.ts.map +1 -1
  64. package/dist/device/motion.js +85 -144
  65. package/dist/device/motion.js.map +1 -1
  66. package/dist/device/plug.d.ts +9 -4
  67. package/dist/device/plug.d.ts.map +1 -1
  68. package/dist/device/plug.js +100 -127
  69. package/dist/device/plug.js.map +1 -1
  70. package/dist/device/robotvacuumcleaner.d.ts +9 -6
  71. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  72. package/dist/device/robotvacuumcleaner.js +172 -259
  73. package/dist/device/robotvacuumcleaner.js.map +1 -1
  74. package/dist/device/waterdetector.d.ts +12 -4
  75. package/dist/device/waterdetector.d.ts.map +1 -1
  76. package/dist/device/waterdetector.js +106 -131
  77. package/dist/device/waterdetector.js.map +1 -1
  78. package/dist/irdevice/airconditioner.d.ts +2 -1
  79. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  80. package/dist/irdevice/airconditioner.js +2 -3
  81. package/dist/irdevice/airconditioner.js.map +1 -1
  82. package/dist/irdevice/airpurifier.d.ts +2 -1
  83. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  84. package/dist/irdevice/airpurifier.js +2 -3
  85. package/dist/irdevice/airpurifier.js.map +1 -1
  86. package/dist/irdevice/camera.d.ts +2 -1
  87. package/dist/irdevice/camera.d.ts.map +1 -1
  88. package/dist/irdevice/camera.js +2 -3
  89. package/dist/irdevice/camera.js.map +1 -1
  90. package/dist/irdevice/fan.d.ts +2 -1
  91. package/dist/irdevice/fan.d.ts.map +1 -1
  92. package/dist/irdevice/fan.js +2 -3
  93. package/dist/irdevice/fan.js.map +1 -1
  94. package/dist/irdevice/irdevice.d.ts +3 -1
  95. package/dist/irdevice/irdevice.d.ts.map +1 -1
  96. package/dist/irdevice/irdevice.js +5 -1
  97. package/dist/irdevice/irdevice.js.map +1 -1
  98. package/dist/irdevice/light.d.ts +2 -1
  99. package/dist/irdevice/light.d.ts.map +1 -1
  100. package/dist/irdevice/light.js +2 -3
  101. package/dist/irdevice/light.js.map +1 -1
  102. package/dist/irdevice/other.d.ts +2 -1
  103. package/dist/irdevice/other.d.ts.map +1 -1
  104. package/dist/irdevice/other.js +2 -3
  105. package/dist/irdevice/other.js.map +1 -1
  106. package/dist/irdevice/tv.d.ts +2 -1
  107. package/dist/irdevice/tv.d.ts.map +1 -1
  108. package/dist/irdevice/tv.js +2 -3
  109. package/dist/irdevice/tv.js.map +1 -1
  110. package/dist/irdevice/vacuumcleaner.d.ts +2 -1
  111. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  112. package/dist/irdevice/vacuumcleaner.js +2 -3
  113. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  114. package/dist/irdevice/waterheater.d.ts +2 -1
  115. package/dist/irdevice/waterheater.d.ts.map +1 -1
  116. package/dist/irdevice/waterheater.js +2 -3
  117. package/dist/irdevice/waterheater.js.map +1 -1
  118. package/dist/platform.d.ts +14 -14
  119. package/dist/platform.d.ts.map +1 -1
  120. package/dist/platform.js +102 -86
  121. package/dist/platform.js.map +1 -1
  122. package/dist/settings.d.ts +49 -190
  123. package/dist/settings.d.ts.map +1 -1
  124. package/dist/settings.js +19 -0
  125. package/dist/settings.js.map +1 -1
  126. package/dist/types/bledevicestatus.d.ts +279 -0
  127. package/dist/types/bledevicestatus.d.ts.map +1 -0
  128. package/dist/types/bledevicestatus.js +2 -0
  129. package/dist/types/bledevicestatus.js.map +1 -0
  130. package/dist/types/devicelist.d.ts +89 -0
  131. package/dist/types/devicelist.d.ts.map +1 -0
  132. package/dist/types/devicelist.js +6 -0
  133. package/dist/types/devicelist.js.map +1 -0
  134. package/dist/types/deviceresponse.d.ts +13 -0
  135. package/dist/types/deviceresponse.d.ts.map +1 -0
  136. package/dist/types/deviceresponse.js +2 -0
  137. package/dist/types/deviceresponse.js.map +1 -0
  138. package/dist/types/devicestatus.d.ts +149 -0
  139. package/dist/types/devicestatus.d.ts.map +1 -0
  140. package/dist/types/devicestatus.js +3 -0
  141. package/dist/types/devicestatus.js.map +1 -0
  142. package/dist/types/devicewebhookstatus.d.ts +156 -0
  143. package/dist/types/devicewebhookstatus.d.ts.map +1 -0
  144. package/dist/types/devicewebhookstatus.js +2 -0
  145. package/dist/types/devicewebhookstatus.js.map +1 -0
  146. package/dist/types/irdevicelist.d.ts +10 -0
  147. package/dist/types/irdevicelist.d.ts.map +1 -0
  148. package/dist/types/irdevicelist.js +2 -0
  149. package/dist/types/irdevicelist.js.map +1 -0
  150. package/dist/types/pushbody.d.ts +6 -0
  151. package/dist/types/pushbody.d.ts.map +1 -0
  152. package/dist/types/pushbody.js +2 -0
  153. package/dist/types/pushbody.js.map +1 -0
  154. package/dist/utils.d.ts +25 -0
  155. package/dist/utils.d.ts.map +1 -1
  156. package/dist/utils.js +28 -0
  157. package/dist/utils.js.map +1 -1
  158. package/package.json +11 -11
  159. package/src/device/blindtilt.ts +254 -376
  160. package/src/device/bot.ts +209 -224
  161. package/src/device/ceilinglight.ts +227 -297
  162. package/src/device/colorbulb.ts +345 -435
  163. package/src/device/contact.ts +139 -200
  164. package/src/device/curtain.ts +254 -414
  165. package/src/device/device.ts +221 -190
  166. package/src/device/fan.ts +222 -253
  167. package/src/device/hub.ts +127 -248
  168. package/src/device/humidifier.ts +217 -246
  169. package/src/device/iosensor.ts +115 -168
  170. package/src/device/lightstrip.ts +303 -380
  171. package/src/device/lock.ts +188 -224
  172. package/src/device/meter.ts +117 -179
  173. package/src/device/meterplus.ts +118 -176
  174. package/src/device/motion.ts +100 -146
  175. package/src/device/plug.ts +111 -131
  176. package/src/device/robotvacuumcleaner.ts +191 -258
  177. package/src/device/waterdetector.ts +124 -141
  178. package/src/irdevice/airconditioner.ts +4 -4
  179. package/src/irdevice/airpurifier.ts +4 -4
  180. package/src/irdevice/camera.ts +4 -4
  181. package/src/irdevice/fan.ts +4 -4
  182. package/src/irdevice/irdevice.ts +8 -2
  183. package/src/irdevice/light.ts +4 -4
  184. package/src/irdevice/other.ts +4 -4
  185. package/src/irdevice/tv.ts +4 -4
  186. package/src/irdevice/vacuumcleaner.ts +4 -4
  187. package/src/irdevice/waterheater.ts +4 -4
  188. package/src/platform.ts +104 -87
  189. package/src/settings.ts +30 -238
  190. package/src/types/bledevicestatus.ts +305 -0
  191. package/src/types/devicelist.ts +124 -0
  192. package/src/types/deviceresponse.ts +15 -0
  193. package/src/types/devicestatus.ts +178 -0
  194. package/src/types/devicewebhookstatus.ts +196 -0
  195. package/src/types/irdevicelist.ts +15 -0
  196. package/src/types/pushbody.ts +9 -0
  197. package/src/utils.ts +33 -0
package/src/settings.ts CHANGED
@@ -3,7 +3,10 @@
3
3
  * settings.ts: @switchbot/homebridge-switchbot platform class.
4
4
  */
5
5
  import type { IClientOptions } from 'async-mqtt';
6
- import type { MacAddress, PlatformConfig } from 'homebridge';
6
+ import type { PlatformConfig } from 'homebridge';
7
+ import type { device } from './types/devicelist';
8
+ import type { irdevice } from './types/irdevicelist';
9
+ import type { SwitchBotBLEModel, SwitchBotBLEModelName, SwitchBotBLEModelFriendlyName } from 'node-switchbot';
7
10
  /**
8
11
  * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
9
12
  */
@@ -39,20 +42,20 @@ export const updateWebhook = 'https://api.switch-bot.com/v1.1/webhook/updateWebh
39
42
  */
40
43
  export const deleteWebhook = 'https://api.switch-bot.com/v1.1/webhook/deleteWebhook';
41
44
 
45
+
42
46
  //Config
43
47
  export interface SwitchBotPlatformConfig extends PlatformConfig {
44
48
  credentials?: credentials;
45
- options?: options | Record<string, never>;
49
+ options?: options;
46
50
  }
47
-
48
- export type credentials = {
51
+ interface credentials {
49
52
  token?: any;
50
53
  secret?: any;
51
54
  notice?: any;
52
55
  openToken?: any;
53
- };
56
+ }
54
57
 
55
- export type options = {
58
+ interface options {
56
59
  refreshRate?: number;
57
60
  updateRate?: number;
58
61
  pushRate?: number;
@@ -70,8 +73,9 @@ export type options = {
70
73
  export interface devicesConfig extends device {
71
74
  bleMac?: string;
72
75
  model?: string;
73
- bleModel?: string;
74
- bleModelName?: string;
76
+ bleModel: SwitchBotBLEModel;
77
+ bleModelName: SwitchBotBLEModelName;
78
+ bleModelFriednlyName: SwitchBotBLEModelFriendlyName;
75
79
  configDeviceType: string;
76
80
  configDeviceName?: string;
77
81
  deviceId: string;
@@ -112,19 +116,19 @@ export interface devicesConfig extends device {
112
116
  hub?: hub;
113
117
  }
114
118
 
115
- export type meter = {
119
+ interface meter {
116
120
  hide_temperature?: boolean;
117
121
  convertUnitTo?: string;
118
122
  hide_humidity?: boolean;
119
123
  };
120
124
 
121
- export type iosensor = {
125
+ interface iosensor {
122
126
  hide_temperature?: boolean;
123
127
  convertUnitTo?: string;
124
128
  hide_humidity?: boolean;
125
129
  };
126
130
 
127
- export type bot = {
131
+ interface bot {
128
132
  mode?: string;
129
133
  deviceType?: string;
130
134
  doublePress?: number;
@@ -133,12 +137,12 @@ export type bot = {
133
137
  multiPress?: boolean;
134
138
  };
135
139
 
136
- export type humidifier = {
140
+ interface humidifier {
137
141
  hide_temperature?: boolean;
138
142
  set_minStep?: number;
139
143
  };
140
144
 
141
- export type curtain = {
145
+ interface curtain {
142
146
  disable_group?: boolean;
143
147
  hide_lightsensor?: boolean;
144
148
  set_minLux?: number;
@@ -150,7 +154,7 @@ export type curtain = {
150
154
  setOpenMode?: string;
151
155
  };
152
156
 
153
- export type blindTilt = {
157
+ interface blindTilt {
154
158
  mode?: string;
155
159
  hide_lightsensor?: boolean;
156
160
  set_minLux?: number;
@@ -162,44 +166,44 @@ export type blindTilt = {
162
166
  setOpenMode?: string;
163
167
  };
164
168
 
165
- export type contact = {
169
+ interface contact {
166
170
  hide_lightsensor?: boolean;
167
171
  set_minLux?: number;
168
172
  set_maxLux?: number;
169
173
  hide_motionsensor?: boolean;
170
174
  };
171
175
 
172
- export type motion = {
176
+ interface motion {
173
177
  hide_lightsensor?: boolean;
174
178
  set_minLux?: number;
175
179
  set_maxLux?: number;
176
180
  };
177
181
 
178
- export type waterdetector = {
182
+ interface waterdetector {
179
183
  hide_leak?: boolean;
180
184
  };
181
185
 
182
- export type colorbulb = {
186
+ interface colorbulb {
183
187
  set_minStep?: number;
184
188
  adaptiveLightingShift?: number;
185
189
  };
186
190
 
187
- export type striplight = {
191
+ interface striplight {
188
192
  set_minStep?: number;
189
193
  adaptiveLightingShift?: number;
190
194
  };
191
195
 
192
- export type ceilinglight = {
196
+ interface ceilinglight {
193
197
  set_minStep?: number;
194
198
  adaptiveLightingShift?: number;
195
199
  };
196
200
 
197
- export type lock = {
201
+ interface lock {
198
202
  hide_contactsensor?: boolean;
199
203
  activate_latchbutton?: boolean;
200
204
  };
201
205
 
202
- export type hub = {
206
+ interface hub {
203
207
  hide_temperature?: boolean;
204
208
  convertUnitTo?: string;
205
209
  hide_humidity?: boolean;
@@ -232,7 +236,7 @@ export interface irDevicesConfig extends irdevice {
232
236
  other?: other;
233
237
  }
234
238
 
235
- export type irfan = {
239
+ interface irfan {
236
240
  swing_mode?: boolean;
237
241
  rotation_speed?: boolean;
238
242
  set_minStep?: number;
@@ -240,11 +244,11 @@ export type irfan = {
240
244
  set_min?: number;
241
245
  };
242
246
 
243
- export type irlight = {
247
+ interface irlight {
244
248
  stateless?: boolean;
245
249
  };
246
250
 
247
- export type irair = {
251
+ interface irair {
248
252
  hide_automode?: boolean;
249
253
  set_max_heat?: number;
250
254
  set_min_heat?: number;
@@ -255,218 +259,6 @@ export type irair = {
255
259
  meterUuid?: string;
256
260
  };
257
261
 
258
- export type other = {
262
+ interface other {
259
263
  deviceType?: string;
260
264
  };
261
-
262
- export type body = {
263
- command: string;
264
- parameter: string;
265
- commandType: string;
266
- };
267
-
268
- //a list of physical devices.
269
- export type deviceList = {
270
- device: device[];
271
- };
272
-
273
- export type device = {
274
- //device ID.
275
- deviceId?: string;
276
- //device name.
277
- deviceName: string;
278
- //device type.
279
- deviceType: string;
280
- //determines if Cloud Service is enabled or not for the current device.
281
- enableCloudService: boolean;
282
- //device's parent Hub ID.
283
- hubDeviceId: string;
284
- //only available for Curtain devices. a list of Curtain device IDs such that the Curtain devices are being paired or grouped.
285
- curtainDevicesIds?: string[];
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.
287
- blindTiltDevicesIds?: string[];
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
289
- calibrate?: boolean;
290
- //only available for Curtain devices. determines if a Curtain is paired with or grouped with another Curtain or not.
291
- group?: boolean;
292
- //only available for Curtain devices. determines if a Curtain is the master device or not when paired with or grouped with another Curtain.
293
- master?: boolean;
294
- //only available for Curtain devices. the opening direction of a Curtain.
295
- openDirection?: string;
296
- //the opening direction of a Blind Tilt device
297
- direction?: string;
298
- //the current position, 0-100
299
- slidePosition?: string;
300
- //the version of the device
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;
318
- };
319
-
320
- //a list of virtual infrared remote devices.
321
- export type infraredRemoteList = {
322
- device: irdevice[];
323
- };
324
-
325
- export type irdevice = {
326
- deviceId?: string; //device ID
327
- deviceName: string; //device name
328
- remoteType: string; //device type
329
- hubDeviceId: string; //remote device's parent Hub ID
330
- model: string; //device model
331
- };
332
-
333
- export type deviceStatus = {
334
- statusCode: number;
335
- message: string;
336
- body: deviceStatusBody;
337
- };
338
-
339
- export type deviceStatusBody = {
340
- //v1.1 of API
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;
386
- };
387
-
388
- export type ad = {
389
- id: string;
390
- address: string;
391
- rssi: number;
392
- serviceData: serviceData;
393
- };
394
-
395
- export type serviceData = {
396
- //Model of BLE SwitchBot Device
397
- model: string;
398
- //Model Name of BLE SwitchBot Device
399
- modelName: string;
400
- //Mode for Bot either Press or Switch
401
- mode?: boolean;
402
- //Bot/ColorBulb State
403
- state?: string | boolean;
404
- //Lock door open
405
- door_open?: string;
406
- //Lock Status
407
- status?: string;
408
- //ColorBulb Power
409
- power?: boolean;
410
- //ColorBulb R
411
- red?: number;
412
- //ColorBulb G
413
- green?: number;
414
- //ColorBulb B
415
- blue?: number;
416
- //ColorBulb Color temperature
417
- color_temperature?: number;
418
- //Battery percentage left on Bot, Meter, Motion, Contact, PlugMini, and Curtain
419
- battery?: number;
420
- //Humidifier's humidity level percentage
421
- percentage?: boolean | string;
422
- //Humidifier's state
423
- onState?: boolean;
424
- //Humidifier's AutoMode
425
- autoMode?: boolean;
426
- //Meter Temperature Levels
427
- temperature?: temperature;
428
- // Fahrenheit enabled for Meter
429
- fahrenheit?: boolean;
430
- // Humidity level for Meter
431
- humidity?: number;
432
- //Motion Detected for Contact or Motion Sensors
433
- movement?: boolean;
434
- //Motion ((lightLevel == 1) ? 'dark' : ((lightLevel == 2) ? 'bright' : 'unknown'))
435
- //Contact ((lightLevel == 0) ? 'dark' : 'bright')
436
- //Curtain (light sensor level (1-10))
437
- //Light Level
438
- lightLevel?: number | string | boolean;
439
- //Contact DoorState
440
- doorState?: number | string;
441
- //Is Curtain Calibrated
442
- calibration?: boolean;
443
- //Current Curtain Positon %
444
- position?: number;
445
- //Is Curtain Moving?
446
- inMotion?: boolean;
447
- //PlugMini - Is there a delay?
448
- delay?: boolean;
449
- //PlugMini - Is there a Timer?
450
- timer?: boolean;
451
- //PlugMini - Is the UTC time has been synchronized?
452
- syncUtcTime?: boolean;
453
- //PlugMini - The Wifi RSSI Signal
454
- wifiRssi?: number;
455
- //PlugMini - Whether the Plug Mini is overloaded, more than 15A current overload
456
- overload?: boolean;
457
- //PlugMini - Plug Mini current power value of the load
458
- currentPower?: number;
459
- //Color Bulb's brightness level
460
- brightness?: boolean | string;
461
- };
462
-
463
- export type temperature = {
464
- c: number;
465
- f: number;
466
- };
467
-
468
- export type switchbot = {
469
- discover: (arg0: { duration?: any; model: string; quick: boolean; id?: MacAddress }) => Promise<any>;
470
- wait: (arg0: number) => any;
471
- };
472
-
@@ -0,0 +1,305 @@
1
+ /* Copyright(C) 2017-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * bledevicestatus.ts: @switchbot/homebridge-switchbot platform class.
4
+ */
5
+ import type { MacAddress } from 'homebridge';
6
+ import type { SwitchBotBLEModel, SwitchBotBLEModelName, SwitchBotBLEModelFriendlyName } from 'node-switchbot';
7
+
8
+ export type switchbot = {
9
+ discover: (arg0: { duration?: any; model: string; quick: boolean; id?: MacAddress }) => Promise<any>;
10
+ wait: (arg0: number) => any;
11
+ };
12
+
13
+ export type ad = {
14
+ id: string;
15
+ address: string;
16
+ rssi: number;
17
+ serviceData: botServiceData | colorBulbServiceData | contactSensorServiceData |
18
+ curtainServiceData | curtain3ServiceData | stripLightServiceData | lockServiceData |
19
+ lockProServiceData | meterServiceData | meterPlusServiceData | motionSensorServiceData |
20
+ plugMiniUSServiceData | plugMiniJPServiceData | blindTiltServiceData;
21
+ };
22
+
23
+ type serviceData = {
24
+ model: string,
25
+ modelName: string,
26
+ };
27
+
28
+ export type botServiceData = serviceData & {
29
+ model: SwitchBotBLEModel.Bot,
30
+ modelName: SwitchBotBLEModelName.Bot,
31
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Bot,
32
+ mode: string;
33
+ state: boolean;
34
+ battery: number;
35
+ };
36
+
37
+ export type colorBulbServiceData = serviceData & {
38
+ model: SwitchBotBLEModel.ColorBulb,
39
+ modelName: SwitchBotBLEModelName.ColorBulb,
40
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.ColorBulb,
41
+ color_temperature: number;
42
+ power: boolean;
43
+ state: boolean;
44
+ red: number;
45
+ green: number;
46
+ blue: number;
47
+ brightness: number;
48
+ delay: number;
49
+ preset: number;
50
+ color_mode: number;
51
+ speed: number;
52
+ loop_index: number;
53
+ };
54
+
55
+ export type contactSensorServiceData = serviceData & {
56
+ model: SwitchBotBLEModel.ContactSensor,
57
+ modelName: SwitchBotBLEModelName.ContactSensor,
58
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.ContactSensor,
59
+ movement: boolean;
60
+ tested: boolean;
61
+ battery: number;
62
+ contact_open: boolean;
63
+ contact_timeout: boolean;
64
+ lightLevel: string;
65
+ button_count: number;
66
+ doorState: string;
67
+ };
68
+
69
+ export type curtainServiceData = serviceData & {
70
+ model: SwitchBotBLEModel.Curtain,
71
+ modelName: SwitchBotBLEModelName.Curtain,
72
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Curtain,
73
+ calibration: boolean;
74
+ battery: number;
75
+ inMotion: boolean;
76
+ position: number;
77
+ lightLevel: number;
78
+ deviceChain: number;
79
+ };
80
+
81
+ export type curtain3ServiceData = serviceData & {
82
+ model: SwitchBotBLEModel.Curtain3,
83
+ modelName: SwitchBotBLEModelName.Curtain3,
84
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Curtain3,
85
+ calibration: boolean;
86
+ battery: number;
87
+ inMotion: boolean;
88
+ position: number;
89
+ lightLevel: number;
90
+ deviceChain: number;
91
+ };
92
+
93
+ export type stripLightServiceData = serviceData & {
94
+ model: SwitchBotBLEModel.StripLight,
95
+ modelName: SwitchBotBLEModelName.StripLight,
96
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.StripLight,
97
+ power: boolean;
98
+ state: boolean;
99
+ red: number;
100
+ green: number;
101
+ blue: number;
102
+ brightness: number;
103
+ delay: number;
104
+ preset: number;
105
+ color_mode: number;
106
+ speed: number;
107
+ loop_index: number;
108
+ };
109
+
110
+ export type lockServiceData = serviceData & {
111
+ model: SwitchBotBLEModel.Lock,
112
+ modelName: SwitchBotBLEModelName.Lock,
113
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Lock,
114
+ battery: number;
115
+ calibration: boolean;
116
+ status: string;
117
+ update_from_secondary_lock: boolean;
118
+ door_open: string;
119
+ double_lock_mode: boolean;
120
+ unclosed_alarm: boolean;
121
+ unlocked_alarm: boolean;
122
+ auto_lock_paused: boolean;
123
+ night_latch: boolean;
124
+ };
125
+
126
+ export type lockProServiceData = serviceData & {
127
+ model: SwitchBotBLEModel.LockPro,
128
+ modelName: SwitchBotBLEModelName.LockPro,
129
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.LockPro,
130
+ battery: number;
131
+ calibration: boolean;
132
+ status: string;
133
+ update_from_secondary_lock: boolean;
134
+ door_open: string;
135
+ double_lock_mode: boolean;
136
+ unclosed_alarm: boolean;
137
+ unlocked_alarm: boolean;
138
+ auto_lock_paused: boolean;
139
+ night_latch: boolean;
140
+ };
141
+
142
+ export type meterServiceData = serviceData & {
143
+ model: SwitchBotBLEModel.Meter,
144
+ modelName: SwitchBotBLEModelName.Meter,
145
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Meter,
146
+ temperature: temperature;
147
+ fahrenheit: boolean;
148
+ humidity: number;
149
+ battery: number;
150
+ };
151
+
152
+ export type meterPlusServiceData = serviceData & {
153
+ model: SwitchBotBLEModel.MeterPlus,
154
+ modelName: SwitchBotBLEModelName.MeterPlus,
155
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.MeterPlus,
156
+ temperature: temperature;
157
+ fahrenheit: boolean;
158
+ humidity: number;
159
+ battery: number;
160
+ };
161
+
162
+ export type outdoorMeterServiceData = serviceData & {
163
+ model: SwitchBotBLEModel.OutdoorMeter,
164
+ modelName: SwitchBotBLEModelName.OutdoorMeter,
165
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.OutdoorMeter,
166
+ temperature: temperature;
167
+ fahrenheit: boolean;
168
+ humidity: number;
169
+ battery: number;
170
+ };
171
+
172
+ export type motionSensorServiceData = serviceData & {
173
+ model: SwitchBotBLEModel.MotionSensor,
174
+ modelName: SwitchBotBLEModelName.MotionSensor,
175
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.MotionSensor,
176
+ tested: boolean;
177
+ movement: boolean;
178
+ battery: number;
179
+ led: number;
180
+ iot: number;
181
+ sense_distance: number;
182
+ lightLevel: string;
183
+ is_light: boolean;
184
+ };
185
+
186
+ export type plugMiniUSServiceData = serviceData & {
187
+ model: SwitchBotBLEModel.PlugMiniUS,
188
+ modelName: SwitchBotBLEModelName.PlugMini,
189
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.PlugMini,
190
+ state: string;
191
+ delay: boolean;
192
+ timer: boolean;
193
+ syncUtcTime: boolean;
194
+ wifiRssi: number;
195
+ overload: boolean;
196
+ currentPower: number;
197
+ };
198
+
199
+ export type plugMiniJPServiceData = serviceData & {
200
+ model: SwitchBotBLEModel.PlugMiniUS,
201
+ modelName: SwitchBotBLEModelName.PlugMini,
202
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.PlugMini,
203
+ state: string;
204
+ delay: boolean;
205
+ timer: boolean;
206
+ syncUtcTime: boolean;
207
+ wifiRssi: number;
208
+ overload: boolean;
209
+ currentPower: number;
210
+ };
211
+
212
+ export type blindTiltServiceData = serviceData & {
213
+ model: SwitchBotBLEModel.BlindTilt,
214
+ modelName: SwitchBotBLEModelName.BlindTilt,
215
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.BlindTilt,
216
+ calibration: boolean;
217
+ battery: number;
218
+ inMotion: boolean;
219
+ tilt: number;
220
+ lightLevel: number;
221
+ };
222
+
223
+ export type ceilingLightServiceData = serviceData & {
224
+ model: SwitchBotBLEModel.CeilingLight,
225
+ modelName: SwitchBotBLEModelName.CeilingLight,
226
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.CeilingLight,
227
+ color_temperature: number;
228
+ power: boolean;
229
+ state: boolean;
230
+ red: number;
231
+ green: number;
232
+ blue: number;
233
+ brightness: number;
234
+ delay: number;
235
+ preset: number;
236
+ color_mode: number;
237
+ speed: number;
238
+ loop_index: number;
239
+ };
240
+
241
+ export type ceilingLightProServiceData = serviceData & {
242
+ model: SwitchBotBLEModel.CeilingLightPro,
243
+ modelName: SwitchBotBLEModelName.CeilingLightPro,
244
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.CeilingLightPro,
245
+ color_temperature: number;
246
+ power: boolean;
247
+ state: boolean;
248
+ red: number;
249
+ green: number;
250
+ blue: number;
251
+ brightness: number;
252
+ delay: number;
253
+ preset: number;
254
+ color_mode: number;
255
+ speed: number;
256
+ loop_index: number;
257
+ };
258
+
259
+ export type hub2ServiceData = serviceData & {
260
+ model: SwitchBotBLEModel.Hub2,
261
+ modelName: SwitchBotBLEModelName.Hub2,
262
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Hub2,
263
+ temperature: temperature;
264
+ fahrenheit: boolean;
265
+ humidity: number;
266
+ lightLevel: number;
267
+ };
268
+
269
+ export type batteryCirculatorFanServiceData = serviceData & {
270
+ model: SwitchBotBLEModel.Unknown,
271
+ modelName: SwitchBotBLEModelName.Unknown,
272
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Unknown,
273
+ state: string;
274
+ };
275
+
276
+ export type waterLeakDetectorServiceData = serviceData & {
277
+ model: SwitchBotBLEModel.Unknown,
278
+ modelName: SwitchBotBLEModelName.Unknown,
279
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Unknown,
280
+ state: boolean;
281
+ status: number;
282
+ battery: number;
283
+ };
284
+
285
+ export type humidifierServiceData = serviceData & {
286
+ model: SwitchBotBLEModel.Humidifier,
287
+ modelName: SwitchBotBLEModelName.Humidifier,
288
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Humidifier,
289
+ onState: boolean;
290
+ autoMode: boolean;
291
+ percentage: number;
292
+ };
293
+
294
+ export type robotVacuumCleanerServiceData = serviceData & {
295
+ model: SwitchBotBLEModel.Unknown,
296
+ modelName: SwitchBotBLEModelName.Unknown,
297
+ modelFriendlyName: SwitchBotBLEModelFriendlyName.Unknown,
298
+ state: string;
299
+ battery: number;
300
+ };
301
+
302
+ export type temperature = {
303
+ c: number;
304
+ f: number;
305
+ };