@switchbot/homebridge-switchbot 1.3.0 → 1.3.1-beta.11

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 (95) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/config.schema.json +12 -25
  3. package/dist/devices/bots.d.ts +2 -0
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +137 -96
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts +1 -0
  8. package/dist/devices/colorbulb.d.ts.map +1 -1
  9. package/dist/devices/colorbulb.js +18 -4
  10. package/dist/devices/colorbulb.js.map +1 -1
  11. package/dist/devices/contact.js +1 -1
  12. package/dist/devices/contact.js.map +1 -1
  13. package/dist/devices/curtains.d.ts.map +1 -1
  14. package/dist/devices/curtains.js +7 -2
  15. package/dist/devices/curtains.js.map +1 -1
  16. package/dist/devices/humidifiers.d.ts +1 -0
  17. package/dist/devices/humidifiers.d.ts.map +1 -1
  18. package/dist/devices/humidifiers.js +16 -3
  19. package/dist/devices/humidifiers.js.map +1 -1
  20. package/dist/devices/indoorcam.d.ts +32 -3
  21. package/dist/devices/indoorcam.d.ts.map +1 -1
  22. package/dist/devices/indoorcam.js +103 -45
  23. package/dist/devices/indoorcam.js.map +1 -1
  24. package/dist/devices/meters.d.ts +2 -11
  25. package/dist/devices/meters.d.ts.map +1 -1
  26. package/dist/devices/meters.js +8 -38
  27. package/dist/devices/meters.js.map +1 -1
  28. package/dist/devices/plugs.d.ts +2 -0
  29. package/dist/devices/plugs.d.ts.map +1 -1
  30. package/dist/devices/plugs.js +42 -17
  31. package/dist/devices/plugs.js.map +1 -1
  32. package/dist/irdevices/airconditioners.d.ts +2 -0
  33. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  34. package/dist/irdevices/airconditioners.js +18 -2
  35. package/dist/irdevices/airconditioners.js.map +1 -1
  36. package/dist/irdevices/airpurifiers.d.ts +2 -0
  37. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  38. package/dist/irdevices/airpurifiers.js +18 -1
  39. package/dist/irdevices/airpurifiers.js.map +1 -1
  40. package/dist/irdevices/cameras.d.ts +1 -0
  41. package/dist/irdevices/cameras.d.ts.map +1 -1
  42. package/dist/irdevices/cameras.js +10 -1
  43. package/dist/irdevices/cameras.js.map +1 -1
  44. package/dist/irdevices/fans.d.ts +1 -0
  45. package/dist/irdevices/fans.d.ts.map +1 -1
  46. package/dist/irdevices/fans.js +10 -1
  47. package/dist/irdevices/fans.js.map +1 -1
  48. package/dist/irdevices/lights.d.ts +1 -0
  49. package/dist/irdevices/lights.d.ts.map +1 -1
  50. package/dist/irdevices/lights.js +10 -1
  51. package/dist/irdevices/lights.js.map +1 -1
  52. package/dist/irdevices/others.d.ts +1 -0
  53. package/dist/irdevices/others.d.ts.map +1 -1
  54. package/dist/irdevices/others.js +10 -1
  55. package/dist/irdevices/others.js.map +1 -1
  56. package/dist/irdevices/tvs.d.ts +1 -0
  57. package/dist/irdevices/tvs.d.ts.map +1 -1
  58. package/dist/irdevices/tvs.js +10 -1
  59. package/dist/irdevices/tvs.js.map +1 -1
  60. package/dist/irdevices/vacuumcleaners.d.ts +1 -0
  61. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  62. package/dist/irdevices/vacuumcleaners.js +10 -1
  63. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  64. package/dist/irdevices/waterheaters.d.ts +1 -0
  65. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  66. package/dist/irdevices/waterheaters.js +10 -1
  67. package/dist/irdevices/waterheaters.js.map +1 -1
  68. package/dist/platform.d.ts +2 -0
  69. package/dist/platform.d.ts.map +1 -1
  70. package/dist/platform.js +109 -23
  71. package/dist/platform.js.map +1 -1
  72. package/dist/settings.d.ts +6 -5
  73. package/dist/settings.d.ts.map +1 -1
  74. package/dist/settings.js.map +1 -1
  75. package/homebridge-ui/public/index.html +5 -1
  76. package/package.json +66 -66
  77. package/src/devices/bots.ts +125 -86
  78. package/src/devices/colorbulb.ts +18 -4
  79. package/src/devices/contact.ts +1 -1
  80. package/src/devices/curtains.ts +8 -3
  81. package/src/devices/humidifiers.ts +18 -4
  82. package/src/devices/indoorcam.ts +129 -50
  83. package/src/devices/meters.ts +10 -39
  84. package/src/devices/plugs.ts +46 -19
  85. package/src/irdevices/airconditioners.ts +18 -2
  86. package/src/irdevices/airpurifiers.ts +19 -1
  87. package/src/irdevices/cameras.ts +11 -1
  88. package/src/irdevices/fans.ts +11 -1
  89. package/src/irdevices/lights.ts +11 -1
  90. package/src/irdevices/others.ts +11 -1
  91. package/src/irdevices/tvs.ts +11 -1
  92. package/src/irdevices/vacuumcleaners.ts +11 -1
  93. package/src/irdevices/waterheaters.ts +11 -1
  94. package/src/platform.ts +109 -23
  95. package/src/settings.ts +7 -5
