@switchbot/homebridge-switchbot 1.4.1-beta.4 → 1.5.0

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 (88) hide show
  1. package/.github/FUNDING.yml +4 -0
  2. package/CHANGELOG.md +3 -3
  3. package/dist/devices/bots.d.ts +1 -1
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +17 -17
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts +1 -1
  8. package/dist/devices/colorbulb.d.ts.map +1 -1
  9. package/dist/devices/colorbulb.js +13 -8
  10. package/dist/devices/colorbulb.js.map +1 -1
  11. package/dist/devices/contact.d.ts +1 -1
  12. package/dist/devices/contact.d.ts.map +1 -1
  13. package/dist/devices/contact.js +15 -4
  14. package/dist/devices/contact.js.map +1 -1
  15. package/dist/devices/curtains.d.ts +1 -1
  16. package/dist/devices/curtains.d.ts.map +1 -1
  17. package/dist/devices/curtains.js +17 -7
  18. package/dist/devices/curtains.js.map +1 -1
  19. package/dist/devices/humidifiers.d.ts +1 -1
  20. package/dist/devices/humidifiers.d.ts.map +1 -1
  21. package/dist/devices/humidifiers.js +20 -9
  22. package/dist/devices/humidifiers.js.map +1 -1
  23. package/dist/devices/meters.d.ts +1 -1
  24. package/dist/devices/meters.d.ts.map +1 -1
  25. package/dist/devices/meters.js +12 -4
  26. package/dist/devices/meters.js.map +1 -1
  27. package/dist/devices/motion.d.ts +1 -1
  28. package/dist/devices/motion.d.ts.map +1 -1
  29. package/dist/devices/motion.js +10 -4
  30. package/dist/devices/motion.js.map +1 -1
  31. package/dist/devices/plugs.d.ts +1 -1
  32. package/dist/devices/plugs.d.ts.map +1 -1
  33. package/dist/devices/plugs.js +5 -4
  34. package/dist/devices/plugs.js.map +1 -1
  35. package/dist/irdevices/airconditioners.d.ts +30 -15
  36. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  37. package/dist/irdevices/airconditioners.js +308 -165
  38. package/dist/irdevices/airconditioners.js.map +1 -1
  39. package/dist/irdevices/airpurifiers.d.ts +1 -1
  40. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  41. package/dist/irdevices/airpurifiers.js +7 -3
  42. package/dist/irdevices/airpurifiers.js.map +1 -1
  43. package/dist/irdevices/cameras.d.ts +1 -1
  44. package/dist/irdevices/cameras.d.ts.map +1 -1
  45. package/dist/irdevices/cameras.js +4 -3
  46. package/dist/irdevices/cameras.js.map +1 -1
  47. package/dist/irdevices/fans.d.ts +1 -1
  48. package/dist/irdevices/fans.d.ts.map +1 -1
  49. package/dist/irdevices/fans.js +6 -3
  50. package/dist/irdevices/fans.js.map +1 -1
  51. package/dist/irdevices/lights.d.ts +1 -1
  52. package/dist/irdevices/lights.d.ts.map +1 -1
  53. package/dist/irdevices/lights.js +4 -3
  54. package/dist/irdevices/lights.js.map +1 -1
  55. package/dist/irdevices/others.d.ts +1 -1
  56. package/dist/irdevices/others.d.ts.map +1 -1
  57. package/dist/irdevices/others.js +4 -3
  58. package/dist/irdevices/others.js.map +1 -1
  59. package/dist/irdevices/tvs.d.ts +1 -1
  60. package/dist/irdevices/tvs.d.ts.map +1 -1
  61. package/dist/irdevices/tvs.js +5 -3
  62. package/dist/irdevices/tvs.js.map +1 -1
  63. package/dist/irdevices/vacuumcleaners.d.ts +1 -1
  64. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  65. package/dist/irdevices/vacuumcleaners.js +4 -3
  66. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  67. package/dist/irdevices/waterheaters.d.ts +1 -1
  68. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  69. package/dist/irdevices/waterheaters.js +4 -3
  70. package/dist/irdevices/waterheaters.js.map +1 -1
  71. package/package.json +68 -68
  72. package/src/devices/bots.ts +17 -18
  73. package/src/devices/colorbulb.ts +14 -9
  74. package/src/devices/contact.ts +16 -5
  75. package/src/devices/curtains.ts +17 -7
  76. package/src/devices/humidifiers.ts +21 -10
  77. package/src/devices/meters.ts +13 -5
  78. package/src/devices/motion.ts +11 -5
  79. package/src/devices/plugs.ts +6 -5
  80. package/src/irdevices/airconditioners.ts +309 -165
  81. package/src/irdevices/airpurifiers.ts +8 -4
  82. package/src/irdevices/cameras.ts +5 -4
  83. package/src/irdevices/fans.ts +7 -4
  84. package/src/irdevices/lights.ts +5 -4
  85. package/src/irdevices/others.ts +4 -3
  86. package/src/irdevices/tvs.ts +6 -4
  87. package/src/irdevices/vacuumcleaners.ts +5 -4
  88. package/src/irdevices/waterheaters.ts +5 -4
