@switchbot/homebridge-switchbot 3.5.1-beta.11 → 3.5.1-beta.13

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 (153) 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 +57 -45
  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 +38 -24
  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 +44 -27
  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 +47 -32
  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 +40 -28
  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 +35 -22
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/device.d.ts +13 -2
  27. package/dist/device/device.d.ts.map +1 -1
  28. package/dist/device/device.js +223 -108
  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 +48 -29
  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 +43 -26
  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 +43 -26
  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 +39 -24
  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 +43 -27
  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 +33 -22
  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 +38 -24
  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 +37 -24
  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 +33 -22
  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 +27 -16
  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 +34 -21
  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 +38 -23
  77. package/dist/device/waterdetector.js.map +1 -1
  78. package/dist/irdevice/airconditioner.d.ts +1 -3
  79. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  80. package/dist/irdevice/airconditioner.js +32 -138
  81. package/dist/irdevice/airconditioner.js.map +1 -1
  82. package/dist/irdevice/airpurifier.d.ts +0 -1
  83. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  84. package/dist/irdevice/airpurifier.js +13 -44
  85. package/dist/irdevice/airpurifier.js.map +1 -1
  86. package/dist/irdevice/camera.d.ts.map +1 -1
  87. package/dist/irdevice/camera.js +3 -10
  88. package/dist/irdevice/camera.js.map +1 -1
  89. package/dist/irdevice/fan.d.ts.map +1 -1
  90. package/dist/irdevice/fan.js +7 -25
  91. package/dist/irdevice/fan.js.map +1 -1
  92. package/dist/irdevice/irdevice.d.ts +1 -1
  93. package/dist/irdevice/irdevice.js +5 -5
  94. package/dist/irdevice/irdevice.js.map +1 -1
  95. package/dist/irdevice/light.d.ts.map +1 -1
  96. package/dist/irdevice/light.js +9 -27
  97. package/dist/irdevice/light.js.map +1 -1
  98. package/dist/irdevice/other.js +1 -1
  99. package/dist/irdevice/other.js.map +1 -1
  100. package/dist/irdevice/tv.d.ts.map +1 -1
  101. package/dist/irdevice/tv.js +3 -18
  102. package/dist/irdevice/tv.js.map +1 -1
  103. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  104. package/dist/irdevice/vacuumcleaner.js +2 -9
  105. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  106. package/dist/irdevice/waterheater.d.ts.map +1 -1
  107. package/dist/irdevice/waterheater.js +2 -9
  108. package/dist/irdevice/waterheater.js.map +1 -1
  109. package/dist/platform.d.ts +0 -11
  110. package/dist/platform.d.ts.map +1 -1
  111. package/dist/platform.js +11 -184
  112. package/dist/platform.js.map +1 -1
  113. package/dist/settings.d.ts +9 -8
  114. package/dist/settings.d.ts.map +1 -1
  115. package/dist/settings.js.map +1 -1
  116. package/dist/types/bledevicestatus.d.ts +2 -1
  117. package/dist/types/bledevicestatus.d.ts.map +1 -1
  118. package/dist/types/devicestatus.d.ts +1 -1
  119. package/dist/types/devicestatus.d.ts.map +1 -1
  120. package/package.json +9 -9
  121. package/src/device/blindtilt.ts +60 -47
  122. package/src/device/bot.ts +47 -25
  123. package/src/device/ceilinglight.ts +53 -27
  124. package/src/device/colorbulb.ts +50 -39
  125. package/src/device/contact.ts +43 -28
  126. package/src/device/curtain.ts +45 -23
  127. package/src/device/device.ts +226 -96
  128. package/src/device/fan.ts +61 -30
  129. package/src/device/hub.ts +55 -29
  130. package/src/device/humidifier.ts +55 -31
  131. package/src/device/iosensor.ts +45 -27
  132. package/src/device/lightstrip.ts +48 -28
  133. package/src/device/lock.ts +49 -23
  134. package/src/device/meter.ts +54 -26
  135. package/src/device/meterplus.ts +50 -26
  136. package/src/device/motion.ts +45 -24
  137. package/src/device/plug.ts +34 -17
  138. package/src/device/robotvacuumcleaner.ts +49 -23
  139. package/src/device/waterdetector.ts +56 -25
  140. package/src/irdevice/airconditioner.ts +41 -125
  141. package/src/irdevice/airpurifier.ts +18 -40
  142. package/src/irdevice/camera.ts +4 -9
  143. package/src/irdevice/fan.ts +10 -22
  144. package/src/irdevice/irdevice.ts +5 -5
  145. package/src/irdevice/light.ts +10 -24
  146. package/src/irdevice/other.ts +1 -1
  147. package/src/irdevice/tv.ts +5 -16
  148. package/src/irdevice/vacuumcleaner.ts +3 -8
  149. package/src/irdevice/waterheater.ts +3 -8
  150. package/src/platform.ts +11 -184
  151. package/src/settings.ts +10 -8
  152. package/src/types/bledevicestatus.ts +4 -2
  153. package/src/types/devicestatus.ts +1 -1
