@switchbot/homebridge-switchbot 3.5.0-beta.57 → 3.5.0-beta.59

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 (164) hide show
  1. package/.vscode/settings.json +4 -1
  2. package/dist/device/blindtilt.d.ts +5 -5
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +103 -69
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts +4 -4
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +201 -154
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts +3 -3
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +41 -36
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts +3 -3
  15. package/dist/device/colorbulb.d.ts.map +1 -1
  16. package/dist/device/colorbulb.js +36 -37
  17. package/dist/device/colorbulb.js.map +1 -1
  18. package/dist/device/contact.d.ts +4 -4
  19. package/dist/device/contact.d.ts.map +1 -1
  20. package/dist/device/contact.js +76 -55
  21. package/dist/device/contact.js.map +1 -1
  22. package/dist/device/curtain.d.ts +4 -4
  23. package/dist/device/curtain.d.ts.map +1 -1
  24. package/dist/device/curtain.js +99 -55
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/device.d.ts +4 -4
  27. package/dist/device/device.d.ts.map +1 -1
  28. package/dist/device/device.js +11 -9
  29. package/dist/device/device.js.map +1 -1
  30. package/dist/device/fan.d.ts +3 -3
  31. package/dist/device/fan.d.ts.map +1 -1
  32. package/dist/device/fan.js +54 -24
  33. package/dist/device/fan.js.map +1 -1
  34. package/dist/device/hub.d.ts +4 -4
  35. package/dist/device/hub.d.ts.map +1 -1
  36. package/dist/device/hub.js +40 -57
  37. package/dist/device/hub.js.map +1 -1
  38. package/dist/device/humidifier.d.ts +3 -3
  39. package/dist/device/humidifier.d.ts.map +1 -1
  40. package/dist/device/humidifier.js +39 -39
  41. package/dist/device/humidifier.js.map +1 -1
  42. package/dist/device/iosensor.d.ts +3 -3
  43. package/dist/device/iosensor.d.ts.map +1 -1
  44. package/dist/device/iosensor.js +41 -50
  45. package/dist/device/iosensor.js.map +1 -1
  46. package/dist/device/lightstrip.d.ts +4 -4
  47. package/dist/device/lightstrip.d.ts.map +1 -1
  48. package/dist/device/lightstrip.js +36 -33
  49. package/dist/device/lightstrip.js.map +1 -1
  50. package/dist/device/lock.d.ts +3 -3
  51. package/dist/device/lock.d.ts.map +1 -1
  52. package/dist/device/lock.js +68 -59
  53. package/dist/device/lock.js.map +1 -1
  54. package/dist/device/meter.d.ts +3 -3
  55. package/dist/device/meter.d.ts.map +1 -1
  56. package/dist/device/meter.js +42 -51
  57. package/dist/device/meter.js.map +1 -1
  58. package/dist/device/meterplus.d.ts +3 -3
  59. package/dist/device/meterplus.d.ts.map +1 -1
  60. package/dist/device/meterplus.js +42 -51
  61. package/dist/device/meterplus.js.map +1 -1
  62. package/dist/device/motion.d.ts +3 -3
  63. package/dist/device/motion.d.ts.map +1 -1
  64. package/dist/device/motion.js +52 -40
  65. package/dist/device/motion.js.map +1 -1
  66. package/dist/device/plug.d.ts +3 -3
  67. package/dist/device/plug.d.ts.map +1 -1
  68. package/dist/device/plug.js +13 -13
  69. package/dist/device/plug.js.map +1 -1
  70. package/dist/device/robotvacuumcleaner.d.ts +4 -4
  71. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  72. package/dist/device/robotvacuumcleaner.js +81 -98
  73. package/dist/device/robotvacuumcleaner.js.map +1 -1
  74. package/dist/device/waterdetector.d.ts +3 -3
  75. package/dist/device/waterdetector.d.ts.map +1 -1
  76. package/dist/device/waterdetector.js +39 -31
  77. package/dist/device/waterdetector.js.map +1 -1
  78. package/dist/homebridge-ui/public/index.html +20 -14
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +1 -1
  82. package/dist/index.js.map +1 -1
  83. package/dist/irdevice/airconditioner.d.ts +3 -3
  84. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  85. package/dist/irdevice/airconditioner.js +9 -9
  86. package/dist/irdevice/airconditioner.js.map +1 -1
  87. package/dist/irdevice/airpurifier.d.ts +3 -3
  88. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  89. package/dist/irdevice/airpurifier.js +1 -1
  90. package/dist/irdevice/airpurifier.js.map +1 -1
  91. package/dist/irdevice/camera.d.ts +3 -3
  92. package/dist/irdevice/camera.d.ts.map +1 -1
  93. package/dist/irdevice/camera.js +2 -2
  94. package/dist/irdevice/camera.js.map +1 -1
  95. package/dist/irdevice/fan.d.ts +6 -6
  96. package/dist/irdevice/fan.d.ts.map +1 -1
  97. package/dist/irdevice/fan.js +37 -29
  98. package/dist/irdevice/fan.js.map +1 -1
  99. package/dist/irdevice/irdevice.d.ts +3 -3
  100. package/dist/irdevice/irdevice.d.ts.map +1 -1
  101. package/dist/irdevice/irdevice.js.map +1 -1
  102. package/dist/irdevice/light.d.ts +9 -14
  103. package/dist/irdevice/light.d.ts.map +1 -1
  104. package/dist/irdevice/light.js +67 -88
  105. package/dist/irdevice/light.js.map +1 -1
  106. package/dist/irdevice/other.d.ts +3 -3
  107. package/dist/irdevice/other.d.ts.map +1 -1
  108. package/dist/irdevice/other.js +1 -1
  109. package/dist/irdevice/other.js.map +1 -1
  110. package/dist/irdevice/tv.d.ts +3 -3
  111. package/dist/irdevice/tv.d.ts.map +1 -1
  112. package/dist/irdevice/tv.js +3 -3
  113. package/dist/irdevice/tv.js.map +1 -1
  114. package/dist/irdevice/vacuumcleaner.d.ts +3 -3
  115. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  116. package/dist/irdevice/vacuumcleaner.js +2 -2
  117. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  118. package/dist/irdevice/waterheater.d.ts +3 -3
  119. package/dist/irdevice/waterheater.d.ts.map +1 -1
  120. package/dist/irdevice/waterheater.js +2 -2
  121. package/dist/irdevice/waterheater.js.map +1 -1
  122. package/dist/platform.d.ts +7 -7
  123. package/dist/platform.d.ts.map +1 -1
  124. package/dist/platform.js +20 -23
  125. package/dist/platform.js.map +1 -1
  126. package/dist/settings.d.ts +24 -10
  127. package/dist/settings.d.ts.map +1 -1
  128. package/dist/settings.js +16 -0
  129. package/dist/settings.js.map +1 -1
  130. package/eslint.config.js +89 -78
  131. package/package.json +3 -3
  132. package/src/device/blindtilt.ts +120 -87
  133. package/src/device/bot.ts +238 -175
  134. package/src/device/ceilinglight.ts +49 -46
  135. package/src/device/colorbulb.ts +40 -43
  136. package/src/device/contact.ts +91 -65
  137. package/src/device/curtain.ts +113 -66
  138. package/src/device/device.ts +12 -13
  139. package/src/device/fan.ts +66 -29
  140. package/src/device/hub.ts +53 -60
  141. package/src/device/humidifier.ts +54 -56
  142. package/src/device/iosensor.ts +57 -56
  143. package/src/device/lightstrip.ts +43 -39
  144. package/src/device/lock.ts +79 -68
  145. package/src/device/meter.ts +54 -54
  146. package/src/device/meterplus.ts +54 -54
  147. package/src/device/motion.ts +62 -46
  148. package/src/device/plug.ts +19 -18
  149. package/src/device/robotvacuumcleaner.ts +89 -104
  150. package/src/device/waterdetector.ts +46 -34
  151. package/src/homebridge-ui/public/index.html +20 -14
  152. package/src/index.ts +3 -2
  153. package/src/irdevice/airconditioner.ts +13 -11
  154. package/src/irdevice/airpurifier.ts +5 -3
  155. package/src/irdevice/camera.ts +6 -4
  156. package/src/irdevice/fan.ts +42 -29
  157. package/src/irdevice/irdevice.ts +4 -5
  158. package/src/irdevice/light.ts +83 -103
  159. package/src/irdevice/other.ts +5 -3
  160. package/src/irdevice/tv.ts +7 -5
  161. package/src/irdevice/vacuumcleaner.ts +6 -4
  162. package/src/irdevice/waterheater.ts +6 -4
  163. package/src/platform.ts +59 -66
  164. package/src/settings.ts +73 -58
