@switchbot/homebridge-switchbot 2.8.1-beta.0 → 2.8.1-beta.2

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 (64) hide show
  1. package/dist/device/hub.d.ts.map +1 -1
  2. package/dist/device/hub.js +13 -19
  3. package/dist/device/hub.js.map +1 -1
  4. package/dist/device/lightstrip.d.ts +7 -8
  5. package/dist/device/lightstrip.d.ts.map +1 -1
  6. package/dist/device/lightstrip.js +26 -21
  7. package/dist/device/lightstrip.js.map +1 -1
  8. package/dist/device/lock.d.ts +3 -3
  9. package/dist/device/lock.d.ts.map +1 -1
  10. package/dist/device/lock.js +16 -5
  11. package/dist/device/lock.js.map +1 -1
  12. package/dist/device/meter.d.ts +13 -13
  13. package/dist/device/meter.d.ts.map +1 -1
  14. package/dist/device/meter.js +32 -21
  15. package/dist/device/meter.js.map +1 -1
  16. package/dist/device/meterplus.d.ts +12 -12
  17. package/dist/device/meterplus.d.ts.map +1 -1
  18. package/dist/device/meterplus.js +32 -21
  19. package/dist/device/meterplus.js.map +1 -1
  20. package/dist/device/motion.d.ts +8 -13
  21. package/dist/device/motion.d.ts.map +1 -1
  22. package/dist/device/motion.js +34 -23
  23. package/dist/device/motion.js.map +1 -1
  24. package/dist/device/plug.d.ts +4 -10
  25. package/dist/device/plug.d.ts.map +1 -1
  26. package/dist/device/plug.js +20 -15
  27. package/dist/device/plug.js.map +1 -1
  28. package/dist/device/robotvacuumcleaner.d.ts +6 -6
  29. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  30. package/dist/device/robotvacuumcleaner.js +23 -12
  31. package/dist/device/robotvacuumcleaner.js.map +1 -1
  32. package/dist/irdevice/airconditioner.d.ts +4 -4
  33. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  34. package/dist/irdevice/camera.d.ts +1 -1
  35. package/dist/irdevice/camera.d.ts.map +1 -1
  36. package/dist/irdevice/fan.d.ts +3 -3
  37. package/dist/irdevice/fan.d.ts.map +1 -1
  38. package/dist/irdevice/light.d.ts +1 -1
  39. package/dist/irdevice/light.d.ts.map +1 -1
  40. package/dist/irdevice/other.d.ts +2 -2
  41. package/dist/irdevice/other.d.ts.map +1 -1
  42. package/dist/irdevice/tv.d.ts +1 -1
  43. package/dist/irdevice/tv.d.ts.map +1 -1
  44. package/dist/irdevice/vacuumcleaner.d.ts +1 -1
  45. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  46. package/dist/irdevice/waterheater.d.ts +1 -1
  47. package/dist/irdevice/waterheater.d.ts.map +1 -1
  48. package/package.json +4 -4
  49. package/src/device/hub.ts +13 -21
  50. package/src/device/lightstrip.ts +35 -30
  51. package/src/device/lock.ts +18 -8
  52. package/src/device/meter.ts +47 -35
  53. package/src/device/meterplus.ts +46 -34
  54. package/src/device/motion.ts +45 -33
  55. package/src/device/plug.ts +23 -25
  56. package/src/device/robotvacuumcleaner.ts +31 -19
  57. package/src/irdevice/airconditioner.ts +4 -4
  58. package/src/irdevice/camera.ts +1 -1
  59. package/src/irdevice/fan.ts +3 -3
  60. package/src/irdevice/light.ts +1 -1
  61. package/src/irdevice/other.ts +2 -2
  62. package/src/irdevice/tv.ts +1 -1
  63. package/src/irdevice/vacuumcleaner.ts +1 -1
  64. package/src/irdevice/waterheater.ts +1 -1