package/src/device/fan.ts CHANGED
@@ -39,6 +39,15 @@ export class Fan extends deviceBase {
39
39
  Brightness: CharacteristicValue;
40
40
  };
41
41
 
42
+ // OpenAPI
43
+ deviceStatus!: batteryCirculatorFanStatus;
44
+
45
+ //Webhook
46
+ webhookContext!: batteryCirculatorFanWebhookContext;
47
+
48
+ // BLE
49
+ serviceData!: batteryCirculatorFanServiceData;
50
+
42
51
  // Updates
43
52
  fanUpdateInProgress!: boolean;
44
53
  doFanUpdate!: Subject<void>;
@@ -149,10 +158,12 @@ export class Fan extends deviceBase {
149
158
  .onSet(this.BrightnessSet.bind(this));
150
159
 
151
160
  // Retrieve initial values and updateHomekit
161
+ this.debugLog('Retrieve initial values and update Homekit');
152
162
  this.refreshStatus();
153
163
 
154
- // Update Homekit
155
- this.updateHomeKitCharacteristics();
164
+ //regisiter webhook event handler
165
+ this.debugLog('Registering Webhook Event Handler');
166
+ this.registerWebhook();
156
167
 
157
168
  //regisiter webhook event handler
158
169
  this.registerWebhook();
@@ -184,35 +195,45 @@ export class Fan extends deviceBase {
184
195
  });
185
196
  }
186
197
 
