@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
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { SwitchBotPlatform } from '../platform';
3
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
- import { CharacteristicValue, HAPStatus, PlatformAccessory, Service } from 'homebridge';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -140,7 +140,7 @@ export class Camera {
140
140
  this.errorLog(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
141
141
  + ` Error: ${JSON.stringify(e)}`);
142
142
  }
143
- this.apiError();
143
+ this.apiError(e);
144
144
  }
145
145
  }
146
146
 
@@ -173,8 +173,9 @@ export class Camera {
173
173
  }
174
174
  }
175
175
 
176
- public apiError() {
177
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
176
+ public apiError(e: any) {
177
+ this.service.updateCharacteristic(this.platform.Characteristic.On, e);
178
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
178
179
  }
179
180
 
180
181
  /**
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { SwitchBotPlatform } from '../platform';
3
- import { CharacteristicValue, HAPStatus, PlatformAccessory, Service } from 'homebridge';
3
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
4
4
  import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
5
5
 
6
6
  /**
@@ -262,7 +262,7 @@ export class Fan {
262
262
  this.errorLog(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
263
263
  + ` Error: ${JSON.stringify(e)}`);
264
264
  }
265
- this.apiError();
265
+ this.apiError(e);
266
266
  }
267
267
  }
268
268
 
@@ -295,8 +295,11 @@ export class Fan {
295
295
  }
296
296
  }
297
297
 
298
- public apiError() {
299
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
298
+ public apiError(e: any) {
299
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
300
+ this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
301
+ this.service.updateCharacteristic(this.platform.Characteristic.SwingMode, e);
302
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
300
303
  }
301
304
 
302
305
  /**
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { SwitchBotPlatform } from '../platform';
3
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
- import { CharacteristicValue, HAPStatus, PlatformAccessory, Service } from 'homebridge';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -173,7 +173,7 @@ export class Light {
173
173
  this.errorLog(`Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
174
174
  + ` Error: ${JSON.stringify(e)}`);
175
175
  }
176
- this.apiError();
176
+ this.apiError(e);
177
177
  }
178
178
  }
179
179
 
@@ -207,8 +207,9 @@ export class Light {
207
207
  }
208
208
  }
209
209
 
210
- public apiError() {
211
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
210
+ public apiError(e: any) {
211
+ this.service.updateCharacteristic(this.platform.Characteristic.On, e);
212
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
212
213
  }
213
214
 
214
215
  /**
@@ -161,7 +161,7 @@ export class Others {
161
161
  this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
162
162
  + ` Error: ${JSON.stringify(e)}`);
163
163
  }
164
- this.apiError();
164
+ this.apiError(e);
165
165
  }
166
166
  }
167
167
 
@@ -194,8 +194,9 @@ export class Others {
194
194
  }
195
195
  }
196
196
 
197
- public apiError() {
198
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
197
+ public apiError(e: any) {
198
+ this.service?.updateCharacteristic(this.platform.Characteristic.Active, e);
199
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
199
200
  }
200
201
 
201
202
  /**
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { SwitchBotPlatform } from '../platform';
3
- import { CharacteristicValue, HAPStatus, PlatformAccessory, Service } from 'homebridge';
3
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
4
4
  import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
5
5
 
6
6
  /**
@@ -377,7 +377,7 @@ export class TV {
377
377
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
378
378
  + ` Error: ${JSON.stringify(e)}`);
379
379
  }
380
- this.apiError();
380
+ this.apiError(e);
381
381
  }
382
382
  }
383
383
 
@@ -412,8 +412,10 @@ export class TV {
412
412
  }
413
413
  }
414
414
 
415
- public apiError() {
416
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
415
+ public apiError(e: any) {
416
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
417
+ this.service.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, e);
418
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
417
419
  }
418
420
 
419
421
  /**
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { SwitchBotPlatform } from '../platform';
3
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
- import { CharacteristicValue, HAPStatus, PlatformAccessory, Service } from 'homebridge';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -140,7 +140,7 @@ export class VacuumCleaner {
140
140
  this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
141
141
  + ` Error: ${JSON.stringify(e)}`);
142
142
  }
143
- this.apiError();
143
+ this.apiError(e);
144
144
  }
145
145
  }
146
146
 
@@ -173,8 +173,9 @@ export class VacuumCleaner {
173
173
  }
174
174
  }
175
175
 
176
- public apiError() {
177
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
176
+ public apiError(e: any) {
177
+ this.service.updateCharacteristic(this.platform.Characteristic.On, e);
178
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
178
179
  }
179
180
 
180
181
  /**
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { SwitchBotPlatform } from '../platform';
3
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
- import { CharacteristicValue, HAPStatus, PlatformAccessory, Service } from 'homebridge';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -154,7 +154,7 @@ export class WaterHeater {
154
154
  this.errorLog(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
155
155
  + ` Error: ${JSON.stringify(e)}`);
156
156
  }
157
- this.apiError();
157
+ this.apiError(e);
158
158
  }
159
159
  }
160
160
 
@@ -187,8 +187,9 @@ export class WaterHeater {
187
187
  }
188
188
  }
189
189
 
190
- public apiError() {
191
- throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
190
+ public apiError(e: any) {
191
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
192
+ //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
192
193
  }
193
194
 
194
195
  /**