@@ -126,7 +126,7 @@ class WaterHeater {
126
126
  this.errorLog(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
127
127
  + ` Error: ${JSON.stringify(e)}`);
128
128
  }
129
- this.apiError();
129
+ this.apiError(e);
130
130
  }
131
131
  }
132
132
  statusCode(push) {
@@ -157,8 +157,9 @@ class WaterHeater {
157
157
  this.debugLog(`Water Heater: ${this.accessory.displayName} Unknown statusCode.`);
158
158
  }
159
159
  }
160
- apiError() {
161
- throw new this.platform.api.hap.HapStatusError(-70402 /* SERVICE_COMMUNICATION_FAILURE */);
160
+ apiError(e) {
161
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
162
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
162
163
  }
163
164
  /**
164
165
  * Logging for Device
@@ -1 +1 @@
1
- {"version":3,"file":"waterheaters.js","sourceRoot":"","sources":["../../src/irdevices/waterheaters.ts"],"names":[],"mappings":";;;AAEA,0CAA4E;AAG5E;;;;GAIG;AACH,MAAa,WAAW;IAWtB,YACmB,QAA2B,EACpC,SAA4B,EAC7B,MAAkC;QAFxB,aAAQ,GAAR,QAAQ,CAAmB;QACpC,cAAS,GAAT,SAAS,CAAmB;QAC7B,WAAM,GAAN,MAAM,CAA4B;QAEzC,uBAAuB;QACvB,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,IAAI,C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G,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;aACzC;SACF;IACH,CAAC;IAED,qBAAqB;QACnB,OAAO,IAAI,CAAC,aAAa,KAAK,OAAO,IAAI,IAAI,CAAC,aAAa,KAAK,UAAU,CAAC;IAC7E,CAAC;CACF;AA1ND,kCA0NC"}
package/package.json CHANGED
@@ -1,72 +1,72 @@
1
1
  {
2
- "displayName": "Homebridge SwitchBot",
3
- "name": "@switchbot/homebridge-switchbot",
4
- "version": "1.4.1-beta.4",
5
- "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
- "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
- "license": "ISC",
8
- "repository": {
9
- "type": "git",
10
- "url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
2
+ "displayName": "Homebridge SwitchBot",
3
+ "name": "@switchbot/homebridge-switchbot",
4
+ "version": "1.5.0",
5
+ "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
+ "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
+ "license": "ISC",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
14
+ },
15
+ "engines": {
16
+ "homebridge": "^1.3.8",
17
+ "node": "^14.18.2 || ^16.13.1"
18
+ },
19
+ "main": "dist/index.js",
20
+ "scripts": {
21
+ "check": "npm install && npm outdated",
22
+ "update": "ncu -u && npm update && npm install",
23
+ "lint": "eslint src/**.ts",
24
+ "watch": "npm run build && npm link && nodemon",
25
+ "build": "rimraf ./dist && tsc",
26
+ "prepublishOnly": "npm run lint && npm run build"
27
+ },
28
+ "funding": [
29
+ {
30
+ "type": "Paypal",
31
+ "url": "https://paypal.me/donavanbecker"
11
32
  },
12
- "bugs": {
13
- "url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
14
- },
15
- "engines": {
16
- "homebridge": "^1.3.8",
17
- "node": "^14.18.2 || ^16.13.1"
18
- },
19
- "main": "dist/index.js",
20
- "scripts": {
21
- "check": "npm install && npm outdated",
22
- "update": "ncu -u && npm update && npm install",
23
- "lint": "eslint src/**.ts",
24
- "watch": "npm run build && npm link && nodemon",
25
- "build": "rimraf ./dist && tsc",
26
- "prepublishOnly": "npm run lint && npm run build"
27
- },
28
- "funding": [
29
- {
30
- "type": "Paypal",
31
- "url": "https://paypal.me/donavanbecker"
32
- },
33
- {
34
- "type": "GitHub",
35
- "url": "https://github.com/sponsors/donavanbecker"
36
- }
37
- ],
38
- "publishConfig": {
39
- "access": "public"
40
- },
41
- "keywords": [
42
- "homebridge-plugin",
43
- "switchbot",
44
- "humidifier",
45
- "humidity",
46
- "temperature",
47
- "bot",
48
- "curtains",
49
- "windows",
50
- "ble",
51
- "ir"
52
- ],
53
- "dependencies": {
54
- "@homebridge/plugin-ui-utils": "^0.0.19",
55
- "axios": "^0.24.0",
56
- "node-switchbot": "^1.1.2",
57
- "rxjs": "^7.4.0"
58
- },
59
- "devDependencies": {
60
- "@types/node": "^17.0.4",
61
- "@typescript-eslint/eslint-plugin": "^5.8.0",
62
- "@typescript-eslint/parser": "^5.8.0",
63
- "eslint": "^8.5.0",
64
- "homebridge": "^1.3.8",
65
- "nodemon": "^2.0.15",
66
- "npm-check-updates": "^12.0.5",
67
- "rimraf": "^3.0.2",
68
- "ts-node": "^10.4.0",
69
- "typescript": "^4.5.4",
70
- "typescript-axios-wb": "^1.0.3"
33
+ {
34
+ "type": "GitHub",
35
+ "url": "https://github.com/sponsors/donavanbecker"
71
36
  }
37
+ ],
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "keywords": [
42
+ "homebridge-plugin",
43
+ "switchbot",
44
+ "humidifier",
45
+ "humidity",
46
+ "temperature",
47
+ "bot",
48
+ "curtains",
49
+ "windows",
50
+ "ble",
51
+ "ir"
52
+ ],
53
+ "dependencies": {
54
+ "@homebridge/plugin-ui-utils": "^0.0.19",
55
+ "axios": "^0.24.0",
56
+ "node-switchbot": "^1.1.2",
57
+ "rxjs": "^7.4.0"
58
+ },
59
+ "devDependencies": {
60
+ "@types/node": "^17.0.5",
61
+ "@typescript-eslint/eslint-plugin": "^5.8.0",
62
+ "@typescript-eslint/parser": "^5.8.0",
63
+ "eslint": "^8.5.0",
64
+ "homebridge": "^1.3.8",
65
+ "nodemon": "^2.0.15",
66
+ "npm-check-updates": "^12.0.5",
67
+ "rimraf": "^3.0.2",
68
+ "ts-node": "^10.4.0",
69
+ "typescript": "^4.5.4",
70
+ "typescript-axios-wb": "^1.0.3"
71
+ }
72
72
  }
@@ -4,7 +4,7 @@ import Switchbot from 'node-switchbot';
4
4
  import { interval, Subject } from 'rxjs';
5
5
  import { SwitchBotPlatform } from '../platform';
6
6
  import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
7
- import { Service, PlatformAccessory, CharacteristicValue, HAPStatus } from 'homebridge';
7
+ import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
8
8
  import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceStatusResponse, payload } from '../settings';
9
9
 
10
10
  /**
@@ -323,7 +323,7 @@ export class Bot {
323
323
  this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
324
324
  await this.openAPIRefreshStatus();
325
325
  }
326
- this.apiError();
326
+ this.apiError(e);
327
327
  });
328
328
  }
329
329
 
@@ -333,16 +333,6 @@ export class Bot {
333
333
  try {
334
334
  this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
335
335
  this.debugLog(`Bot: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
336
- /*this.deviceStatus = {
337
- statusCode: 100,
338
- body: {
339
- deviceId: this.device.deviceId!,
340
- deviceType: this.device.deviceType!,
341
- hubDeviceId: this.device.hubDeviceId,
342
- power: 'on',
343
- },
344
- message: 'success',
345
- };*/
346
336
  this.parseStatus();
347
337
  this.updateHomeKitCharacteristics();
348
338
  } catch (e: any) {
@@ -355,7 +345,7 @@ export class Bot {
355
345
  this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
356
346
  + ` Error: ${JSON.stringify(e)}`);
357
347
  }