package/src/platform.ts CHANGED
@@ -2,24 +2,23 @@
2
2
  *
3
3
  * platform.ts: @switchbot/homebridge-switchbot platform class.
4
4
  */
5
- import { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
6
- import { PLATFORM_NAME, PLUGIN_NAME, irdevice, device, SwitchBotPlatformConfig, devicesConfig, irDevicesConfig, Devices } from './settings.js';
5
+ import { Hub } from './device/hub.js';
7
6
  import { Bot } from './device/bot.js';
8
7
  import { Plug } from './device/plug.js';
9
8
  import { Lock } from './device/lock.js';
10
9
  import { Meter } from './device/meter.js';
11
10
  import { Motion } from './device/motion.js';
12
- import { Hub } from './device/hub.js';
13
11
  import { Contact } from './device/contact.js';
14
12
  import { Curtain } from './device/curtain.js';
15
13
  import { IOSensor } from './device/iosensor.js';
16
- import { WaterDetector } from './device/waterdetector.js';
17
14
  import { MeterPlus } from './device/meterplus.js';
18
15
  import { ColorBulb } from './device/colorbulb.js';
19
- import { CeilingLight } from './device/ceilinglight.js';
20
16
  import { StripLight } from './device/lightstrip.js';
21
17
  import { Humidifier } from './device/humidifier.js';
18
+ import { CeilingLight } from './device/ceilinglight.js';
19
+ import { WaterDetector } from './device/waterdetector.js';
22
20
  import { RobotVacuumCleaner } from './device/robotvacuumcleaner.js';
21
+
23
22
  import { Fan } from './device/fan.js';
24
23
  import { TV } from './irdevice/tv.js';
25
24
  import { IRFan } from './irdevice/fan.js';
@@ -31,18 +30,25 @@ import { AirPurifier } from './irdevice/airpurifier.js';
31
30
  import { WaterHeater } from './irdevice/waterheater.js';
32
31
  import { VacuumCleaner } from './irdevice/vacuumcleaner.js';
33
32
  import { AirConditioner } from './irdevice/airconditioner.js';
34
- import * as http from 'http';
33
+
35
34
  import { Buffer } from 'buffer';
36
- import { Dispatcher, request } from 'undici';
37
- import { MqttClient } from 'mqtt';
35
+ import { request } from 'undici';
36
+ import asyncmqtt from 'async-mqtt';
37
+ import { sleep } from './utils.js';
38
+ import { createServer } from 'http';
38
39
  import { queueScheduler } from 'rxjs';
39
40
  import fakegato from 'fakegato-history';
40
- import asyncmqtt from 'async-mqtt';
41
41
  import crypto, { randomUUID } from 'crypto';
42
42
  import { readFileSync, writeFileSync } from 'fs';
43
43
  import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
44
- import { UrlObject } from 'url';
45
- import { sleep } from './utils.js';
44
+ import { PLATFORM_NAME, PLUGIN_NAME, Devices, setupWebhook, updateWebhook, deleteWebhook, queryWebhook } from './settings.js';
45
+
46
+ import type { UrlObject } from 'url';
47
+ import type { MqttClient } from 'mqtt';
48
+ import type { Dispatcher } from 'undici';
49
+ import type { Server, IncomingMessage, ServerResponse } from 'http';
50
+ import type { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
51
+ import type { irdevice, device, SwitchBotPlatformConfig, devicesConfig, irDevicesConfig } from './settings.js';
46
52
 
47
53
  /**
48
54
  * HomebridgePlatform
@@ -63,7 +69,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
63
69
  platformLogging!: SwitchBotPlatformConfig['logging'];
64
70
  config!: SwitchBotPlatformConfig;
65
71
 
66
- webhookEventListener: http.Server | null = null;
72
+ webhookEventListener: Server | null = null;
67
73
  mqttClient: MqttClient | null = null;
68
74
 
69
75
  public readonly fakegatoAPI: any;
@@ -121,7 +127,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
121
127
  if (this.config.credentials?.openToken && !this.config.credentials.token) {
122
128
  await this.updateToken();
123
129
  } else if (this.config.credentials?.token && !this.config.credentials?.secret) {
124
- // eslint-disable-next-line no-useless-escape
130
+
125
131
  this.errorLog('"secret" config is not populated, you must populate then please restart Homebridge.');
126
132
  } else {
127
133
  this.discoverDevices();
@@ -175,7 +181,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
175
181
  const xurl = new URL(url);
176
182
  const port = Number(xurl.port);
177
183
  const path = xurl.pathname;
178
- this.webhookEventListener = http.createServer((request: http.IncomingMessage, response: http.ServerResponse) => {
184
+ this.webhookEventListener = createServer((request: IncomingMessage, response: ServerResponse) => {
179
185
  try {
180
186
  if (request.url === path && request.method === 'POST') {
181
187
  request.on('data', async (data) => {
@@ -212,16 +218,15 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
212
218
  }
213
219
 
214
220
  try {
215
- const { body, statusCode } = await request(
216
- 'https://api.switch-bot.com/v1.1/webhook/setupWebhook', {
217
- method: 'POST',
218
- headers: this.generateHeaders(),
219
- body: JSON.stringify({
220
- 'action': 'setupWebhook',
221
- 'url': url,
222
- 'deviceList': 'ALL',
223
- }),
224
- });
221
+ const { body, statusCode } = await request(setupWebhook, {
222
+ method: 'POST',
223
+ headers: this.generateHeaders(),
224
+ body: JSON.stringify({
225
+ 'action': 'setupWebhook',
226
+ 'url': url,
227
+ 'deviceList': 'ALL',
228
+ }),
229
+ });
225
230
  const response: any = await body.json();
226
231
  this.debugLog(`setupWebhook: url:${url}`);
227
232
  this.debugLog(`setupWebhook: body:${JSON.stringify(response)}`);
@@ -235,18 +240,15 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
235
240
  }
236
241
 
237
242
  try {
238
- const { body, statusCode } = await request(
239
- 'https://api.switch-bot.com/v1.1/webhook/updateWebhook', {
240
- method: 'POST',
241
- headers: this.generateHeaders(),
242
- body: JSON.stringify({
243
- 'action': 'updateWebhook',
244
- 'config': {
245
- 'url': url,
246
- 'enable': true,
247
- },
248
- }),
249
- });
243
+ const { body, statusCode } = await request(updateWebhook, {
244
+ method: 'POST', headers: this.generateHeaders(), body: JSON.stringify({
245
+ 'action': 'updateWebhook',
246
+ 'config': {
247
+ 'url': url,
248
+ 'enable': true,
249
+ },
250
+ }),
251
+ });
250
252
  const response: any = await body.json();
251
253
  this.debugLog(`updateWebhook: url:${url}`);
252
254
  this.debugLog(`updateWebhook: body:${JSON.stringify(response)}`);
@@ -259,14 +261,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
259
261
  }
260
262
 
261
263
  try {
262
- const { body, statusCode } = await request(
263
- 'https://api.switch-bot.com/v1.1/webhook/queryWebhook', {
264
- method: 'POST',
265
- headers: this.generateHeaders(),
266
- body: JSON.stringify({
267
- 'action': 'queryUrl',
268
- }),
269
- });
264
+ const { body, statusCode } = await request(queryWebhook, {
265
+ method: 'POST',
266
+ headers: this.generateHeaders(),
267
+ body: JSON.stringify({
268
+ 'action': 'queryUrl',
269
+ }),
270
+ });
270
271
  const response: any = await body.json();
271
272
  this.debugLog(`queryWebhook: body:${JSON.stringify(response)}`);
272
273
  this.debugLog(`queryWebhook: statusCode:${statusCode}`);
@@ -281,15 +282,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
281
282
 
282
283
  this.api.on('shutdown', async () => {
283
284
  try {
284
- const { body, statusCode } = await request(
285
- 'https://api.switch-bot.com/v1.1/webhook/deleteWebhook', {
286
- method: 'POST',
287
- headers: this.generateHeaders(),
288
- body: JSON.stringify({
289
- 'action': 'deleteWebhook',
290
- 'url': url,
291
- }),
292
- });
285
+ const { body, statusCode } = await request(deleteWebhook, {
286
+ method: 'POST',
287
+ headers: this.generateHeaders(),
288
+ body: JSON.stringify({
289
+ 'action': 'deleteWebhook',
290
+ 'url': url,
291
+ }),
292
+ });
293
293
  const response: any = await body.json();
294
294
  this.debugLog(`deleteWebhook: url:${url}`);
295
295
  this.debugLog(`deleteWebhook: body:${JSON.stringify(response)}`);
@@ -449,18 +449,12 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
449
449
  }
450
450
  // Move openToken to token
451
451
  if (!this.config.credentials.secret) {
452
- // eslint-disable-next-line no-useless-escape, max-len
453
- this.warnLog(
454
- 'This plugin has been updated to use OpenAPI v1.1, config is set with openToken, "openToken" cconfig has been moved to the "token" config',
455
- );
456
- // eslint-disable-next-line no-useless-escape
452
+ this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken,'
453
+ + ' "openToken" cconfig has been moved to the "token" config');
457
454
  this.errorLog('"secret" config is not populated, you must populate then please restart Homebridge.');
458
455
  } else {
459
- // eslint-disable-next-line no-useless-escape, max-len
460
- this.warnLog(
461
- 'This plugin has been updated to use OpenAPI v1.1, config is set with openToken, '
462
- + '"openToken" config has been moved to the "token" config, please restart Homebridge.',
463
- );
456
+ this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken, '
457
+ + '"openToken" config has been moved to the "token" config, please restart Homebridge.');
464
458
  }
465
459
 
466
460
  // set the refresh token
@@ -754,9 +748,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
754
748
  this.createFan(device);
755
749
  break;
756
750
  default:
757
- this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
758
- // eslint-disable-next-line max-len
759
- this.warnLog('Submit Feature Requests Here: ' + 'https://tinyurl.com/SwitchBotFeatureRequest');
751
+ this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`,
752
+ + 'Submit Feature Requests Here: https://tinyurl.com/SwitchBotFeatureRequest');
760
753
  }
761
754
  }
762
755
 
package/src/settings.ts CHANGED
@@ -2,9 +2,8 @@
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;
@@ -39,8 +58,8 @@ export type options = {
39
58
  maxRetries?: number;
40
59
  delayBetweenRetries?: number;
41
60
  logging?: string;
42
- devices?: Array<devicesConfig>;
43
- irdevices?: Array<irDevicesConfig>;
61
+ devices?: devicesConfig[];
62
+ irdevices?: irDevicesConfig[];
44
63
  webhookURL?: string;
45
64
  mqttURL?: string;
46
65
  mqttOptions?: IClientOptions;
@@ -245,7 +264,7 @@ export type body = {
245
264
 
246
265
  //a list of physical devices.
247
266
  export type deviceList = {
248
- device: Array<device>;
267
+ device: device[];
249
268
  };
250
269
 
251
270
  export type device = {
@@ -260,9 +279,9 @@ export type device = {
260
279
  //device's parent Hub ID.
261
280
  hubDeviceId: string;
262
281
  //only available for Curtain devices. a list of Curtain device IDs such that the Curtain devices are being paired or grouped.
263
- curtainDevicesIds?: Array<string>;
282
+ curtainDevicesIds?: string[];
264
283
  //only available for Blind Titl devices. a list of Blind Tilt device IDs such that the Blind Tilt devices are being paired or grouped.
265
- blindTiltDevicesIds?: Array<string>;
284
+ blindTiltDevicesIds?: string[];
266
285
  //only available for Curtain/Lock devices. determines if the open position and the close position of a device have been properly calibrated or not
267
286
  calibrate?: boolean;
268
287
  //only available for Curtain devices. determines if a Curtain is paired with or grouped with another Curtain or not.
@@ -295,13 +314,9 @@ export type device = {
295
314
  fanSpeed: number;
296
315
  };
297
316
 
298
- // values defined but not displayed by API
299
- export interface deviceInfo extends device {
300
- }
301
-
302
317
  //a list of virtual infrared remote devices.
303
318
  export type infraredRemoteList = {
304
- device: Array<irdevice>;
319
+ device: irdevice[];
305
320
  };
306
321
 
307
322
  export type irdevice = {
@@ -320,51 +335,51 @@ export type deviceStatus = {
320
335
 
321
336
  export type deviceStatusBody = {
322
337
  //v1.1 of API
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)
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)
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)
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)
327
- calibrate?: boolean; //determines if device has been calibrated or not. (Used by the following deviceTypes: Curtain, Lock, Blind Tilt)
328
- group?: boolean; //determines if a device is paired with or grouped with another device or not. (Used by the following deviceTypes: Curtain, Blind Tilt)
329
- moving?: boolean; //determines if a device is moving or not. (Used by the following deviceTypes: Curtain, Blind Tilt)
330
- 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)
331
- temperature?: number; //temperature in celsius (Used by the following deviceTypes: Meter, Meter Plus, Humidifier, IOSensor)
332
- humidity?: number; //humidity percentage. (Used by the following deviceTypes: Meter, Meter Plus, Humidifier, IOSensor)
333
- lockState?: string; //determines if locked or not. (Used by the following deviceTypes: Lock)
334
- doorState?: string; //determines if the door is closed or not. (Used by the following deviceTypes: Lock)
335
- moveDetected?: boolean; //determines if motion is detected. (Used by the following deviceTypes: Motion Sensor, Contact Sensor)
336
- 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)
337
- openState?: string; //the open state of the sensor. open, close, or timeOutNotClose. (Used by the following deviceTypes: Contact Sensor)
338
- colorTemperature?: number; //the color temperature value, range from 2700 to 6500. (Used by the following deviceTypes: Ceiling Light, Ceiling Light Pro, Color Bulb)
339
- voltage?: number; //the voltage of the device, measured in Volt. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
340
- weight?: number; //the power consumed in a day, measured in Watts. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
341
- 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))
342
- electricCurrent?: number; //the current of the device at the moment, measured in Amp. (Used by the following deviceTypes: Plug Mini (US), Plug Mini (JP))
343
- color?: string; //the color value, RGB "255:255:255". (Used by the following deviceTypes: Strip Light, Color Bulb)
344
- 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)
345
- 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)
346
- battery?: number; //the current battery level. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Blind Tilt, IOSensor)
347
- deviceName?: string; //device name. (Used by the following deviceTypes: Robot Vacuum Cleaner S1 Plus)
348
- nebulizationEfficiency?: number; //atomization efficiency percentage. (Used by the following deviceTypes: Humidifier)
349
- auto?: boolean; //determines if a Humidifier is in Auto Mode or not. (Used by the following deviceTypes: Humidifier)
350
- childLock?: boolean; //determines if a Humidifier's safety lock is on or not. (Used by the following deviceTypes: Humidifier)
351
- sound?: boolean; //determines if a Humidifier is muted or not. (Used by the following deviceTypes: Humidifier)
352
- lackWater?: boolean; //determines if the water tank is empty or not. (Used by the following deviceTypes: Humidifier)
353
- version?: number; //the version of the device.
354
- direction?: string; //the opening direction of a Blind Tilt device. (Used by the following deviceTypes: Blind Tilt)
355
- runStatus?: string; //'static' when not moving. (Used by the following deviceTypes: Blind Tilt)
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")
357
- speed?: number; //the fan speed. (Used by the following deviceTypes: Smart Fan)
358
- shaking?: boolean; //determines if the fan is swinging or not. (Used by the following deviceTypes: Smart Fan)
359
- shakeCenter?: string; //the fan's swing direction. (Used by the following deviceTypes: Smart Fan)
360
- shakeRange?: string; //the fan's swing range, 0~120°. (Used by the following deviceTypes: Smart Fan)
361
- status?: number //the leak status. 0 for no leak, 1 for leak. (Used by the following deviceTypes: Water Detector)
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
338
+ deviceId: string;
339
+ deviceType: string;
340
+ hubDeviceId: string;
341
+ power?: string;
342
+ calibrate?: boolean;
343
+ group?: boolean;
344
+ moving?: boolean;
345
+ slidePosition?: number;
346
+ temperature?: number;
347
+ humidity?: number;
348
+ lockState?: string;
349
+ doorState?: string;
350
+ moveDetected?: boolean;
351
+ brightness?: string | number;
352
+ openState?: string;
353
+ colorTemperature?: number;
354
+ voltage?: number;
355
+ weight?: number;
356
+ electricityOfDay?: number;
357
+ electricCurrent?: number;
358
+ color?: string;
359
+ workingStatus?: string;
360
+ onlineStatus?: string;
361
+ battery?: number;
362
+ deviceName?: string;
363
+ nebulizationEfficiency?: number;
364
+ auto?: boolean;
365
+ childLock?: boolean;
366
+ sound?: boolean;
367
+ lackWater?: boolean;
368
+ version?: number;
369
+ direction?: string;
370
+ runStatus?: string;
371
+ mode?: number | string;
372
+ speed?: number;
373
+ shaking?: boolean;
374
+ shakeCenter?: string;
375
+ shakeRange?: string;
376
+ status?: number;
377
+ lightLevel?: number;
378
+ nightStatus: number;
379
+ oscillation: string;
380
+ verticalOscillation: string;
381
+ chargingStatus: string;
382
+ fanSpeed: number;
368
383
  };
369
384
 
370
385
  export type ad = {