@@ -22,24 +22,26 @@ export class MeterPlus {
22
22
  temperatureservice?: Service;
23
23
 
24
24
  // Characteristic Values
25
- CurrentRelativeHumidity!: CharacteristicValue;
26
- CurrentTemperature?: CharacteristicValue;
27
25
  BatteryLevel!: CharacteristicValue;
28
26
  StatusLowBattery!: CharacteristicValue;
27
+ CurrentTemperature?: CharacteristicValue;
28
+ CurrentRelativeHumidity!: CharacteristicValue;
29
29
 
30
- // OpenAPI Others
31
- Version: deviceStatus['version'];
32
- Battery: deviceStatus['battery'];
33
- Temperature: deviceStatus['temperature'];
34
- Humidity: deviceStatus['humidity'];
30
+ // OpenAPI Status
31
+ OpenAPI_BatteryLevel: deviceStatus['battery'];
32
+ OpenAPI_FirmwareRevision: deviceStatus['version'];
33
+ OpenAPI_CurrentTemperature: deviceStatus['temperature'];
34
+ OpenAPI_CurrentRelativeHumidity: deviceStatus['humidity'];
35
+
36
+ // BLE Status
37
+ BLE_Celsius!: temperature['c'];
38
+ BLE_Fahrenheit!: temperature['f'];
39
+ BLE_BatteryLevel!: serviceData['battery'];
40
+ BLE_CurrentTemperature!: serviceData['temperature'];
41
+ BLE_CurrentRelativeHumidity!: serviceData['humidity'];
35
42
 
36
43
  // BLE Others
37
- connected?: boolean;
38
- temperature!: serviceData['temperature'];
39
- celsius!: temperature['c'];
40
- fahrenheit!: temperature['f'];
41
- battery!: serviceData['battery'];
42
- humidity!: serviceData['humidity'];
44
+ BLE_IsConnected?: boolean;
43
45
 
44
46
  //MQTT stuff
45
47
  mqttClient: MqttClient | null = null;
@@ -192,7 +194,7 @@ export class MeterPlus {
192
194
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
193
195
 
194
196
  // Battery
195
- this.BatteryLevel = Number(this.battery);
197
+ this.BatteryLevel = Number(this.BLE_BatteryLevel);
196
198
  if (this.BatteryLevel < 15) {
197
199
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
198
200
  } else {
@@ -202,14 +204,14 @@ export class MeterPlus {
202
204
 
203
205
  // Humidity
204
206
  if (!this.device.meter?.hide_humidity) {
205
- this.CurrentRelativeHumidity = this.humidity!;
207
+ this.CurrentRelativeHumidity = this.BLE_CurrentRelativeHumidity!;
206
208
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Humidity: ${this.CurrentRelativeHumidity}%`);
207
209
  }
208
210
 
209
211
  // Current Temperature
210
212
  if (!this.device.meter?.hide_temperature) {
211
- this.celsius < 0 ? 0 : this.celsius > 100 ? 100 : this.celsius;
212
- this.CurrentTemperature = this.celsius;
213
+ this.BLE_Celsius < 0 ? 0 : this.BLE_Celsius > 100 ? 100 : this.BLE_Celsius;
214
+ this.CurrentTemperature = this.BLE_Celsius;
213
215
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c`);
214
216
  }
215
217
  }
@@ -218,7 +220,7 @@ export class MeterPlus {
218
220
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
219
221
 
220
222
  // Battery
221
- this.BatteryLevel = Number(this.Battery);
223
+ this.BatteryLevel = Number(this.OpenAPI_BatteryLevel);
222
224
  if (this.BatteryLevel < 15) {
223
225
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
224
226
  } else {
@@ -228,13 +230,13 @@ export class MeterPlus {
228
230
 
229
231
  // Current Relative Humidity
230
232
  if (!this.device.meter?.hide_humidity) {
231
- this.CurrentRelativeHumidity = this.Humidity!;
233
+ this.CurrentRelativeHumidity = this.BLE_CurrentRelativeHumidity!;
232
234
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Humidity: ${this.CurrentRelativeHumidity}%`);
233
235
  }
234
236
 
235
237
  // Current Temperature
236
238
  if (!this.device.meter?.hide_temperature) {
237
- this.CurrentTemperature = this.Temperature!;
239
+ this.CurrentTemperature = this.BLE_CurrentTemperature!;
238
240
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c`);
239
241
  }
240
242
  }
@@ -284,12 +286,12 @@ export class MeterPlus {
284
286
  );
285
287
  if (ad.serviceData.humidity! > 0) {
286
288
  // reject unreliable data
287
- this.humidity = ad.serviceData.humidity;
289
+ this.BLE_CurrentRelativeHumidity = ad.serviceData.humidity;
288
290
  }
289
- this.temperature = ad.serviceData.temperature;
290
- this.celsius = ad.serviceData.temperature!.c;
291
- this.fahrenheit = ad.serviceData.temperature!.f;
292
- this.battery = ad.serviceData.battery;
291
+ this.BLE_CurrentTemperature = ad.serviceData.temperature;
292
+ this.BLE_Celsius = ad.serviceData.temperature!.c;
293
+ this.BLE_Fahrenheit = ad.serviceData.temperature!.f;
294
+ this.BLE_BatteryLevel = ad.serviceData.battery;
293
295
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
294
296
  this.debugLog(
295
297
  `${this.device.deviceType}: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName}, ` +
@@ -298,12 +300,12 @@ export class MeterPlus {
298
300
  );
299
301
 
300
302
  if (ad.serviceData) {
301
- this.connected = true;
302
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
303
+ this.BLE_IsConnected = true;
304
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
303
305
  await this.stopScanning(switchbot);
304
306
  } else {
305
- this.connected = false;
306
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
307
+ this.BLE_IsConnected = false;
308
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
307
309
  }
308
310
  };
309
311
  // Wait
@@ -337,10 +339,10 @@ export class MeterPlus {
337
339
  this.statusCode(statusCode);
338
340
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
339
341
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
340
- this.Humidity = deviceStatus.body.humidity!;
341
- this.Temperature = deviceStatus.body.temperature!;
342
- this.Battery = deviceStatus.body.battery;
343
- this.Version = deviceStatus.body.version;
342
+ this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity!;
343
+ this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature!;
344
+ this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
345
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
344
346
  this.openAPIparseStatus();
345
347
  this.updateHomeKitCharacteristics();
346
348
  } catch (e: any) {
@@ -422,6 +424,16 @@ export class MeterPlus {
422
424
  this.historyService?.addEntry(entry);
423
425
  }
424
426
  }
427
+ // FirmwareRevision
428
+ if (this.OpenAPI_FirmwareRevision === undefined) {
429
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
430
+ } else {
431
+ this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
432
+ this.accessory.getService(this.platform.Service.AccessoryInformation)!
433
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
434
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
435
+ + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
436
+ }
425
437
  }
426
438
 
427
439
  /*
@@ -475,7 +487,7 @@ export class MeterPlus {
475
487
 
476
488
  async stopScanning(switchbot: any) {
477
489
  await switchbot.stopScan();
478
- if (this.connected) {
490
+ if (this.BLE_IsConnected) {
479
491
  await this.BLEparseStatus();
480
492
  await this.updateHomeKitCharacteristics();
481
493
  } else {
@@ -25,22 +25,24 @@ export class Motion {
25
25
  StatusLowBattery!: CharacteristicValue;
26
26
 
27
27
  // OpenAPI Others
28
- Version: deviceStatus['version'];
29
- Battery: deviceStatus['battery'];
30
- moveDetected: deviceStatus['moveDetected'];
31
- brightness: deviceStatus['brightness'];
28
+ OpenAPI_BatteryLevel: deviceStatus['battery'];
29
+ OpenAPI_FirmwareRevision: deviceStatus['version'];
30
+ OpenAPI_MotionDetected: deviceStatus['moveDetected'];
31
+ OpenAPI_CurrentAmbientLightLevel: deviceStatus['brightness'];
32
+
33
+ // Status
34
+ BLE_BatteryLevel!: serviceData['battery'];
35
+ BLE_MotionDetected!: serviceData['movement'];
36
+ BLE_CurrentAmbientLightLevel!: serviceData['lightLevel'];
32
37
 
33
38
  // BLE Others
34
39
  scanning!: boolean;
35
- connected?: boolean;
36
- battery!: serviceData['battery'];
37
- movement!: serviceData['movement'];
38
- lightLevel!: serviceData['lightLevel'];
39
- is_light!: any; //serviceData['is_light'];
40
+ BLE_IsConnected?: boolean;
41
+ /*is_light!: any; //serviceData['is_light'];
40
42
  tested!: any;
41
43
  led!: any;
42
44
  iot!: any;
43
- sense_distance!: any;
45
+ sense_distance!: any;*/
44
46
 
45
47
  // Config
46
48
  set_minLux!: number;
@@ -163,7 +165,7 @@ export class Motion {
163
165
  async BLEparseStatus(): Promise<void> {
164
166
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
165
167
  // Movement
166
- this.MotionDetected = this.movement!;
168
+ this.MotionDetected = this.BLE_MotionDetected!;
167
169
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
168
170
  if (this.MotionDetected !== this.accessory.context.MotionDetected && this.MotionDetected) {
169
171
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Detected Motion`);
@@ -172,7 +174,7 @@ export class Motion {
172
174
  if (!this.device.motion?.hide_lightsensor) {
173
175
  this.set_minLux = this.minLux();
174
176
  this.set_maxLux = this.maxLux();
175
- switch (this.lightLevel) {
177
+ switch (this.BLE_CurrentAmbientLightLevel) {
176
178
  case 'dark':
177
179
  case 1:
178
180
  this.CurrentAmbientLightLevel = this.set_minLux;
@@ -181,7 +183,7 @@ export class Motion {
181
183
  this.CurrentAmbientLightLevel = this.set_maxLux;
182
184
  }
183
185
  this.debugLog(
184
- `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel},` +
186
+ `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.BLE_CurrentAmbientLightLevel},` +
185
187
  ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
186
188
  );
187
189
  if (this.CurrentAmbientLightLevel !== this.accessory.context.CurrentAmbientLightLevel) {
@@ -189,10 +191,10 @@ export class Motion {
189
191
  }
190
192
  }
191
193
  // Battery
192
- if (this.battery === undefined) {
193
- this.battery = 100;
194
+ if (this.BLE_BatteryLevel === undefined) {
195
+ this.BLE_BatteryLevel = 100;
194
196
  }
195
- this.BatteryLevel = this.battery!;
197
+ this.BatteryLevel = this.BLE_BatteryLevel!;
196
198
  if (this.BatteryLevel < 10) {
197
199
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
198
200
  } else {
@@ -206,13 +208,13 @@ export class Motion {
206
208
  async openAPIparseStatus(): Promise<void> {
207
209
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
208
210
  // Motion State
209
- this.MotionDetected = this.moveDetected!;
211
+ this.MotionDetected = this.OpenAPI_MotionDetected!;
210
212
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
211
213
  // Light Level
212
214
  if (!this.device.motion?.hide_lightsensor) {
213
215
  this.set_minLux = this.minLux();
214
216
  this.set_maxLux = this.maxLux();
215
- switch (this.brightness) {
217
+ switch (this.OpenAPI_CurrentAmbientLightLevel) {
216
218
  case 'dim':
217
219
  this.CurrentAmbientLightLevel = this.set_minLux;
218
220
  break;
@@ -223,10 +225,10 @@ export class Motion {
223
225
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
224
226
  }
225
227
  // Battery
226
- if (this.battery === undefined) {
227
- this.battery = 100;
228
+ if (this.OpenAPI_BatteryLevel === undefined) {
229
+ this.OpenAPI_BatteryLevel = 100;
228
230
  }
229
- this.BatteryLevel = this.Battery!;
231
+ this.BatteryLevel = this.OpenAPI_BatteryLevel!;
230
232
  if (this.BatteryLevel < 10) {
231
233
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
232
234
  } else {
@@ -286,9 +288,9 @@ export class Motion {
286
288
  `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
287
289
  ` BLE Address Found: ${ad.address}`,
288
290
  );
289
- this.movement = ad.serviceData.movement;
290
- this.battery = ad.serviceData.battery;
291
- this.lightLevel = ad.serviceData.lightLevel;
291
+ this.BLE_MotionDetected = ad.serviceData.movement;
292
+ this.BLE_BatteryLevel = ad.serviceData.battery;
293
+ this.BLE_CurrentAmbientLightLevel = ad.serviceData.lightLevel;
292
294
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
293
295
  this.debugLog(
294
296
  `${this.device.deviceType}: ${this.accessory.displayName} movement: ${ad.serviceData.movement},`
@@ -296,15 +298,15 @@ export class Motion {
296
298
  );
297
299
 
298
300
  if (ad.serviceData) {
299
- this.connected = true;
300
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
301
+ this.BLE_IsConnected = true;
302
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
301
303
  this.debugErrorLog('1');
302
304
  await this.stopScanning(switchbot);
303
305
  this.scanning = false;
304
306
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} scanning: ${this.scanning}`);
305
307
  } else {
306
- this.connected = false;
307
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
308
+ this.BLE_IsConnected = false;
309
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
308
310
  }
309
311
  };
310
312
  // Wait
@@ -346,10 +348,10 @@ export class Motion {
346
348
  this.statusCode(statusCode);
347
349
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
348
350
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
349
- this.moveDetected = deviceStatus.body.moveDetected;
350
- this.brightness = deviceStatus.body.brightness;
351
- this.Battery = deviceStatus.body.battery;
352
- this.Version = deviceStatus.body.version;
351
+ this.OpenAPI_MotionDetected = deviceStatus.body.moveDetected;
352
+ this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
353
+ this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
354
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
353
355
  this.openAPIparseStatus();
354
356
  this.updateHomeKitCharacteristics();
355
357
  } catch (e: any) {
@@ -398,11 +400,21 @@ export class Motion {
398
400
  );
399
401
  }
400
402
  }
403
+ // FirmwareRevision
404
+ if (this.OpenAPI_FirmwareRevision === undefined) {
405
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
406
+ } else {
407
+ this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
408
+ this.accessory.getService(this.platform.Service.AccessoryInformation)!
409
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
410
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
411
+ + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
412
+ }
401
413
  }
402
414
 
403
415
  async stopScanning(switchbot: any) {
404
416
  await switchbot.stopScan();
405
- if (this.connected) {
417
+ if (this.BLE_IsConnected) {
406
418
  await this.BLEparseStatus();
407
419
  await this.updateHomeKitCharacteristics();
408
420
  } else {
@@ -15,18 +15,12 @@ export class Plug {
15
15
  On!: CharacteristicValue;
16
16
 
17
17
  // OpenAPI Others
18
- Version: deviceStatus['version'];
19
- power: deviceStatus['power'];
18
+ OpenAPI_On: deviceStatus['power'];
19
+ OpenAPI_FirmwareRevision: deviceStatus['version'];
20
20
 
21
21
  // BLE Others
22
- connected?: boolean;
23
- state: serviceData['state'];
24
- delay: serviceData['delay'];
25
- timer: serviceData['timer'];
26
- wifiRssi: serviceData['wifiRssi'];
27
- overload: serviceData['overload'];
28
- syncUtcTime: serviceData['syncUtcTime'];
29
- currentPower: serviceData['currentPower'];
22
+ BLE_IsConnected?: boolean;
23
+ BLE_On: serviceData['state'];
30
24
 
31
25
  // Config
32
26
  scanDuration!: number;
@@ -145,7 +139,7 @@ export class Plug {
145
139
  async BLEparseStatus(): Promise<void> {
146
140
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
147
141
  // State
148
- switch (this.state) {
142
+ switch (this.BLE_On) {
149
143
  case 'on':
150
144
  this.On = true;
151
145
  break;
@@ -157,7 +151,7 @@ export class Plug {
157
151
 
158
152
  async openAPIparseStatus() {
159
153
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
160
- switch (this.power) {
154
+ switch (this.OpenAPI_On) {
161
155
  case 'on':
162
156
  this.On = true;
163
157
  break;
@@ -210,13 +204,7 @@ export class Plug {
210
204
  `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
211
205
  ` BLE Address Found: ${ad.address}`,
212
206
  );
213
- this.state = ad.serviceData.state;
214
- this.delay = ad.serviceData.delay;
215
- this.timer = ad.serviceData.timer;
216
- this.syncUtcTime = ad.serviceData.syncUtcTime;
217
- this.wifiRssi = ad.serviceData.wifiRssi;
218
- this.overload = ad.serviceData.overload;
219
- this.currentPower = ad.serviceData.currentPower;
207
+ this.BLE_On = ad.serviceData.state;
220
208
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
221
209
  this.debugLog(
222
210
  `${this.device.deviceType}: ${this.accessory.displayName} state: ${ad.serviceData.state}, ` +
@@ -225,12 +213,12 @@ export class Plug {
225
213
  );
226
214
 
227
215
  if (ad.serviceData) {
228
- this.connected = true;
229
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
216
+ this.BLE_IsConnected = true;
217
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
230
218
  await this.stopScanning(switchbot);
231
219
  } else {
232
- this.connected = false;
233
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
220
+ this.BLE_IsConnected = false;
221
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
234
222
  }
235
223
  };
236
224
  // Wait
@@ -264,7 +252,7 @@ export class Plug {
264
252
  this.statusCode(statusCode);
265
253
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
266
254
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
267
- this.power = deviceStatus.body.power;
255
+ this.OpenAPI_On = deviceStatus.body.power;
268
256
  this.openAPIparseStatus();
269
257
  this.updateHomeKitCharacteristics();
270
258
  } catch (e: any) {
@@ -419,11 +407,21 @@ export class Plug {
419
407
  this.outletService.updateCharacteristic(this.platform.Characteristic.On, this.On);
420
408
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
421
409
  }
410
+ // FirmwareRevision
411
+ if (this.OpenAPI_FirmwareRevision === undefined) {
412
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
413
+ } else {
414
+ this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
415
+ this.accessory.getService(this.platform.Service.AccessoryInformation)!
416
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
417
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
418
+ + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
419
+ }
422
420
  }
423
421
 
424
422
  async stopScanning(switchbot: any) {
425
423
  await switchbot.stopScan();
426
- if (this.connected) {
424
+ if (this.BLE_IsConnected) {
427
425
  await this.BLEparseStatus();
428
426
  await this.updateHomeKitCharacteristics();
429
427
  } else {
@@ -10,8 +10,8 @@ import { device, devicesConfig, deviceStatus, ad, serviceData, Devices } from '.
10
10
 
11
11
  export class RobotVacuumCleaner {
12
12
  // Services
13
- robotVacuumCleanerService: Service;
14
13
  batteryService: Service;
14
+ robotVacuumCleanerService: Service;
15
15
 
16
16
  // Characteristic Values
17
17
  On!: CharacteristicValue;
@@ -19,14 +19,16 @@ export class RobotVacuumCleaner {
19
19
  BatteryLevel!: CharacteristicValue;
20
20
  StatusLowBattery!: CharacteristicValue;
21
21
 
22
- // OpenAPI Others
23
- Version: deviceStatus['version'];
24
- Battery: deviceStatus['battery'];
25
- power: deviceStatus['power'];
22
+ // OpenAPI Status
23
+ OpenAPI_On: deviceStatus['power'];
24
+ OpenAPI_BatteryLevel: deviceStatus['battery'];
25
+ OpenAPI_FirmwareRevision: deviceStatus['version'];
26
+
27
+ // BLE Status
28
+ BLE_On: serviceData['state'];
26
29
 
27
30
  // BLE Others
28
- connected?: boolean;
29
- state: serviceData['state'];
31
+ BLE_IsConnected?: boolean;
30
32
 
31
33
  // Config
32
34
  scanDuration!: number;
@@ -174,7 +176,7 @@ export class RobotVacuumCleaner {
174
176
  async BLEparseStatus(): Promise<void> {
175
177
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
176
178
  // State
177
- switch (this.state) {
179
+ switch (this.BLE_On) {
178
180
  case 'on':
179
181
  this.On = true;
180
182
  break;
@@ -186,7 +188,7 @@ export class RobotVacuumCleaner {
186
188
 
187
189
  async openAPIparseStatus() {
188
190
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
189
- switch (this.power) {
191
+ switch (this.OpenAPI_On) {
190
192
  case 'on':
191
193
  this.On = true;
192
194
  break;
@@ -196,7 +198,7 @@ export class RobotVacuumCleaner {
196
198
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
197
199
 
198
200
  // Battery
199
- this.BatteryLevel = Number(this.Battery);
201
+ this.BatteryLevel = Number(this.OpenAPI_BatteryLevel);
200
202
  if (this.BatteryLevel < 15) {
201
203
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
202
204
  } else {
@@ -248,7 +250,7 @@ export class RobotVacuumCleaner {
248
250
  `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
249
251
  ` BLE Address Found: ${ad.address}`,
250
252
  );
251
- this.state = ad.serviceData.state;
253
+ this.BLE_On = ad.serviceData.state;
252
254
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
253
255
  this.debugLog(
254
256
  `${this.device.deviceType}: ${this.accessory.displayName} state: ${ad.serviceData.state}, ` +
@@ -257,12 +259,12 @@ export class RobotVacuumCleaner {
257
259
  );
258
260
 
259
261
  if (ad.serviceData) {
260
- this.connected = true;
261
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
262
+ this.BLE_IsConnected = true;
263
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
262
264
  await this.stopScanning(switchbot);
263
265
  } else {
264
- this.connected = false;
265
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
266
+ this.BLE_IsConnected = false;
267
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.BLE_IsConnected}`);
266
268
  }
267
269
  };
268
270
  // Wait
@@ -296,9 +298,9 @@ export class RobotVacuumCleaner {
296
298
  this.statusCode(statusCode);
297
299
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
298
300
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
299
- this.power = deviceStatus.body.power;
300
- this.Battery = deviceStatus.body.battery;
301
- this.Version = deviceStatus.body.version;
301
+ this.OpenAPI_On = deviceStatus.body.power;
302
+ this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
303
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
302
304
  this.openAPIparseStatus();
303
305
  this.updateHomeKitCharacteristics();
304
306
  } catch (e: any) {
@@ -556,11 +558,21 @@ export class RobotVacuumCleaner {
556
558
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
557
559
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
558
560
  }
561
+ // FirmwareRevision
562
+ if (this.OpenAPI_FirmwareRevision === undefined) {
563
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
564
+ } else {
565
+ this.accessory.context.OpenAPI_FirmwareRevision = this.OpenAPI_FirmwareRevision;
566
+ this.accessory.getService(this.platform.Service.AccessoryInformation)!
567
+ .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
568
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
569
+ + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
570
+ }
559
571
  }
560
572
 
561
573
  async stopScanning(switchbot: any) {
562
574
  await switchbot.stopScan();
563
- if (this.connected) {
575
+ if (this.BLE_IsConnected) {
564
576
  await this.BLEparseStatus();
565
577
  await this.updateHomeKitCharacteristics();
566
578
  } else {
@@ -16,10 +16,10 @@ export class AirConditioner {
16
16
  Active!: CharacteristicValue;
17
17
  RotationSpeed!: CharacteristicValue;
18
18
  CurrentTemperature!: CharacteristicValue;
19
+ ThresholdTemperature!: CharacteristicValue;
19
20
  CurrentRelativeHumidity?: CharacteristicValue;
20
21
  TargetHeaterCoolerState!: CharacteristicValue;
21
22
  CurrentHeaterCoolerState!: CharacteristicValue;
22
- ThresholdTemperature!: CharacteristicValue;
23
23
 
24
24
  // Others
25
25
  state!: string;
@@ -33,12 +33,12 @@ export class AirConditioner {
33
33
  static MODE_HEAT: number;
34
34
 
35
35
  // Config
36
- disablePushOn?: boolean;
37
- disablePushOff?: boolean;
38
- disablePushDetail?: boolean;
39
36
  deviceLogging!: string;
40
37
  hide_automode?: boolean;
38
+ disablePushOn?: boolean;
39
+ disablePushOff?: boolean;
41
40
  meter?: PlatformAccessory;
41
+ disablePushDetail?: boolean;
42
42
 
43
43
  private readonly valid12 = [1, 2];
44
44
  private readonly valid012 = [0, 1, 2];
@@ -16,9 +16,9 @@ export class Camera {
16
16
  On!: CharacteristicValue;
17
17
 
18
18
  // Config
19
+ deviceLogging!: string;
19
20
  disablePushOn?: boolean;
20
21
  disablePushOff?: boolean;
21
- deviceLogging!: string;
22
22
 
23
23
  constructor(
24
24
  private readonly platform: SwitchBotPlatform,
@@ -14,18 +14,18 @@ export class Fan {
14
14
 
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
17
- ActiveIdentifier!: CharacteristicValue;
18
- RotationSpeed!: CharacteristicValue;
19
17
  SwingMode!: CharacteristicValue;
18
+ RotationSpeed!: CharacteristicValue;
19
+ ActiveIdentifier!: CharacteristicValue;
20
20
  RotationDirection!: CharacteristicValue;
21
21
 
22
22
  // Config
23
23
  minStep?: number;
24
24
  minValue?: number;
25
25
  maxValue?: number;
26
+ deviceLogging!: string;
26
27
  disablePushOn?: boolean;
27
28
  disablePushOff?: boolean;
28
- deviceLogging!: string;
29
29
 
30
30
  constructor(
31
31
  private readonly platform: SwitchBotPlatform,
@@ -16,9 +16,9 @@ export class Light {
16
16
  On!: CharacteristicValue;
17
17
 
18
18
  // Config
19
+ deviceLogging!: string;
19
20
  disablePushOn?: boolean;
20
21
  disablePushOff?: boolean;
21
- deviceLogging!: string;
22
22
 
23
23
  constructor(
24
24
  private readonly platform: SwitchBotPlatform,
@@ -16,10 +16,10 @@ export class Others {
16
16
  Active!: CharacteristicValue;
17
17
 
18
18
  // Config
19
- disablePushOn?: boolean;
20
- disablePushOff?: boolean;
21
19
  deviceLogging!: string;
20
+ disablePushOn?: boolean;
22
21
  otherDeviceType?: string;
22
+ disablePushOff?: boolean;
23
23
 
24
24
  constructor(
25
25
  private readonly platform: SwitchBotPlatform,
@@ -18,10 +18,10 @@ export class TV {
18
18
  ActiveIdentifier!: CharacteristicValue;
19
19
 
20
20
  // Config
21
+ deviceLogging!: string;
21
22
  disablePushOn?: boolean;
22
23
  disablePushOff?: boolean;
23
24
  disablePushDetail?: boolean;
24
- deviceLogging!: string;
25
25
 
26
26
  constructor(
27
27
  private readonly platform: SwitchBotPlatform,