358
- this.apiError();
348
+ this.apiError(e);
359
349
  }
360
350
  }
361
351
  }
@@ -407,7 +397,7 @@ export class Bot {
407
397
  this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
408
398
  await this.openAPIpushChanges();
409
399
  }
410
- this.apiError();
400
+ this.apiError(e);
411
401
  });
412
402
  } else if (this.device.bot?.mode === 'switch') {
413
403
  this.debugLog(`Bot: ${this.accessory.displayName} Press Mode: ${this.device.bot?.mode}`);
@@ -430,7 +420,7 @@ export class Bot {
430
420
  this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
431
421
  await this.openAPIpushChanges();
432
422
  }
433
- this.apiError();
423
+ this.apiError(e);
434
424
  });
435
425
  } else {
436
426
  this.errorLog(`Bot: ${this.accessory.displayName} Mode Not Set, mode: ${this.device.bot?.mode}`);
@@ -494,7 +484,7 @@ export class Bot {
494
484
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
495
485
  + ` Error: ${JSON.stringify(e)}`);
496
486
  }
497
- this.apiError();
487
+ this.apiError(e);
498
488
  }
499
489
  }
500
490
  }
@@ -529,8 +519,17 @@ export class Bot {
529
519
  }
530
520
  }
531
521
 
532
- public apiError() {
533
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
522
+ public apiError(e: any) {
523
+ if (this.device.bot?.deviceType === 'switch') {
524
+ this.switchService?.updateCharacteristic(this.platform.Characteristic.On, e);
525
+ } else {
526
+ this.outletService?.updateCharacteristic(this.platform.Characteristic.On, e);
527
+ }
528
+ if (this.device.ble) {
529
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
530
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
531
+ }
532
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
534
533
  }
535
534
 
536
535
  private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
@@ -2,7 +2,7 @@ import { AxiosResponse } from 'axios';
2
2
  import { interval, Subject } from 'rxjs';
3
3
  import { SwitchBotPlatform } from '../platform';
4
4
  import { debounceTime, skipWhile, tap } from 'rxjs/operators';
5
- import { Service, PlatformAccessory, CharacteristicValue, ControllerConstructor, Controller, ControllerServiceMap, HAPStatus } from 'homebridge';
5
+ import { Service, PlatformAccessory, CharacteristicValue, ControllerConstructor, Controller, ControllerServiceMap } from 'homebridge';
6
6
  import { DeviceURL, device, devicesConfig, switchbot, deviceStatusResponse, payload, hs2rgb, rgb2hs, m2hs } from '../settings';
7
7
 
8
8
  /**
@@ -191,7 +191,7 @@ export class ColorBulb {
191
191
  this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges,`
192
192
  + ` Error: ${JSON.stringify(e)}`);
193
193
  }
194
- this.apiError();
194
+ this.apiError(e);
195
195
  }
196
196
  this.colorBulbUpdateInProgress = false;
197
197
  });
@@ -301,7 +301,7 @@ export class ColorBulb {
301
301
  this.errorLog(`Color Bulb: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
302
302
  + ` Error: ${JSON.stringify(e)}`);
303
303
  }
304
- this.apiError();
304
+ this.apiError(e);
305
305
  }
306
306
  }
307
307
 
@@ -365,7 +365,7 @@ export class ColorBulb {
365
365
  this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
366
366
  + ` Error: ${JSON.stringify(e)}`);
367
367
  }
368
- this.apiError();
368
+ this.apiError(e);
369
369
  }
370
370
  }
371
371
 
@@ -407,7 +407,7 @@ export class ColorBulb {
407
407
  this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
408
408
  + ` Error: ${JSON.stringify(e)}`);
409
409
  }
410
- this.apiError();
410
+ this.apiError(e);
411
411
  }
412
412
  }
413
413
 
@@ -445,7 +445,7 @@ export class ColorBulb {
445
445
  this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
446
446
  + ` Error: ${JSON.stringify(e)}`);
447
447
  }
448
- this.apiError();
448
+ this.apiError(e);
449
449
  }
450
450
  }
451
451
 
@@ -480,7 +480,7 @@ export class ColorBulb {
480
480
  this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
481
481
  + ` Error: ${JSON.stringify(e)}`);
482
482
  }
483
- this.apiError();
483
+ this.apiError(e);
484
484
  }
485
485
  }
486
486
 
@@ -517,8 +517,13 @@ export class ColorBulb {
517
517
  }
518
518
  }
519
519
 
520
- public apiError() {
521
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
520
+ public apiError(e: any) {
521
+ this.service.updateCharacteristic(this.platform.Characteristic.On, e);
522
+ this.service.updateCharacteristic(this.platform.Characteristic.Hue, e);
523
+ this.service.updateCharacteristic(this.platform.Characteristic.Brightness, e);
524
+ this.service.updateCharacteristic(this.platform.Characteristic.Saturation, e);
525
+ this.service.updateCharacteristic(this.platform.Characteristic.ColorTemperature, e);
526
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
522
527
  }
523
528
 
524
529
  private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
@@ -2,7 +2,7 @@ import Switchbot from 'node-switchbot';
2
2
  import { interval, Subject } from 'rxjs';
3
3
  import { skipWhile } from 'rxjs/operators';
4
4
  import { SwitchBotPlatform } from '../platform';
5
- import { Service, PlatformAccessory, CharacteristicValue, HAPStatus } from 'homebridge';
5
+ import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
6
6
  import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings';
7
7
 
8
8
  /**
@@ -322,7 +322,7 @@ export class Contact {
322
322
  this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
323
323
  await this.openAPIRefreshStatus();
324
324
  }
325
- this.apiError();
325
+ this.apiError(e);
326
326
  });
327
327
  }
328
328
 
@@ -344,7 +344,7 @@ export class Contact {
344
344
  this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
345
345
  + ` Error: ${JSON.stringify(e)}`);
346
346
  }
347
- this.apiError();
347
+ this.apiError(e);
348
348
  }
349
349
  }
350
350
  }
@@ -392,8 +392,19 @@ export class Contact {
392
392
  }
393
393
  }
394
394
 
395
- public apiError() {
396
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
395
+ public apiError(e: any) {
396
+ this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, e);
397
+ if (!this.device.contact?.hide_motionsensor) {
398
+ this.motionService?.updateCharacteristic(this.platform.Characteristic.MotionDetected, e);
399
+ }
400
+ if (!this.device.contact?.hide_lightsensor) {
401
+ this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
402
+ }
403
+ if (this.device.ble) {
404
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
405
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
406
+ }
407
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
397
408
  }
398
409
 
399
410
  /**
@@ -186,7 +186,7 @@ export class Curtain {
186
186
  this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges,`
187
187
  + ` Error: ${JSON.stringify(e)}`);
188
188
  }
189
- this.apiError();
189
+ this.apiError(e);
190
190
  }
191
191
  this.curtainUpdateInProgress = false;
192
192
  });
@@ -490,7 +490,7 @@ export class Curtain {
490
490
  this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
491
491
  await this.openAPIRefreshStatus();
492
492
  }
493
- this.apiError();
493
+ this.apiError(e);
494
494
  });
495
495
  }
496
496
 
@@ -512,7 +512,7 @@ export class Curtain {
512
512
  this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
513
513
  + ` Error: ${JSON.stringify(e)}`);
514
514
  }
515
- this.apiError();
515
+ this.apiError(e);
516
516
  }
517
517
  }
518
518
  }
@@ -554,7 +554,7 @@ export class Curtain {
554
554
  this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
555
555
  await this.OpenAPIpushChanges();
556
556
  }
557
- this.apiError();
557
+ this.apiError(e);
558
558
  });
559
559
  } else {
560
560
  this.debugLog(`Curtain: ${this.accessory.displayName} No BLE Changes, CurrentPosition & TargetPosition Are the Same.`
@@ -596,7 +596,7 @@ export class Curtain {
596
596
  this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
597
597
  + ` Error: ${JSON.stringify(e)}`);
598
598
  }
599
- this.apiError();
599
+ this.apiError(e);
600
600
  }
601
601
  }
602
602
  }
@@ -645,8 +645,18 @@ export class Curtain {
645
645
  }
646
646
  }
647
647
 
648
- public apiError() {
649
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
648
+ public apiError(e: any) {
649
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
650
+ this.service.updateCharacteristic(this.platform.Characteristic.PositionState, e);
651
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
652
+ if (!this.device.curtain?.hide_lightsensor) {
653
+ this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
654
+ }
655
+ if (this.device.ble) {
656
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
657
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
658
+ }
659
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
650
660
  }
651
661
 
652
662
  private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
@@ -3,7 +3,7 @@ import Switchbot from 'node-switchbot';
3
3
  import { interval, Subject } from 'rxjs';
4
4
  import { SwitchBotPlatform } from '../platform';
5
5
  import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
6
- import { Service, PlatformAccessory, CharacteristicValue, HAPStatus } from 'homebridge';
6
+ import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
7
7
  import { DeviceURL, device, devicesConfig, serviceData, ad, deviceStatusResponse, payload } from '../settings';
8
8
 
9
9
  /**
@@ -184,7 +184,7 @@ export class Humidifier {
184
184
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,`
185
185
  + ` Error: ${JSON.stringify(e)}`);
186
186
  }
187
- this.apiError();
187
+ this.apiError(e);
188
188
  }
189
189
  this.humidifierUpdateInProgress = false;
190
190
  });
@@ -387,7 +387,7 @@ export class Humidifier {
387
387
  this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
388
388
  await this.openAPIRefreshStatus();
389
389
  }
390
- this.apiError();
390
+ this.apiError(e);
391
391
  });
392
392
  }
393
393
 
@@ -413,7 +413,7 @@ export class Humidifier {
413
413
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
414
414
  + ` Error: ${JSON.stringify(e)}`);
415
415
  }
416
- this.apiError();
416
+ this.apiError(e);
417
417
  }
418
418
  }
419
419
  }
@@ -457,7 +457,7 @@ export class Humidifier {
457
457
  this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
458
458
  await this.OpenAPIpushChanges();
459
459
  }
460
- this.apiError();
460
+ this.apiError(e);
461
461
  });
462
462
  }
463
463
 
@@ -494,7 +494,7 @@ export class Humidifier {
494
494
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
495
495
  + ` Error: ${JSON.stringify(e)}`);
496
496
  }
497
- this.apiError();
497
+ this.apiError(e);
498
498
  }
499
499
  } else if (
500
500
  this.TargetHumidifierDehumidifierState ===
@@ -543,7 +543,7 @@ export class Humidifier {
543
543
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,`
544
544
  + ` Error: ${JSON.stringify(e)}`);
545
545
  }
546
- this.apiError();
546
+ this.apiError(e);
547
547
  }
548
548
  }
549
549
 
@@ -578,7 +578,7 @@ export class Humidifier {
578
578
  this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,`
579
579
  + ` Error: ${JSON.stringify(e)}`);
580
580
  }
581
- this.apiError();
581
+ this.apiError(e);
582
582
  }
583
583
  }
584
584
 
@@ -639,8 +639,19 @@ export class Humidifier {
639
639
  }
640
640
  }
641
641
 
642
- public apiError() {
643
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
642
+ public apiError(e: any) {
643
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
644
+ if (!this.device.ble) {
645
+ this.service.updateCharacteristic(this.platform.Characteristic.WaterLevel, e);
646
+ }
647
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, e);
648
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, e);
649
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
650
+ this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, e);
651
+ if (!this.device.humidifier?.hide_temperature && !this.device.ble) {
652
+ this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
653
+ }
654
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
644
655
  }
645
656
 
646
657
  private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
@@ -2,7 +2,7 @@ import Switchbot from 'node-switchbot';
2
2
  import { interval, Subject } from 'rxjs';
3
3
  import { skipWhile } from 'rxjs/operators';
4
4
  import { SwitchBotPlatform } from '../platform';
5
- import { Service, PlatformAccessory, Units, CharacteristicValue, HAPStatus } from 'homebridge';
5
+ import { Service, PlatformAccessory, Units, CharacteristicValue } from 'homebridge';
6
6
  import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceStatusResponse, temperature } from '../settings';
7
7
 
8
8
  /**
@@ -358,7 +358,7 @@ export class Meter {
358
358
  this.warnLog(`Meter: ${this.accessory.displayName} Using OpenAPI Connection`);
359
359
  this.openAPIRefreshStatus();
360
360
  }
361
- this.apiError();
361
+ this.apiError(e);
362
362
  });
363
363
  }
364
364
 
@@ -386,7 +386,7 @@ export class Meter {
386
386
  this.errorLog(`Meter: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
387
387
  + ` Error: ${JSON.stringify(e)}`);
388
388
  }
389
- this.apiError();
389
+ this.apiError(e);
390
390
  }
391
391
  }
392
392
  }
@@ -425,8 +425,16 @@ export class Meter {
425
425
  }
426
426
  }
427
427
 
428
- public apiError() {
429
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
428
+ public apiError(e: any) {
429
+ this.service.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
430
+ this.service.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
431
+ if (!this.device.meter?.hide_humidity) {
432
+ this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
433
+ }
434
+ if (!this.device.meter?.hide_temperature) {
435
+ this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
436
+ }
437
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
430
438
  }
431
439
 
432
440
  /**
@@ -2,7 +2,7 @@ import Switchbot from 'node-switchbot';
2
2
  import { interval, Subject } from 'rxjs';
3
3
  import { skipWhile } from 'rxjs/operators';
4
4
  import { SwitchBotPlatform } from '../platform';
5
- import { Service, PlatformAccessory, CharacteristicValue, HAPStatus } from 'homebridge';
5
+ import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
6
6
  import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings';
7
7
 
8
8
  /**
@@ -259,7 +259,7 @@ export class Motion {
259
259
  this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
260
260
  await this.openAPIRefreshStatus();
261
261
  }
262
- this.apiError();
262
+ this.apiError(e);
263
263
  });
264
264
  }
265
265
 
@@ -281,7 +281,7 @@ export class Motion {
281
281
  this.errorLog(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
282
282
  + ` Error: ${JSON.stringify(e)}`);
283
283
  }
284
- this.apiError();
284
+ this.apiError(e);
285
285
  }
286
286
  }
287
287
  }
@@ -319,8 +319,14 @@ export class Motion {
319
319
  }
320
320
  }
321
321
 
322
- public apiError() {
323
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
322
+ public apiError(e: any) {
323
+ this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, e);
324
+ if (this.device.ble) {
325
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
326
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
327
+ this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
328
+ }
329
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
324
330
  }
325
331
 
326
332
  /**