@@ -14,6 +14,7 @@ export class Light {
14
14
 
15
15
  // Characteristic Values
16
16
  On!: CharacteristicValue;
17
+ OnCached!: CharacteristicValue;
17
18
 
18
19
  // Config
19
20
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
@@ -24,6 +25,13 @@ export class Light {
24
25
  private accessory: PlatformAccessory,
25
26
  public device: irdevice & irDevicesConfig,
26
27
  ) {
28
+ // default placeholders
29
+ if (this.On === undefined) {
30
+ this.On = false;
31
+ } else {
32
+ this.On = this.accessory.context.On;
33
+ }
34
+
27
35
  // set accessory information
28
36
  accessory
29
37
  .getService(this.platform.Service.AccessoryInformation)!
@@ -142,6 +150,8 @@ export class Light {
142
150
  const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
143
151
  this.platform.debug(`Light: ${this.accessory.displayName} pushChanges: ${push.data}`);
144
152
  this.statusCode(push);
153
+ this.OnCached = this.On;
154
+ this.accessory.context.On = this.OnCached;
145
155
  this.updateHomeKitCharacteristics();
146
156
  } catch (e: any) {
147
157
  this.platform.log.error(`Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
@@ -173,7 +183,7 @@ export class Light {
173
183
  this.platform.log.error(`Light: ${this.accessory.displayName} Device is offline.`);
174
184
  break;
175
185
  case 171:
176
- this.platform.log.error(`Light: ${this.accessory.displayName} Hub Device is offline.`);
186
+ this.platform.log.error(`Light: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
177
187
  break;
178
188
  case 190:
179
189
  this.platform.log.error(`Light: ${this.accessory.displayName} Device internal error due to device states not synchronized`
@@ -14,6 +14,7 @@ export class Others {
14
14
 
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
17
+ ActiveCached!: CharacteristicValue;
17
18
 
18
19
  // Config
19
20
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
@@ -24,6 +25,13 @@ export class Others {
24
25
  private accessory: PlatformAccessory,
25
26
  public device: irdevice & irDevicesConfig,
26
27
  ) {
28
+ // default placeholders
29
+ if (this.Active === undefined) {
30
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
31
+ } else {
32
+ this.Active = this.accessory.context.Active;
33
+ }
34
+
27
35
  // set accessory information
28
36
  accessory
29
37
  .getService(this.platform.Service.AccessoryInformation)!
@@ -54,6 +62,8 @@ export class Others {
54
62
  this.pushOffChanges();
55
63
  }
56
64
  this.Active = value;
65
+ this.ActiveCached = this.Active;
66
+ this.accessory.context.Active = this.ActiveCached;
57
67
  }
58
68
 
59
69
  private updateHomeKitCharacteristics() {
@@ -160,7 +170,7 @@ export class Others {
160
170
  this.platform.log.error(`Other: ${this.accessory.displayName} Device is offline.`);
161
171
  break;
162
172
  case 171:
163
- this.platform.log.error(`Other: ${this.accessory.displayName} Hub Device is offline.`);
173
+ this.platform.log.error(`Other: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
164
174
  break;
165
175
  case 190:
166
176
  this.platform.log.error(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized`
@@ -15,6 +15,7 @@ export class TV {
15
15
 
16
16
  // Characteristic Values
17
17
  Active!: CharacteristicValue;
18
+ ActiveCached!: CharacteristicValue;
18
19
  ActiveIdentifier!: CharacteristicValue;
19
20
 
20
21
  // Others
@@ -29,6 +30,13 @@ export class TV {
29
30
  private accessory: PlatformAccessory,
30
31
  public device: irdevice & irDevicesConfig,
31
32
  ) {
33
+ // default placeholders
34
+ if (this.Active === undefined) {
35
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
36
+ } else {
37
+ this.Active = this.accessory.context.Active;
38
+ }
39
+
32
40
  // set accessory information
33
41
  accessory
34
42
  .getService(this.platform.Service.AccessoryInformation)!
@@ -207,6 +215,8 @@ export class TV {
207
215
  this.pushTvOnChanges();
208
216
  }
209
217
  this.Active = value;
218
+ this.ActiveCached = this.Active;
219
+ this.accessory.context.Active = this.ActiveCached;
210
220
  }
211
221
  }
212
222
 
@@ -377,7 +387,7 @@ export class TV {
377
387
  this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
378
388
  break;
379
389
  case 171:
380
- this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline.`);
390
+ this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
381
391
  break;
382
392
  case 190:
383
393
  this.platform.log.error(`${this.device.remoteType}: `
@@ -14,6 +14,7 @@ export class VacuumCleaner {
14
14
 
15
15
  // Characteristic Values
16
16
  On!: CharacteristicValue;
17
+ OnCached!: CharacteristicValue;
17
18
 
18
19
  // Config
19
20
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
@@ -24,6 +25,13 @@ export class VacuumCleaner {
24
25
  private accessory: PlatformAccessory,
25
26
  public device: irdevice & irDevicesConfig,
26
27
  ) {
28
+ // default placeholders
29
+ if (this.On === undefined) {
30
+ this.On = false;
31
+ } else {
32
+ this.On = this.accessory.context.On;
33
+ }
34
+
27
35
  // set accessory information
28
36
  accessory
29
37
  .getService(this.platform.Service.AccessoryInformation)!
@@ -109,6 +117,8 @@ export class VacuumCleaner {
109
117
  const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
110
118
  this.platform.debug(`Vacuum Cleaner: ${this.accessory.displayName} pushChanges: ${push.data}`);
111
119
  this.statusCode(push);
120
+ this.OnCached = this.On;
121
+ this.accessory.context.On = this.OnCached;
112
122
  this.updateHomeKitCharacteristics();
113
123
  } catch (e: any) {
114
124
  this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
@@ -139,7 +149,7 @@ export class VacuumCleaner {
139
149
  this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Device is offline.`);
140
150
  break;
141
151
  case 171:
142
- this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Hub Device is offline.`);
152
+ this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
143
153
  break;
144
154
  case 190:
145
155
  this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
@@ -14,6 +14,7 @@ export class WaterHeater {
14
14
 
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
17
+ ActiveCached!: CharacteristicValue;
17
18
 
18
19
  // Config
19
20
  private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
@@ -24,6 +25,13 @@ export class WaterHeater {
24
25
  private accessory: PlatformAccessory,
25
26
  public device: irdevice & irDevicesConfig,
26
27
  ) {
28
+ // default placeholders
29
+ if (this.Active === undefined) {
30
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
31
+ } else {
32
+ this.Active = this.accessory.context.Active;
33
+ }
34
+
27
35
  // set accessory information
28
36
  accessory
29
37
  .getService(this.platform.Service.AccessoryInformation)!
@@ -71,6 +79,8 @@ export class WaterHeater {
71
79
  this.service.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.IN_USE);
72
80
  }
73
81
  this.Active = value;
82
+ this.ActiveCached = this.Active;
83
+ this.accessory.context.Active = this.ActiveCached;
74
84
  }
75
85
 
76
86
  private updateHomeKitCharacteristics() {
@@ -153,7 +163,7 @@ export class WaterHeater {
153
163
  this.platform.log.error(`Water Heater: ${this.accessory.displayName} Device is offline.`);
154
164
  break;
155
165
  case 171:
156
- this.platform.log.error(`Water Heater: ${this.accessory.displayName} Hub Device is offline.`);
166
+ this.platform.log.error(`Water Heater: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
157
167
  break;
158
168
  case 190:
159
169
  this.platform.log.error(`Water Heater: ${this.accessory.displayName} Device internal error due to device states not synchronized`
package/src/platform.ts CHANGED
@@ -204,7 +204,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
204
204
 
205
205
  const mergeBydeviceId = (a1: { deviceId: string; }[], a2: any[]) =>
206
206
  a1.map((itm: { deviceId: string; }) => ({
207
- ...a2.find((item: { deviceId: string; }) => (item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId) && item),
207
+ ...a2.find((item: { deviceId: string; }) => (
208
+ item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '')) && item),
208
209
  ...itm,
209
210
  }));
210
211
 
@@ -238,7 +239,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
238
239
 
239
240
  const mergeIRBydeviceId = (a1: { deviceId: string; }[], a2: any[]) =>
240
241
  a1.map((itm: { deviceId: string; }) => ({
241
- ...a2.find((item: { deviceId: string; }) => (item.deviceId === itm.deviceId) && item),
242
+ ...a2.find((item: { deviceId: string; }) => (
243
+ item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '')) && item),
242
244
  ...itm,
243
245
  }));
244
246
 
@@ -265,8 +267,43 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
265
267
  this.log.error('Neither SwitchBot OpenToken or Device Config are not set.');
266
268
  }
267
269
  } catch (e: any) {
268
- this.log.error('Failed to Discover Devices.', JSON.stringify(e.message));
269
- this.debug(JSON.stringify(e));
270
+ if (e.message.includes('400')) {
271
+ this.log.error('Failed to Discover Devices: Bad Request');
272
+ this.debug('The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.');
273
+ } else if (e.message.includes('401')) {
274
+ this.log.error('Failed to Discover Devices: Unauthorized Request');
275
+ this.debug('Authorization for the API is required, but the request has not been authenticated.');
276
+ } else if (e.message.includes('403')) {
277
+ this.log.error('Failed to Discover Devices: Forbidden Request');
278
+ this.debug('The request has been authenticated but does not have appropriate permissions, or a requested resource is not found.');
279
+ } else if (e.message.includes('404')) {
280
+ this.log.error('Failed to Discover Devices: Requst Not Found');
281
+ this.debug('Specifies the requested path does not exist.');
282
+ } else if (e.message.includes('406')) {
283
+ this.log.error('Failed to Discover Devices: Request Not Acceptable');
284
+ this.debug('The client has requested a MIME type via the Accept header for a value not supported by the server.');
285
+ } else if (e.message.includes('415')) {
286
+ this.log.error('Failed to Discover Devices: Unsupported Requst Header');
287
+ this.debug('The client has defined a contentType header that is not supported by the server.');
288
+ } else if (e.message.includes('422')) {
289
+ this.log.error('Failed to Discover Devices: Unprocessable Entity');
290
+ this.debug('The client has made a valid request, but the server cannot process it.'
291
+ + ' This is often used for APIs for which certain limits have been exceeded.');
292
+ } else if (e.message.includes('429')) {
293
+ this.log.error('Failed to Discover Devices: Too Many Requests');
294
+ this.debug('The client has exceeded the number of requests allowed for a given time window.');
295
+ } else if (e.message.includes('500')) {
296
+ this.log.error('Failed to Discover Devices: Internal Server Error');
297
+ this.debug('An unexpected error on the SmartThings servers has occurred. These errors should be rare.');
298
+ } else {
299
+ this.log.error('Failed to Discover Devices');
300
+ }
301
+ if (this.config.options?.debug === 'device') {
302
+ this.log.error(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}`);
303
+ }
304
+ if (this.config.options?.debug === 'debug' || this.debugMode) {
305
+ this.log.error(`Failed to Discover Devices, Error: ${JSON.stringify(e)}`);
306
+ }
270
307
  }
271
308
  }
272
309
 
@@ -310,7 +347,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
310
347
  this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
311
348
  this.createColorBulb(device);
312
349
  break;
313
- case 'IndoorCam':
350
+ case 'Indoor Cam':
314
351
  this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
315
352
  this.createIndoorCam(device);
316
353
  break;
@@ -420,6 +457,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
420
457
  existingAccessory.context.deviceID = device.deviceId;
421
458
  existingAccessory.displayName = device.deviceName;
422
459
  existingAccessory.context.firmwareRevision = this.version;
460
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
423
461
  await this.connectionTypeExistingAccessory(device, existingAccessory);
424
462
  this.api.updatePlatformAccessories([existingAccessory]);
425
463
  // create the accessory handler for the restored accessory
@@ -442,6 +480,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
442
480
  accessory.context.model = device.deviceType;
443
481
  accessory.context.deviceID = device.deviceId;
444
482
  accessory.context.firmwareRevision = this.version;
483
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
445
484
  await this.connectionTypeNewAccessory(device, accessory);
446
485
  // create the accessory handler for the newly create accessory
447
486
  // this is imported from `platformAccessory.ts`
@@ -475,6 +514,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
475
514
  existingAccessory.context.deviceID = device.deviceId;
476
515
  existingAccessory.displayName = device.deviceName;
477
516
  existingAccessory.context.firmwareRevision = this.version;
517
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
478
518
  await this.connectionTypeExistingAccessory(device, existingAccessory);
479
519
  this.api.updatePlatformAccessories([existingAccessory]);
480
520
  // create the accessory handler for the restored accessory
@@ -499,6 +539,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
499
539
  accessory.context.model = device.deviceType;
500
540
  accessory.context.deviceID = device.deviceId;
501
541
  accessory.context.firmwareRevision = this.version;
542
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
502
543
  await this.connectionTypeNewAccessory(device, accessory);
503
544
  // accessory.context.firmwareRevision = findaccessories.accessoryAttribute.softwareRevision;
504
545
  // create the accessory handler for the newly create accessory
@@ -531,6 +572,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
531
572
  existingAccessory.context.deviceID = device.deviceId;
532
573
  existingAccessory.displayName = device.deviceName;
533
574
  existingAccessory.context.firmwareRevision = this.version;
575
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
534
576
  await this.connectionTypeExistingAccessory(device, existingAccessory);
535
577
  this.api.updatePlatformAccessories([existingAccessory]);
536
578
  // create the accessory handler for the restored accessory
@@ -553,6 +595,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
553
595
  accessory.context.model = device.deviceType;
554
596
  accessory.context.deviceID = device.deviceId;
555
597
  accessory.context.firmwareRevision = this.version;
598
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
556
599
  await this.connectionTypeNewAccessory(device, accessory);
557
600
  // create the accessory handler for the newly create accessory
558
601
  // this is imported from `platformAccessory.ts`
@@ -584,6 +627,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
584
627
  existingAccessory.context.deviceID = device.deviceId;
585
628
  existingAccessory.displayName = device.deviceName;
586
629
  existingAccessory.context.firmwareRevision = this.version;
630
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
587
631
  await this.connectionTypeExistingAccessory(device, existingAccessory);
588
632
  this.api.updatePlatformAccessories([existingAccessory]);
589
633
  // create the accessory handler for the restored accessory
@@ -606,6 +650,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
606
650
  accessory.context.model = device.deviceType;
607
651
  accessory.context.deviceID = device.deviceId;
608
652
  accessory.context.firmwareRevision = this.version;
653
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
609
654
  await this.connectionTypeNewAccessory(device, accessory);
610
655
  // create the accessory handler for the newly create accessory
611
656
  // this is imported from `platformAccessory.ts`
@@ -637,6 +682,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
637
682
  existingAccessory.context.deviceID = device.deviceId;
638
683
  existingAccessory.displayName = device.deviceName;
639
684
  existingAccessory.context.firmwareRevision = this.version;
685
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
640
686
  await this.connectionTypeExistingAccessory(device, existingAccessory);
641
687
  this.api.updatePlatformAccessories([existingAccessory]);
642
688
  // create the accessory handler for the restored accessory
@@ -659,6 +705,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
659
705
  accessory.context.model = device.deviceType;
660
706
  accessory.context.deviceID = device.deviceId;
661
707
  accessory.context.firmwareRevision = this.version;
708
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
662
709
  await this.connectionTypeNewAccessory(device, accessory);
663
710
  // create the accessory handler for the newly create accessory
664
711
  // this is imported from `platformAccessory.ts`
@@ -690,6 +737,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
690
737
  existingAccessory.context.deviceID = device.deviceId;
691
738
  existingAccessory.displayName = device.deviceName;
692
739
  existingAccessory.context.firmwareRevision = this.version;
740
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
693
741
  await this.connectionTypeExistingAccessory(device, existingAccessory);
694
742
  this.api.updatePlatformAccessories([existingAccessory]);
695
743
  // create the accessory handler for the restored accessory
@@ -722,6 +770,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
722
770
  accessory.context.model = device.deviceType;
723
771
  accessory.context.deviceID = device.deviceId;
724
772
  accessory.context.firmwareRevision = this.version;
773
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
725
774
  await this.connectionTypeNewAccessory(device, accessory);
726
775
  // create the accessory handler for the newly create accessory
727
776
  // this is imported from `platformAccessory.ts`
@@ -766,6 +815,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
766
815
  existingAccessory.context.deviceID = device.deviceId;
767
816
  existingAccessory.displayName = device.deviceName;
768
817
  existingAccessory.context.firmwareRevision = this.version;
818
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
769
819
  await this.connectionTypeExistingAccessory(device, existingAccessory);
770
820
  this.api.updatePlatformAccessories([existingAccessory]);
771
821
  // create the accessory handler for the restored accessory
@@ -788,6 +838,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
788
838
  accessory.context.model = device.deviceType;
789
839
  accessory.context.deviceID = device.deviceId;
790
840
  accessory.context.firmwareRevision = this.version;
841
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
791
842
  await this.connectionTypeNewAccessory(device, accessory);
792
843
  // create the accessory handler for the newly create accessory
793
844
  // this is imported from `platformAccessory.ts`
@@ -819,6 +870,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
819
870
  existingAccessory.context.deviceID = device.deviceId;
820
871
  existingAccessory.displayName = device.deviceName;
821
872
  existingAccessory.context.firmwareRevision = this.version;
873
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
822
874
  await this.connectionTypeExistingAccessory(device, existingAccessory);
823
875
  this.api.updatePlatformAccessories([existingAccessory]);
824
876
  // create the accessory handler for the restored accessory
@@ -841,6 +893,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
841
893
  accessory.context.model = device.deviceType;
842
894
  accessory.context.deviceID = device.deviceId;
843
895
  accessory.context.firmwareRevision = this.version;
896
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
844
897
  await this.connectionTypeNewAccessory(device, accessory);
845
898
  // create the accessory handler for the newly create accessory
846
899
  // this is imported from `platformAccessory.ts`
@@ -872,6 +925,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
872
925
  existingAccessory.context.deviceID = device.deviceId;
873
926
  existingAccessory.displayName = device.deviceName;
874
927
  existingAccessory.context.firmwareRevision = this.version;
928
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
875
929
  await this.connectionTypeExistingAccessory(device, existingAccessory);
876
930
  this.api.updatePlatformAccessories([existingAccessory]);
877
931
  // create the accessory handler for the restored accessory
@@ -894,6 +948,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
894
948
  accessory.context.model = device.deviceType;
895
949
  accessory.context.deviceID = device.deviceId;
896
950
  accessory.context.firmwareRevision = this.version;
951
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
897
952
  await this.connectionTypeNewAccessory(device, accessory);
898
953
  // create the accessory handler for the newly create accessory
899
954
  // this is imported from `platformAccessory.ts`
@@ -923,7 +978,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
923
978
  existingAccessory.context.deviceID = device.deviceId;
924
979
  existingAccessory.displayName = device.deviceName;
925
980
  existingAccessory.context.firmwareRevision = this.version;
926
- await this.connectionTypeExistingAccessory(device, existingAccessory);
981
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
982
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
927
983
  this.api.updatePlatformAccessories([existingAccessory]);
928
984
  // create the accessory handler for the restored accessory
929
985
  // this is imported from `platformAccessory.ts`
@@ -942,7 +998,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
942
998
  accessory.context.model = device.remoteType;
943
999
  accessory.context.deviceID = device.deviceId;
944
1000
  accessory.context.firmwareRevision = this.version;
945
- await this.connectionTypeNewAccessory(device, accessory);
1001
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1002
+ await this.connectionTypeNewIRAccessory(device, accessory);
946
1003
  // create the accessory handler for the newly create accessory
947
1004
  // this is imported from `platformAccessory.ts`
948
1005
  new TV(this, accessory, device);
@@ -978,7 +1035,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
978
1035
  existingAccessory.context.deviceID = device.deviceId;
979
1036
  existingAccessory.displayName = device.deviceName;
980
1037
  existingAccessory.context.firmwareRevision = this.version;
981
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1038
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1039
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
982
1040
  this.api.updatePlatformAccessories([existingAccessory]);
983
1041
  // create the accessory handler for the restored accessory
984
1042
  // this is imported from `platformAccessory.ts`
@@ -1000,7 +1058,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1000
1058
  accessory.context.model = device.remoteType;
1001
1059
  accessory.context.deviceID = device.deviceId;
1002
1060
  accessory.context.firmwareRevision = this.version;
1003
- await this.connectionTypeNewAccessory(device, accessory);
1061
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1062
+ await this.connectionTypeNewIRAccessory(device, accessory);
1004
1063
  // create the accessory handler for the newly create accessory
1005
1064
  // this is imported from `platformAccessory.ts`
1006
1065
  new Fan(this, accessory, device);
@@ -1031,7 +1090,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1031
1090
  existingAccessory.context.deviceID = device.deviceId;
1032
1091
  existingAccessory.displayName = device.deviceName;
1033
1092
  existingAccessory.context.firmwareRevision = this.version;
1034
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1093
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1094
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1035
1095
  this.api.updatePlatformAccessories([existingAccessory]);
1036
1096
  // create the accessory handler for the restored accessory
1037
1097
  // this is imported from `platformAccessory.ts`
@@ -1053,7 +1113,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1053
1113
  accessory.context.model = device.remoteType;
1054
1114
  accessory.context.deviceID = device.deviceId;
1055
1115
  accessory.context.firmwareRevision = this.version;
1056
- await this.connectionTypeNewAccessory(device, accessory);
1116
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1117
+ await this.connectionTypeNewIRAccessory(device, accessory);
1057
1118
  // create the accessory handler for the newly create accessory
1058
1119
  // this is imported from `platformAccessory.ts`
1059
1120
  new Light(this, accessory, device);
@@ -1084,7 +1145,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1084
1145
  existingAccessory.context.deviceID = device.deviceId;
1085
1146
  existingAccessory.displayName = device.deviceName;
1086
1147
  existingAccessory.context.firmwareRevision = this.version;
1087
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1148
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1149
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1088
1150
  this.api.updatePlatformAccessories([existingAccessory]);
1089
1151
  // create the accessory handler for the restored accessory
1090
1152
  // this is imported from `platformAccessory.ts`
@@ -1106,7 +1168,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1106
1168
  accessory.context.model = device.remoteType;
1107
1169
  accessory.context.deviceID = device.deviceId;
1108
1170
  accessory.context.firmwareRevision = this.version;
1109
- await this.connectionTypeNewAccessory(device, accessory);
1171
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1172
+ await this.connectionTypeNewIRAccessory(device, accessory);
1110
1173
  // create the accessory handler for the newly create accessory
1111
1174
  // this is imported from `platformAccessory.ts`
1112
1175
  new AirConditioner(this, accessory, device);
@@ -1137,7 +1200,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1137
1200
  existingAccessory.context.deviceID = device.deviceId;
1138
1201
  existingAccessory.displayName = device.deviceName;
1139
1202
  existingAccessory.context.firmwareRevision = this.version;
1140
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1203
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1204
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1141
1205
  this.api.updatePlatformAccessories([existingAccessory]);
1142
1206
  // create the accessory handler for the restored accessory
1143
1207
  // this is imported from `platformAccessory.ts`
@@ -1159,7 +1223,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1159
1223
  accessory.context.model = device.remoteType;
1160
1224
  accessory.context.deviceID = device.deviceId;
1161
1225
  accessory.context.firmwareRevision = this.version;
1162
- await this.connectionTypeNewAccessory(device, accessory);
1226
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1227
+ await this.connectionTypeNewIRAccessory(device, accessory);
1163
1228
  // create the accessory handler for the newly create accessory
1164
1229
  // this is imported from `platformAccessory.ts`
1165
1230
  new AirPurifier(this, accessory, device);
@@ -1190,7 +1255,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1190
1255
  existingAccessory.context.deviceID = device.deviceId;
1191
1256
  existingAccessory.displayName = device.deviceName;
1192
1257
  existingAccessory.context.firmwareRevision = this.version;
1193
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1258
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1259
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1194
1260
  this.api.updatePlatformAccessories([existingAccessory]);
1195
1261
  // create the accessory handler for the restored accessory
1196
1262
  // this is imported from `platformAccessory.ts`
@@ -1212,7 +1278,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1212
1278
  accessory.context.model = device.remoteType;
1213
1279
  accessory.context.deviceID = device.deviceId;
1214
1280
  accessory.context.firmwareRevision = this.version;
1215
- await this.connectionTypeNewAccessory(device, accessory);
1281
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1282
+ await this.connectionTypeNewIRAccessory(device, accessory);
1216
1283
  // create the accessory handler for the newly create accessory
1217
1284
  // this is imported from `platformAccessory.ts`
1218
1285
  new WaterHeater(this, accessory, device);
@@ -1243,7 +1310,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1243
1310
  existingAccessory.context.deviceID = device.deviceId;
1244
1311
  existingAccessory.displayName = device.deviceName;
1245
1312
  existingAccessory.context.firmwareRevision = this.version;
1246
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1313
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1314
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1247
1315
  this.api.updatePlatformAccessories([existingAccessory]);
1248
1316
  // create the accessory handler for the restored accessory
1249
1317
  // this is imported from `platformAccessory.ts`
@@ -1265,7 +1333,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1265
1333
  accessory.context.model = device.remoteType;
1266
1334
  accessory.context.deviceID = device.deviceId;
1267
1335
  accessory.context.firmwareRevision = this.version;
1268
- await this.connectionTypeNewAccessory(device, accessory);
1336
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1337
+ await this.connectionTypeNewIRAccessory(device, accessory);
1269
1338
  // create the accessory handler for the newly create accessory
1270
1339
  // this is imported from `platformAccessory.ts`
1271
1340
  new VacuumCleaner(this, accessory, device);
@@ -1296,7 +1365,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1296
1365
  existingAccessory.context.deviceID = device.deviceId;
1297
1366
  existingAccessory.displayName = device.deviceName;
1298
1367
  existingAccessory.context.firmwareRevision = this.version;
1299
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1368
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1369
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1300
1370
  this.api.updatePlatformAccessories([existingAccessory]);
1301
1371
  // create the accessory handler for the restored accessory
1302
1372
  // this is imported from `platformAccessory.ts`
@@ -1318,7 +1388,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1318
1388
  accessory.context.model = device.remoteType;
1319
1389
  accessory.context.deviceID = device.deviceId;
1320
1390
  accessory.context.firmwareRevision = this.version;
1321
- await this.connectionTypeNewAccessory(device, accessory);
1391
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1392
+ await this.connectionTypeNewIRAccessory(device, accessory);
1322
1393
  // create the accessory handler for the newly create accessory
1323
1394
  // this is imported from `platformAccessory.ts`
1324
1395
  new Camera(this, accessory, device);
@@ -1349,7 +1420,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1349
1420
  existingAccessory.context.deviceID = device.deviceId;
1350
1421
  existingAccessory.displayName = device.deviceName;
1351
1422
  existingAccessory.context.firmwareRevision = this.version;
1352
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1423
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1424
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1353
1425
  this.api.updatePlatformAccessories([existingAccessory]);
1354
1426
  // create the accessory handler for the restored accessory
1355
1427
  // this is imported from `platformAccessory.ts`
@@ -1371,7 +1443,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1371
1443
  accessory.context.model = device.remoteType;
1372
1444
  accessory.context.deviceID = device.deviceId;
1373
1445
  accessory.context.firmwareRevision = this.version;
1374
- await this.connectionTypeNewAccessory(device, accessory);
1446
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1447
+ await this.connectionTypeNewIRAccessory(device, accessory);
1375
1448
  // create the accessory handler for the newly create accessory
1376
1449
  // this is imported from `platformAccessory.ts`
1377
1450
  new Others(this, accessory, device);
@@ -1406,6 +1479,19 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1406
1479
  }
1407
1480
  }
1408
1481
 
1482
+ public async connectionTypeNewIRAccessory(
1483
+ device: irdevice & devicesConfig,
1484
+ accessory: PlatformAccessory) {
1485
+ accessory.context.connectionType = 'IR wirth OpenAPI';
1486
+ }
1487
+
1488
+ public async connectionTypeExistingIRAccessory(
1489
+ device: irdevice & devicesConfig,
1490
+ existingAccessory: PlatformAccessory,
1491
+ ) {
1492
+ existingAccessory.context.connectionType = 'IR with OpenAPI';
1493
+ }
1494
+
1409
1495
  public unregisterPlatformAccessories(existingAccessory: PlatformAccessory) {
1410
1496
  // remove platform accessories when no longer present
1411
1497
  this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [existingAccessory]);
package/src/settings.ts CHANGED
@@ -49,10 +49,10 @@ export interface devicesConfig extends device {
49
49
  colorbulb?: colorbulb;
50
50
  ble?: string;
51
51
  hide_device?: boolean;
52
+ offline?: boolean;
52
53
  }
53
54
 
54
55
  export type meter = {
55
- unit?: number;
56
56
  hide_temperature?: boolean;
57
57
  hide_humidity?: boolean;
58
58
  };
@@ -280,10 +280,7 @@ export type serviceData = {
280
280
  //Humidifier's AutoMode
281
281
  autoMode?: boolean;
282
282
  //Meter Temperature Levels
283
- temperature?: {
284
- c: number,
285
- f: number
286
- };
283
+ temperature?: temperature;
287
284
  // Fahrenheit enabled for Meter
288
285
  fahrenheit: boolean;
289
286
  // Humidity level for Meter
@@ -303,6 +300,11 @@ export type serviceData = {
303
300
  position?: number;
304
301
  };
305
302
 
303
+ export type temperature = {
304
+ c: number;
305
+ f: number;
306
+ };
307
+
306
308
  export type switchbot = {
307
309
  discover: (
308
310
  arg0: