@switchbot/homebridge-switchbot 3.5.1-beta.12 → 3.5.1-beta.14

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 (150) hide show
  1. package/config.schema.json +19 -3
  2. package/dist/device/blindtilt.d.ts +6 -4
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +56 -44
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts +6 -3
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +37 -23
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts +6 -3
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +39 -20
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts +6 -3
  15. package/dist/device/colorbulb.d.ts.map +1 -1
  16. package/dist/device/colorbulb.js +41 -30
  17. package/dist/device/colorbulb.js.map +1 -1
  18. package/dist/device/contact.d.ts +6 -3
  19. package/dist/device/contact.d.ts.map +1 -1
  20. package/dist/device/contact.js +39 -27
  21. package/dist/device/contact.js.map +1 -1
  22. package/dist/device/curtain.d.ts +6 -4
  23. package/dist/device/curtain.d.ts.map +1 -1
  24. package/dist/device/curtain.js +34 -21
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/device.d.ts +6 -3
  27. package/dist/device/device.d.ts.map +1 -1
  28. package/dist/device/device.js +54 -125
  29. package/dist/device/device.js.map +1 -1
  30. package/dist/device/fan.d.ts +6 -3
  31. package/dist/device/fan.d.ts.map +1 -1
  32. package/dist/device/fan.js +47 -28
  33. package/dist/device/fan.js.map +1 -1
  34. package/dist/device/hub.d.ts +6 -3
  35. package/dist/device/hub.d.ts.map +1 -1
  36. package/dist/device/hub.js +42 -25
  37. package/dist/device/hub.js.map +1 -1
  38. package/dist/device/humidifier.d.ts +6 -3
  39. package/dist/device/humidifier.d.ts.map +1 -1
  40. package/dist/device/humidifier.js +42 -25
  41. package/dist/device/humidifier.js.map +1 -1
  42. package/dist/device/iosensor.d.ts +6 -3
  43. package/dist/device/iosensor.d.ts.map +1 -1
  44. package/dist/device/iosensor.js +38 -23
  45. package/dist/device/iosensor.js.map +1 -1
  46. package/dist/device/lightstrip.d.ts +6 -3
  47. package/dist/device/lightstrip.d.ts.map +1 -1
  48. package/dist/device/lightstrip.js +42 -26
  49. package/dist/device/lightstrip.js.map +1 -1
  50. package/dist/device/lock.d.ts +6 -3
  51. package/dist/device/lock.d.ts.map +1 -1
  52. package/dist/device/lock.js +32 -21
  53. package/dist/device/lock.js.map +1 -1
  54. package/dist/device/meter.d.ts +6 -3
  55. package/dist/device/meter.d.ts.map +1 -1
  56. package/dist/device/meter.js +37 -23
  57. package/dist/device/meter.js.map +1 -1
  58. package/dist/device/meterplus.d.ts +6 -3
  59. package/dist/device/meterplus.d.ts.map +1 -1
  60. package/dist/device/meterplus.js +36 -23
  61. package/dist/device/meterplus.js.map +1 -1
  62. package/dist/device/motion.d.ts +6 -3
  63. package/dist/device/motion.d.ts.map +1 -1
  64. package/dist/device/motion.js +32 -21
  65. package/dist/device/motion.js.map +1 -1
  66. package/dist/device/plug.d.ts +6 -3
  67. package/dist/device/plug.d.ts.map +1 -1
  68. package/dist/device/plug.js +26 -15
  69. package/dist/device/plug.js.map +1 -1
  70. package/dist/device/robotvacuumcleaner.d.ts +6 -3
  71. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  72. package/dist/device/robotvacuumcleaner.js +33 -20
  73. package/dist/device/robotvacuumcleaner.js.map +1 -1
  74. package/dist/device/waterdetector.d.ts +6 -3
  75. package/dist/device/waterdetector.d.ts.map +1 -1
  76. package/dist/device/waterdetector.js +37 -22
  77. package/dist/device/waterdetector.js.map +1 -1
  78. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  79. package/dist/irdevice/airconditioner.js +19 -72
  80. package/dist/irdevice/airconditioner.js.map +1 -1
  81. package/dist/irdevice/airpurifier.js +4 -4
  82. package/dist/irdevice/airpurifier.js.map +1 -1
  83. package/dist/irdevice/camera.d.ts.map +1 -1
  84. package/dist/irdevice/camera.js +3 -10
  85. package/dist/irdevice/camera.js.map +1 -1
  86. package/dist/irdevice/fan.d.ts.map +1 -1
  87. package/dist/irdevice/fan.js +7 -25
  88. package/dist/irdevice/fan.js.map +1 -1
  89. package/dist/irdevice/irdevice.d.ts +1 -1
  90. package/dist/irdevice/irdevice.js +2 -2
  91. package/dist/irdevice/irdevice.js.map +1 -1
  92. package/dist/irdevice/light.d.ts.map +1 -1
  93. package/dist/irdevice/light.js +9 -27
  94. package/dist/irdevice/light.js.map +1 -1
  95. package/dist/irdevice/other.js +1 -1
  96. package/dist/irdevice/other.js.map +1 -1
  97. package/dist/irdevice/tv.d.ts.map +1 -1
  98. package/dist/irdevice/tv.js +3 -18
  99. package/dist/irdevice/tv.js.map +1 -1
  100. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  101. package/dist/irdevice/vacuumcleaner.js +2 -9
  102. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  103. package/dist/irdevice/waterheater.d.ts.map +1 -1
  104. package/dist/irdevice/waterheater.js +2 -9
  105. package/dist/irdevice/waterheater.js.map +1 -1
  106. package/dist/platform.d.ts +3 -5
  107. package/dist/platform.d.ts.map +1 -1
  108. package/dist/platform.js +13 -13
  109. package/dist/platform.js.map +1 -1
  110. package/dist/settings.d.ts +9 -8
  111. package/dist/settings.d.ts.map +1 -1
  112. package/dist/settings.js.map +1 -1
  113. package/dist/types/bledevicestatus.d.ts +2 -1
  114. package/dist/types/bledevicestatus.d.ts.map +1 -1
  115. package/dist/types/devicestatus.d.ts +1 -1
  116. package/dist/types/devicestatus.d.ts.map +1 -1
  117. package/package.json +9 -9
  118. package/src/device/blindtilt.ts +59 -46
  119. package/src/device/bot.ts +46 -24
  120. package/src/device/ceilinglight.ts +51 -20
  121. package/src/device/colorbulb.ts +44 -30
  122. package/src/device/contact.ts +42 -27
  123. package/src/device/curtain.ts +44 -22
  124. package/src/device/device.ts +56 -112
  125. package/src/device/fan.ts +60 -29
  126. package/src/device/hub.ts +54 -28
  127. package/src/device/humidifier.ts +54 -30
  128. package/src/device/iosensor.ts +44 -26
  129. package/src/device/lightstrip.ts +47 -27
  130. package/src/device/lock.ts +48 -22
  131. package/src/device/meter.ts +53 -25
  132. package/src/device/meterplus.ts +49 -25
  133. package/src/device/motion.ts +44 -23
  134. package/src/device/plug.ts +33 -16
  135. package/src/device/robotvacuumcleaner.ts +48 -22
  136. package/src/device/waterdetector.ts +55 -24
  137. package/src/irdevice/airconditioner.ts +19 -65
  138. package/src/irdevice/airpurifier.ts +4 -4
  139. package/src/irdevice/camera.ts +4 -9
  140. package/src/irdevice/fan.ts +10 -22
  141. package/src/irdevice/irdevice.ts +2 -2
  142. package/src/irdevice/light.ts +10 -24
  143. package/src/irdevice/other.ts +1 -1
  144. package/src/irdevice/tv.ts +5 -16
  145. package/src/irdevice/vacuumcleaner.ts +3 -8
  146. package/src/irdevice/waterheater.ts +3 -8
  147. package/src/platform.ts +14 -14
  148. package/src/settings.ts +10 -8
  149. package/src/types/bledevicestatus.ts +4 -2
  150. package/src/types/devicestatus.ts +1 -1
package/src/platform.ts CHANGED
@@ -40,17 +40,17 @@ import fakegato from 'fakegato-history';
40
40
  import crypto, { randomUUID } from 'crypto';
41
41
  import { readFileSync, writeFileSync } from 'fs';
42
42
  import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
43
+ import { PLATFORM_NAME, PLUGIN_NAME, Devices, deleteWebhook, queryWebhook, setupWebhook, updateWebhook } from './settings.js';
43
44
  import { isBlindTiltDevice, isCurtainDevice, sleep } from './utils.js';
44
- import { PLATFORM_NAME, PLUGIN_NAME, Devices, setupWebhook, updateWebhook, deleteWebhook, queryWebhook } from './settings.js';
45
45
 
46
46
  import type { UrlObject } from 'url';
47
47
  import type { MqttClient } from 'mqtt';
48
48
  import type { Dispatcher } from 'undici';
49
49
  import type { irdevice } from './types/irdevicelist.js';
50
- import type { Server, IncomingMessage, ServerResponse } from 'http';
51
50
  import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js';
52
51
  import type { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
53
52
  import type { SwitchBotPlatformConfig, devicesConfig, irDevicesConfig } from './settings.js';
53
+ import type { IncomingMessage, Server, ServerResponse } from 'http';
54
54
 
55
55
  /**
56
56
  * HomebridgePlatform
@@ -71,11 +71,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
71
71
  platformLogging!: SwitchBotPlatformConfig['logging'];
72
72
  config!: SwitchBotPlatformConfig;
73
73
 
74
- webhookEventListener: Server | null = null;
75
74
  mqttClient: MqttClient | null = null;
75
+ webhookEventListener: Server | null = null;
76
76
 
77
- public readonly fakegatoAPI: any;
78
77
  public readonly eve: any;
78
+ public readonly fakegatoAPI: any;
79
79
  public readonly webhookEventHandler: { [x: string]: (context: any) => void } = {};
80
80
 
81
81
  constructor(
@@ -2678,10 +2678,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2678
2678
  await this.errorLog(`Requests reached the daily limit, statusCode: ${statusCode}`);
2679
2679
  break;
2680
2680
  case 100:
2681
- await await this.debugLog(`Command successfully sent, statusCode: ${statusCode}`);
2681
+ await this.debugLog(`Command successfully sent, statusCode: ${statusCode}`);
2682
2682
  break;
2683
2683
  case 200:
2684
- await await this.debugLog(`Request successful, statusCode: ${statusCode}`);
2684
+ await this.debugLog(`Request successful, statusCode: ${statusCode}`);
2685
2685
  break;
2686
2686
  case 400:
2687
2687
  await this.errorLog('Bad Request, The client has issued an invalid request. This is commonly used to specify validation errors in a request '
@@ -2735,13 +2735,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2735
2735
  if (statusCode === 200 || statusCode === 100) {
2736
2736
  return { body, statusCode };
2737
2737
  } else {
2738
- await await this.debugLog(`Received status code: ${statusCode}`);
2738
+ await this.debugLog(`Received status code: ${statusCode}`);
2739
2739
  }
2740
2740
  } catch (error: any) {
2741
2741
  await this.errorLog(`Error making request: ${error.message}`);
2742
2742
  }
2743
2743
  retryCount++;
2744
- await await this.debugLog(`Retry attempt ${retryCount} of ${maxRetries}`);
2744
+ await this.debugLog(`Retry attempt ${retryCount} of ${maxRetries}`);
2745
2745
  await sleep(delayBetweenRetries);
2746
2746
  }
2747
2747
  return { body: null, statusCode: -1 };
@@ -2753,7 +2753,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2753
2753
  try {
2754
2754
  const SwitchBot = (await import('node-switchbot')).SwitchBot;
2755
2755
  queueScheduler.schedule(() => (switchbot = new SwitchBot()));
2756
- await await this.debugLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}`);
2756
+ await this.debugLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}`);
2757
2757
  } catch (e: any) {
2758
2758
  switchbot = false;
2759
2759
  await this.errorLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}, Error: ${e}`);
@@ -2768,7 +2768,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2768
2768
  'utf-8',
2769
2769
  ),
2770
2770
  );
2771
- await await this.debugLog(`Plugin Version: ${json.version}`);
2771
+ await this.debugLog(`Plugin Version: ${json.version}`);
2772
2772
  this.version = json.version;
2773
2773
  }
2774
2774
 
@@ -2804,7 +2804,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2804
2804
  platformConfig.delayBetweenRetries = this.delayBetweenRetries / 1000;
2805
2805
  }
2806
2806
  if (Object.entries(platformConfig).length !== 0) {
2807
- await await this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
2807
+ await this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
2808
2808
  }
2809
2809
  this.platformConfig = platformConfig;
2810
2810
  }
@@ -2814,13 +2814,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2814
2814
  this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
2815
2815
  if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
2816
2816
  this.platformLogging = this.config.options.logging;
2817
- await await this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`);
2817
+ await this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`);
2818
2818
  } else if (this.debugMode) {
2819
2819
  this.platformLogging = 'debugMode';
2820
- await await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
2820
+ await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
2821
2821
  } else {
2822
2822
  this.platformLogging = 'standard';
2823
- await await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
2823
+ await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
2824
2824
  }
2825
2825
  }
2826
2826
 
package/src/settings.ts CHANGED
@@ -56,18 +56,18 @@ interface credentials {
56
56
  }
57
57
 
58
58
  interface options {
59
- refreshRate?: number;
60
- updateRate?: number;
61
- pushRate?: number;
62
- maxRetries?: number;
63
- delayBetweenRetries?: number;
64
- logging?: string;
65
59
  devices?: devicesConfig[];
66
60
  irdevices?: irDevicesConfig[];
67
- webhookURL?: string;
68
61
  mqttURL?: string;
69
62
  mqttOptions?: IClientOptions;
70
63
  mqttPubOptions?: IClientOptions;
64
+ webhookURL?: string;
65
+ maxRetries?: number;
66
+ delayBetweenRetries?: number;
67
+ refreshRate?: number;
68
+ updateRate?: number;
69
+ pushRate?: number;
70
+ logging?: string;
71
71
  };
72
72
 
73
73
  export interface devicesConfig extends device {
@@ -111,7 +111,7 @@ export interface devicesConfig extends device {
111
111
  colorbulb?: colorbulb;
112
112
  striplight?: striplight;
113
113
  ceilinglight?: ceilinglight;
114
- plug?: Record<any, any>;
114
+ plug?: plug;
115
115
  lock?: lock;
116
116
  hub?: hub;
117
117
  }
@@ -198,6 +198,8 @@ interface ceilinglight {
198
198
  adaptiveLightingShift?: number;
199
199
  };
200
200
 
201
+ type plug = object;
202
+
201
203
  interface lock {
202
204
  hide_contactsensor?: boolean;
203
205
  activate_latchbutton?: boolean;
@@ -16,8 +16,9 @@ export type ad = {
16
16
  rssi: number;
17
17
  serviceData: botServiceData | colorBulbServiceData | contactSensorServiceData |
18
18
  curtainServiceData | curtain3ServiceData | stripLightServiceData | lockServiceData |
19
- lockProServiceData | meterServiceData | meterPlusServiceData | motionSensorServiceData |
20
- plugMiniUSServiceData | plugMiniJPServiceData | blindTiltServiceData;
19
+ lockProServiceData | meterServiceData | meterPlusServiceData | motionSensorServiceData | outdoorMeterServiceData |
20
+ plugMiniUSServiceData | plugMiniJPServiceData | blindTiltServiceData | ceilingLightServiceData | ceilingLightProServiceData |
21
+ hub2ServiceData | batteryCirculatorFanServiceData | waterLeakDetectorServiceData | humidifierServiceData | robotVacuumCleanerServiceData;
21
22
  };
22
23
 
23
24
  type serviceData = {
@@ -271,6 +272,7 @@ export type batteryCirculatorFanServiceData = serviceData & {
271
272
  modelName: SwitchBotBLEModelName.Unknown,
272
273
  modelFriendlyName: SwitchBotBLEModelFriendlyName.Unknown,
273
274
  state: string;
275
+ fanSpeed: number;
274
276
  };
275
277
 
276
278
  export type waterLeakDetectorServiceData = serviceData & {
@@ -154,7 +154,7 @@ export type humidifierStatus = deviceStatus & {
154
154
 
155
155
  export type blindTiltStatus = deviceStatus & {
156
156
  calibrate: boolean;
157
- battery: boolean;
157
+ battery: number;
158
158
  direction: string;
159
159
  slidePosition: string;
160
160
  lightLevel?: 'bright' | 'dim';