187
- async BLEparseStatus(serviceData: batteryCirculatorFanServiceData): Promise<void> {
198
+ async BLEparseStatus(): Promise<void> {
188
199
  await this.debugLog('BLEparseStatus');
200
+ await this.debugLog(`(powerState, fanSpeed) = BLE:(${this.serviceData.state}, ${this.serviceData.fanSpeed}), current:(${this.Fan.Active},`
201
+ + ` ${this.Fan.RotationSpeed})`);
202
+
189
203
  // Active
190
- this.Fan.Active = serviceData.state === 'on' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
204
+ this.Fan.Active = this.serviceData.state === 'on' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
191
205
  await this.debugLog(`Active: ${this.Fan.Active}`);
206
+
207
+ // RotationSpeed
208
+ this.Fan.RotationSpeed = this.serviceData.fanSpeed;
192
209
  }
193
210
 
194
- async openAPIparseStatus(deviceStatus: batteryCirculatorFanStatus) {
211
+ async openAPIparseStatus() {
195
212
  await this.debugLog('openAPIparseStatus');
213
+ await this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = OpenAPI:(${this.deviceStatus.version},`
214
+ + ` ${this.deviceStatus.battery}, ${this.deviceStatus.power}, ${this.deviceStatus.oscillation}, ${this.deviceStatus.chargingStatus},`
215
+ + ` ${this.deviceStatus.fanSpeed}), current:(${this.accessory.context.deviceVersion}, ${this.Battery.BatteryLevel}, ${this.Fan.Active},`
216
+ + ` ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`);
196
217
 
197
218
  // Active
198
- this.Fan.Active = deviceStatus.power === 'on' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
219
+ this.Fan.Active = this.deviceStatus.power === 'on' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
199
220
  this.debugLog(`Active: ${this.Fan.Active}`);
200
221
 
201
222
  // SwingMode
202
- this.Fan.SwingMode = deviceStatus.oscillation === 'on' ?
223
+ this.Fan.SwingMode = this.deviceStatus.oscillation === 'on' ?
203
224
  this.hap.Characteristic.SwingMode.SWING_ENABLED : this.hap.Characteristic.SwingMode.SWING_DISABLED;
204
225
  await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
205
226
 
206
227
  // RotationSpeed
207
- this.Fan.RotationSpeed = deviceStatus.fanSpeed;
228
+ this.Fan.RotationSpeed = this.deviceStatus.fanSpeed;
208
229
  await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
209
230
 
210
231
  // ChargingState
211
- this.Battery.ChargingState = deviceStatus.chargingStatus === 'charging' ?
232
+ this.Battery.ChargingState = this.deviceStatus.chargingStatus === 'charging' ?
212
233
  this.hap.Characteristic.ChargingState.CHARGING : this.hap.Characteristic.ChargingState.NOT_CHARGING;
213
234
 
214
235
  // BatteryLevel
215
- this.Battery.BatteryLevel = Number(deviceStatus.battery);
236
+ this.Battery.BatteryLevel = this.deviceStatus.battery;
216
237
  await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
217
238
 
218
239
  // StatusLowBattery
@@ -221,9 +242,9 @@ export class Fan extends deviceBase {
221
242
  await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
222
243
 
223
244
  // Firmware Version
224
- const version = deviceStatus.version.toString();
225
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
226
- if (deviceStatus.version) {
245
+ if (this.deviceStatus.version) {
246
+ const version = this.deviceStatus.version.toString();
247
+ await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
227
248
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
228
249
  this.accessory
229
250
  .getService(this.hap.Service.AccessoryInformation)!
@@ -236,36 +257,43 @@ export class Fan extends deviceBase {
236
257
  }
237
258
  }
238
259
 
239
- async parseStatusWebhook(context: batteryCirculatorFanWebhookContext): Promise<void> {
260
+ async parseStatusWebhook(): Promise<void> {
240
261
  await this.debugLog('parseStatusWebhook');
241
- await this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = Webhook:(${context.version}, ${context.battery},`
242
- + ` ${context.powerState}, ${context.oscillation}, ${context.chargingStatus}, ${context.fanSpeed}),`
243
- + ` current:(${this.accessory.context.deviceVersion}, ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode},`
244
- + ` ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`);
262
+ await this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = Webhook:(${this.webhookContext.version},`
263
+ + ` ${this.webhookContext.battery}, ${this.webhookContext.powerState}, ${this.webhookContext.oscillation},`
264
+ + ` ${this.webhookContext.chargingStatus}, ${this.webhookContext.fanSpeed}), current:(${this.accessory.context.deviceVersion},`
265
+ + ` ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`);
266
+
245
267
  // Active
246
- this.Fan.Active = context.powerState === 'ON' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
268
+ this.Fan.Active = this.webhookContext.powerState === 'ON' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
247
269
  await this.debugLog(`Active: ${this.Fan.Active}`);
270
+
248
271
  // SwingMode
249
- this.Fan.SwingMode = context.oscillation === 'on' ?
272
+ this.Fan.SwingMode = this.webhookContext.oscillation === 'on' ?
250
273
  this.hap.Characteristic.SwingMode.SWING_ENABLED : this.hap.Characteristic.SwingMode.SWING_DISABLED;
251
274
  await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
275
+
252
276
  // RotationSpeed
253
- this.Fan.RotationSpeed = context.fanSpeed;
277
+ this.Fan.RotationSpeed = this.webhookContext.fanSpeed;
254
278
  await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
279
+
255
280
  // BatteryLevel
256
- this.Battery.BatteryLevel = context.battery;
281
+ this.Battery.BatteryLevel = this.webhookContext.battery;
257
282
  await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
283
+
258
284
  // StatusLowBattery
259
285
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
260
286
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
261
287
  await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
288
+
262
289
  // ChargingState
263
- this.Battery.ChargingState = context.chargingStatus === 'charging' ?
290
+ this.Battery.ChargingState = this.webhookContext.chargingStatus === 'charging' ?
264
291
  this.hap.Characteristic.ChargingState.CHARGING : this.hap.Characteristic.ChargingState.NOT_CHARGING;
265
292
  await this.debugLog(`ChargingState: ${this.Battery.ChargingState}`);
293
+
266
294
  // FirmwareVersion
267
- if (context.version) {
268
- const deviceVersion = context.version.replace(/^V|-.*$/g, '') ?? '0.0.0';
295
+ if (this.webhookContext.version) {
296
+ const deviceVersion = this.webhookContext.version.replace(/^V|-.*$/g, '') ?? '0.0.0';
269
297
  this.accessory
270
298
  .getService(this.hap.Service.AccessoryInformation)!
271
299
  .setCharacteristic(this.hap.Characteristic.HardwareRevision, deviceVersion)
@@ -303,10 +331,11 @@ export class Fan extends deviceBase {
303
331
  // Start to monitor advertisement packets
304
332
  (async () => {
305
333
  // Start to monitor advertisement packets
306
- const serviceData = await this.monitorAdvertisementPackets(switchbot) as unknown as batteryCirculatorFanServiceData;
334
+ const serviceData = await this.monitorAdvertisementPackets(switchbot) as batteryCirculatorFanServiceData;
307
335
  // Update HomeKit
308
336
  if (serviceData.model === SwitchBotBLEModel.Unknown && SwitchBotBLEModelName.Unknown) {
309
- await this.BLEparseStatus(serviceData);
337
+ this.serviceData = serviceData;
338
+ await this.BLEparseStatus();
310
339
  await this.updateHomeKitCharacteristics();
311
340
  } else {
312
341
  await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
@@ -324,7 +353,8 @@ export class Fan extends deviceBase {
324
353
  await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);;
325
354
  if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
326
355
  await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
327
- await this.openAPIparseStatus(deviceStatus.body);
356
+ this.deviceStatus = deviceStatus.body;
357
+ await this.openAPIparseStatus();
328
358
  await this.updateHomeKitCharacteristics();
329
359
  } else {
330
360
  await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
@@ -339,10 +369,11 @@ export class Fan extends deviceBase {
339
369
  async registerWebhook() {
340
370
  if (this.device.webhook) {
341
371
  await this.debugLog('is listening webhook.');
342
- this.platform.webhookEventHandler[this.device.deviceId] = async (context: batteryCirculatorFanWebhookContext) => {
372
+ this.webhookEventHandler[this.device.deviceId] = async (context: batteryCirculatorFanWebhookContext) => {
343
373
  try {
344
374
  await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
345
- await this.parseStatusWebhook(context);
375
+ this.webhookContext = context;
376
+ await this.parseStatusWebhook();
346
377
  await this.updateHomeKitCharacteristics();
347
378
  } catch (e: any) {
348
379
  await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
package/src/device/hub.ts CHANGED
@@ -36,6 +36,15 @@ export class Hub extends deviceBase {
36
36
  CurrentTemperature: CharacteristicValue;
37
37
  };
38
38
 
39
+ // OpenAPI
40
+ deviceStatus!: hub2Status;
41
+
42
+ //Webhook
43
+ webhookContext!: hub2WebhookContext;
44
+
45
+ // BLE
46
+ serviceData!: hub2ServiceData;
47
+
39
48
  // Updates
40
49
  hubUpdateInProgress!: boolean;
41
50
  doHubUpdate!: Subject<void>;
@@ -139,12 +148,11 @@ export class Hub extends deviceBase {
139
148
  }
140
149
 
141
150
  // Retrieve initial values and updateHomekit
151
+ this.debugLog('Retrieve initial values and update Homekit');
142
152
  this.refreshStatus();
143
153
 
144
- // Retrieve initial values and update Homekit
145
- this.updateHomeKitCharacteristics();
146
-
147
154
  //regisiter webhook event handler
155
+ this.debugLog('Registering Webhook Event Handler');
148
156
  this.registerWebhook();
149
157
 
150
158
  // Start an update interval
@@ -156,39 +164,49 @@ export class Hub extends deviceBase {
156
164
 
157
165
  }
158
166
 
159
- async BLEparseStatus(serviceData: hub2ServiceData): Promise<void> {
167
+ async BLEparseStatus(): Promise<void> {
160
168
  await this.debugLog('BLEparseStatus');
169
+ await this.debugLog(`(temperature, humidity, lightLevel) = BLE:(${this.serviceData.temperature}, ${this.serviceData.humidity},`
170
+ + ` ${this.serviceData.lightLevel}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity},`
171
+ + ` ${this.LightSensor?.CurrentAmbientLightLevel})`);
172
+
161
173
  // CurrentTemperature
162
174
  if (!this.device.hub?.hide_temperature && this.TemperatureSensor?.Service) {
163
- this.TemperatureSensor.CurrentTemperature = serviceData.temperature;
175
+ this.TemperatureSensor.CurrentTemperature = this.serviceData.temperature;
164
176
  await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`);
165
177
  }
178
+
166
179
  // CurrentRelativeHumidity
167
180
  if (!this.device.hub?.hide_humidity && this.HumiditySensor?.Service) {
168
- this.HumiditySensor!.CurrentRelativeHumidity = Number(serviceData.humidity);
181
+ this.HumiditySensor!.CurrentRelativeHumidity = this.serviceData.humidity;
169
182
  await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`);
170
183
  }
184
+
171
185
  // CurrentAmbientLightLevel
172
186
  if (!this.device.hub?.hide_lightsensor && this.LightSensor?.Service) {
173
187
  const set_minLux = this.device.blindTilt?.set_minLux ?? 1;
174
188
  const set_maxLux = this.device.blindTilt?.set_maxLux ?? 6001;
175
- const lightLevel = Number(serviceData.lightLevel);
189
+ const lightLevel = this.serviceData.lightLevel;
176
190
  this.LightSensor.CurrentAmbientLightLevel = await this.getLightLevel(lightLevel, set_minLux, set_maxLux, 19);
177
- await this.debugLog(`LightLevel: ${serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
191
+ await this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
178
192
  }
179
193
  }
180
194
 
181
- async openAPIparseStatus(deviceStatus: hub2Status): Promise<void> {
195
+ async openAPIparseStatus(): Promise<void> {
182
196
  await this.debugLog('openAPIparseStatus');
197
+ await this.debugLog(`(temperature, humidity, lightLevel) = OpenAPI:(${this.deviceStatus.temperature}, ${this.deviceStatus.humidity},`
198
+ + ` ${this.deviceStatus.lightLevel}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity},`
199
+ + ` ${this.LightSensor?.CurrentAmbientLightLevel})`);
200
+
183
201
  // CurrentRelativeHumidity
184
202
  if (!this.device.hub?.hide_humidity && this.HumiditySensor?.Service) {
185
- this.HumiditySensor.CurrentRelativeHumidity = deviceStatus.humidity;
203
+ this.HumiditySensor.CurrentRelativeHumidity = this.deviceStatus.humidity;
186
204
  await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`);
187
205
  }
188
206
 
189
207
  // CurrentTemperature
190
208
  if (!this.device.hub?.hide_temperature && this.TemperatureSensor?.Service) {
191
- this.TemperatureSensor.CurrentTemperature = deviceStatus.temperature;
209
+ this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature;
192
210
  await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`);
193
211
  }
194
212
 
@@ -196,15 +214,15 @@ export class Hub extends deviceBase {
196
214
  if (!this.device.hub?.hide_lightsensor && this.LightSensor?.Service) {
197
215
  const set_minLux = this.device.blindTilt?.set_minLux ?? 1;
198
216
  const set_maxLux = this.device.blindTilt?.set_maxLux ?? 6001;
199
- const lightLevel = Number(deviceStatus.lightLevel);
217
+ const lightLevel = this.deviceStatus.lightLevel;
200
218
  this.LightSensor.CurrentAmbientLightLevel = await this.getLightLevel(lightLevel, set_minLux, set_maxLux, 19);
201
- await this.debugLog(`LightLevel: ${deviceStatus.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`);
219
+ await this.debugLog(`LightLevel: ${this.deviceStatus.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`);
202
220
  }
203
221
 
204
222
  // Firmware Version
205
- const version = deviceStatus.version.toString();
206
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
207
- if (deviceStatus.version) {
223
+ if (this.deviceStatus.version) {
224
+ const version = this.deviceStatus.version.toString();
225
+ await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
208
226
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
209
227
  this.accessory
210
228
  .getService(this.hap.Service.AccessoryInformation)!
@@ -217,31 +235,36 @@ export class Hub extends deviceBase {
217
235
  }
218
236
  }
219
237
 
220
- async parseStatusWebhook(context: hub2WebhookContext): Promise<void> {
238
+ async parseStatusWebhook(): Promise<void> {
221
239
  await this.debugLog('parseStatusWebhook');
222
- await this.debugLog(`(scale, temperature, humidity, lightLevel) = Webhook:(${context.scale}, ${convertUnits(context.temperature, context.scale,
223
- this.device.hub?.convertUnitTo)}, ${context.humidity}, ${context.lightLevel}), current:(${this.TemperatureSensor?.CurrentTemperature},`
240
+ await this.debugLog(`(scale, temperature, humidity, lightLevel) = Webhook:(${this.webhookContext.scale},`
241
+ + ` ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, this.device.hub?.convertUnitTo)},`
242
+ + ` ${this.webhookContext.humidity}, ${this.webhookContext.lightLevel}), current:(${this.TemperatureSensor?.CurrentTemperature},`
224
243
  + ` ${this.HumiditySensor?.CurrentRelativeHumidity}, ${this.LightSensor?.CurrentAmbientLightLevel})`);
225
244
  // Check if the scale is not CELSIUS
226
- if (context.scale !== 'CELSIUS' && this.device.hub?.convertUnitTo === undefined) {
227
- await this.warnLog(`received a non-CELSIUS Webhook scale: ${context.scale}, Use the *convertUnitsTo* config under Hub settings,`
245
+ if (this.webhookContext.scale !== 'CELSIUS' && this.device.hub?.convertUnitTo === undefined) {
246
+ await this.warnLog(`received a non-CELSIUS Webhook scale: ${this.webhookContext.scale}, Use the *convertUnitsTo* config under Hub settings,`
228
247
  + ' if displaying incorrectly in HomeKit.');
229
248
  }
249
+
230
250
  // CurrentRelativeHumidity
231
251
  if (!this.device.hub?.hide_humidity && this.HumiditySensor?.Service) {
232
- this.HumiditySensor.CurrentRelativeHumidity = context.humidity;
252
+ this.HumiditySensor.CurrentRelativeHumidity = this.webhookContext.humidity;
233
253
  await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}`);
234
254
  }
255
+
235
256
  // CurrentTemperature
236
257
  if (!this.device.hub?.hide_temperature && this.TemperatureSensor?.Service) {
237
- this.TemperatureSensor.CurrentTemperature = convertUnits(context.temperature, context.scale, this.device.hub?.convertUnitTo);
258
+ this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale,
259
+ this.device.hub?.convertUnitTo);
238
260
  await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
239
261
  }
262
+
240
263
  // CurrentAmbientLightLevel
241
264
  if (!this.device.hub?.hide_lightsensor && this.LightSensor?.Service) {
242
265
  const set_minLux = this.device.blindTilt?.set_minLux ?? 1;
243
266
  const set_maxLux = this.device.blindTilt?.set_maxLux ?? 6001;
244
- this.LightSensor.CurrentAmbientLightLevel = await this.getLightLevel(context.lightLevel, set_minLux, set_maxLux, 19);
267
+ this.LightSensor.CurrentAmbientLightLevel = await this.getLightLevel(this.webhookContext.lightLevel, set_minLux, set_maxLux, 19);
245
268
  await this.debugLog(`CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
246
269
  }
247
270
  }
@@ -272,10 +295,11 @@ export class Hub extends deviceBase {
272
295
  // Start to monitor advertisement packets
273
296
  (async () => {
274
297
  // Start to monitor advertisement packets
275
- const serviceData = await this.monitorAdvertisementPackets(switchbot) as unknown as hub2ServiceData;
298
+ const serviceData = await this.monitorAdvertisementPackets(switchbot) as hub2ServiceData;
276
299
  // Update HomeKit
277
300
  if (serviceData.model === SwitchBotBLEModel.Hub2 && serviceData.modelName === SwitchBotBLEModelName.Hub2) {
278
- await this.BLEparseStatus(serviceData);
301
+ this.serviceData = serviceData;
302
+ await this.BLEparseStatus();
279
303
  await this.updateHomeKitCharacteristics();
280
304
  } else {
281
305
  await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
@@ -293,7 +317,8 @@ export class Hub extends deviceBase {
293
317
  await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);;
294
318
  if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
295
319
  await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
296
- await this.openAPIparseStatus(deviceStatus.body);
320
+ this.deviceStatus = deviceStatus.body;
321
+ await this.openAPIparseStatus();
297
322
  await this.updateHomeKitCharacteristics();
298
323
  } else {
299
324
  await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
@@ -308,10 +333,11 @@ export class Hub extends deviceBase {
308
333
  async registerWebhook(): Promise<void> {
309
334
  if (this.device.webhook) {
310
335
  await this.debugLog('is listening webhook.');
311
- this.platform.webhookEventHandler[this.device.deviceId] = async (context: hub2WebhookContext) => {
336
+ this.webhookEventHandler[this.device.deviceId] = async (context: hub2WebhookContext) => {
312
337
  try {
313
338
  await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
314
- await this.parseStatusWebhook(context);
339
+ this.webhookContext = context;
340
+ await this.parseStatusWebhook();
315
341
  await this.updateHomeKitCharacteristics();
316
342
  } catch (e: any) {
317
343
  await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
@@ -39,6 +39,15 @@ export class Humidifier extends deviceBase {
39
39
  CurrentTemperature: CharacteristicValue;
40
40
  };
41
41
 
42
+ // OpenAPI
43
+ deviceStatus!: humidifierStatus;
44
+
45
+ //Webhook
46
+ webhookContext!: humidifierWebhookContext;
47
+
48
+ // BLE
49
+ serviceData!: humidifierServiceData;
50
+
42
51
  // Updates
43
52
  humidifierUpdateInProgress!: boolean;
44
53
  doHumidifierUpdate!: Subject<void>;
@@ -139,12 +148,11 @@ export class Humidifier extends deviceBase {
139
148
  }
140
149
 
141
150
  // Retrieve initial values and updateHomekit
151
+ this.debugLog('Retrieve initial values and update Homekit');
142
152
  this.refreshStatus();
143
153
 
144
- // Retrieve initial values and updateHomekit
145
- this.updateHomeKitCharacteristics();
146
-
147
154
  //regisiter webhook event handler
155
+ this.debugLog('Registering Webhook Event Handler');
148
156
  this.registerWebhook();
149
157
 
150
158
  // Start an update interval
@@ -174,18 +182,23 @@ export class Humidifier extends deviceBase {
174
182
  });
175
183
  }
176
184
 
177
- async BLEparseStatus(serviceData: humidifierServiceData): Promise<void> {
185
+ async BLEparseStatus(): Promise<void> {
178
186
  await this.debugLog('BLEparseStatus');
187
+ await this.debugLog(`(onState, percentage, autoMode) = BLE:(${this.serviceData.onState}, ${this.serviceData.percentage},`
188
+ + ` ${this.serviceData.autoMode}), current:(${this.HumidifierDehumidifier.Active}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity},`
189
+ + ` ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold})`,
190
+ );
191
+
179
192
  // Active
180
- this.HumidifierDehumidifier.Active = serviceData.onState ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
193
+ this.HumidifierDehumidifier.Active = this.serviceData.onState ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
181
194
  await this.debugLog(`Active: ${this.HumidifierDehumidifier.Active}`);
182
195
 
183
196
  // Current Relative Humidity
184
- this.HumidifierDehumidifier.CurrentRelativeHumidity = serviceData.percentage;
197
+ this.HumidifierDehumidifier.CurrentRelativeHumidity = this.serviceData.percentage;
185
198
  await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
186
199
 
187
200
  // Target Humidifier Dehumidifier State
188
- switch (serviceData.autoMode) {
201
+ switch (this.serviceData.autoMode) {
189
202
  case true:
190
203
  this.HumidifierDehumidifier.TargetHumidifierDehumidifierState =
191
204
  this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
@@ -194,7 +207,7 @@ export class Humidifier extends deviceBase {
194
207
  break;
195
208
  default:
196
209
  this.HumidifierDehumidifier.TargetHumidifierDehumidifierState = this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
197
- this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = serviceData.percentage > 100 ? 100 : serviceData.percentage;
210
+ this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = this.serviceData.percentage > 100 ? 100 : this.serviceData.percentage;
198
211
  if (this.HumidifierDehumidifier.CurrentRelativeHumidity > this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold) {
199
212
  this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
200
213
  } else if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
@@ -208,24 +221,30 @@ export class Humidifier extends deviceBase {
208
221
  + ` CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`);
209
222
  }
210
223
 
211
- async openAPIparseStatus(deviceStatus: humidifierStatus): Promise<void> {
224
+ async openAPIparseStatus(): Promise<void> {
212
225
  await this.debugLog('openAPIparseStatus');
226
+ await this.debugLog(`(power, auto, temperature, lackWater, nebulizationEfficiency, version) = OpenAPI:(${this.deviceStatus.power},`
227
+ + ` ${this.deviceStatus.auto}, ${this.deviceStatus.temperature}, ${this.deviceStatus.lackWater},`
228
+ + ` ${this.deviceStatus.nebulizationEfficiency}, ${this.deviceStatus.version}), current:(${this.HumidifierDehumidifier.Active},`
229
+ + ` ${this.HumidifierDehumidifier.CurrentRelativeHumidity}, ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState},`
230
+ + ` ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold})`);
231
+
213
232
  // Active
214
- this.HumidifierDehumidifier.Active = deviceStatus.power === 'on'
233
+ this.HumidifierDehumidifier.Active = this.deviceStatus.power === 'on'
215
234
  ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
216
235
  await this.debugLog(`Active: ${this.HumidifierDehumidifier.Active}`);
217
236
 
218
237
  // Current Relative Humidity
219
- this.HumidifierDehumidifier.CurrentRelativeHumidity = deviceStatus.temperature!;
238
+ this.HumidifierDehumidifier.CurrentRelativeHumidity = this.deviceStatus.temperature!;
220
239
  await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
221
240
 
222
241
  // Current Temperature
223
242
  if (!this.device.humidifier?.hide_temperature && this.TemperatureSensor?.Service) {
224
- this.TemperatureSensor.CurrentTemperature = deviceStatus.temperature;
243
+ this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature;
225
244
  await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
226
245
  }
227
246
  // Target Humidifier Dehumidifier State
228
- switch (deviceStatus.auto) {
247
+ switch (this.deviceStatus.auto) {
229
248
  case true:
230
249
  this.HumidifierDehumidifier.TargetHumidifierDehumidifierState =
231
250
  this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
@@ -234,8 +253,8 @@ export class Humidifier extends deviceBase {
234
253
  break;
235
254
  default:
236
255
  this.HumidifierDehumidifier.TargetHumidifierDehumidifierState = this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
237
- this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = deviceStatus.nebulizationEfficiency > 100
238
- ? 100 : deviceStatus.nebulizationEfficiency;
256
+ this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = this.deviceStatus.nebulizationEfficiency > 100
257
+ ? 100 : this.deviceStatus.nebulizationEfficiency;
239
258
  if (this.HumidifierDehumidifier.CurrentRelativeHumidity > this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold) {
240
259
  this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
241
260
  } else if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
@@ -249,7 +268,7 @@ export class Humidifier extends deviceBase {
249
268
  + ` CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`);
250
269
 
251
270
  // Water Level
252
- if (deviceStatus.lackWater) {
271
+ if (this.deviceStatus.lackWater) {
253
272
  this.HumidifierDehumidifier.WaterLevel = 0;
254
273
  } else {
255
274
  this.HumidifierDehumidifier.WaterLevel = 100;
@@ -257,8 +276,8 @@ export class Humidifier extends deviceBase {
257
276
  await this.debugLog(`WaterLevel: ${this.HumidifierDehumidifier.WaterLevel}`);
258
277
 
259
278
  // Firmware Version
260
- if (deviceStatus.version) {
261
- const version = deviceStatus.version.toString();
279
+ if (this.deviceStatus.version) {
280
+ const version = this.deviceStatus.version.toString();
262
281
  await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
263
282
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
264
283
  this.accessory
@@ -272,18 +291,20 @@ export class Humidifier extends deviceBase {
272
291
  }
273
292
  }
274
293
 
275
- async parseStatusWebhook(context: humidifierWebhookContext): Promise<void> {
294
+ async parseStatusWebhook(): Promise<void> {
276
295
  await this.debugLog('parseStatusWebhook');
277
- await this.debugLog(`(temperature, humidity) = Webhook:(${convertUnits(context.temperature, context.scale, this.device.iosensor?.convertUnitTo)},`
278
- + ` ${context.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity})`);
296
+ await this.debugLog(`(temperature, humidity) = Webhook:(${convertUnits(this.webhookContext.temperature, this.webhookContext.scale,
297
+ this.device.iosensor?.convertUnitTo)}, ${this.webhookContext.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature},`
298
+ + ` ${this.HumidifierDehumidifier.CurrentRelativeHumidity})`);
279
299
 
280
300
  // CurrentRelativeHumidity
281
- this.HumidifierDehumidifier.CurrentRelativeHumidity = context.humidity;
301
+ this.HumidifierDehumidifier.CurrentRelativeHumidity = this.webhookContext.humidity;
282
302
  await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
283
303
 
284
304
  // CurrentTemperature
285
305
  if (!this.device.humidifier?.hide_temperature && this.TemperatureSensor?.Service) {
286
- this.TemperatureSensor.CurrentTemperature = convertUnits(context.temperature, context.scale, this.device.iosensor?.convertUnitTo);
306
+ this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale,
307
+ this.device.iosensor?.convertUnitTo);
287
308
  await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
288
309
  }
289
310
  }
@@ -314,10 +335,11 @@ export class Humidifier extends deviceBase {
314
335
  // Start to monitor advertisement packets
315
336
  (async () => {
316
337
  // Start to monitor advertisement packets
317
- const serviceData= await this.monitorAdvertisementPackets(switchbot) as unknown as humidifierServiceData;
338
+ const serviceData = await this.monitorAdvertisementPackets(switchbot) as humidifierServiceData;
318
339
  // Update HomeKit
319
340
  if (serviceData.model === SwitchBotBLEModel.Humidifier && serviceData.modelName === SwitchBotBLEModelName.Humidifier) {
320
- await this.BLEparseStatus(serviceData);
341
+ this.serviceData = serviceData;
342
+ await this.BLEparseStatus();
321
343
  await this.updateHomeKitCharacteristics();
322
344
  } else {
323
345
  await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
@@ -335,7 +357,8 @@ export class Humidifier extends deviceBase {
335
357
  await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);;
336
358
  if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
337
359
  await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
338
- await this.openAPIparseStatus(deviceStatus.body);
360
+ this.deviceStatus = deviceStatus.body;
361
+ await this.openAPIparseStatus();
339
362
  await this.updateHomeKitCharacteristics();
340
363
  } else {
341
364
  await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
@@ -350,10 +373,11 @@ export class Humidifier extends deviceBase {
350
373
  async registerWebhook() {
351
374
  if (this.device.webhook) {
352
375
  await this.debugLog('is listening webhook.');
353
- this.platform.webhookEventHandler[this.device.deviceId] = async (context: humidifierWebhookContext) => {
376
+ this.webhookEventHandler[this.device.deviceId] = async (context: humidifierWebhookContext) => {
354
377
  try {
355
378
  await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
356
- await this.parseStatusWebhook(context);
379
+ this.webhookContext = context;
380
+ await this.parseStatusWebhook();
357
381
  await this.updateHomeKitCharacteristics();
358
382
  } catch (e: any) {
359
383
  await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
@@ -414,8 +438,8 @@ export class Humidifier extends deviceBase {
414
438
  }
415
439
  } else {
416
440
  await this.debugLog(`No changes (BLEpushChanges), Active: ${this.HumidifierDehumidifier.Active},`
417
- + ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold},`
418
- + ` CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
441
+ + ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold},`
442
+ + ` CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
419
443
  }
420
444
  }
421
445
 
@@ -423,7 +447,7 @@ export class Humidifier extends deviceBase {
423
447
  await this.debugLog('openAPIpushChanges');
424
448
  if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER)
425
449
  && (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)
426
- && (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold !== this.HumidifierDehumidifier.CurrentRelativeHumidity)) {
450
+ && (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold !== this.HumidifierDehumidifier.CurrentRelativeHumidity)) {
427
451
  await this.debugLog(`Auto Off, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}!`);
428
452
  const bodyChange = JSON.stringify({
429
453
  command: 'setMode',