@switchbot/homebridge-switchbot 0.1.2-beta.32 → 0.1.2-beta.36

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 (66) hide show
  1. package/dist/devices/bots.d.ts.map +1 -1
  2. package/dist/devices/bots.js +7 -6
  3. package/dist/devices/bots.js.map +1 -1
  4. package/dist/devices/bulb.js +7 -7
  5. package/dist/devices/bulb.js.map +1 -1
  6. package/dist/devices/contact.d.ts.map +1 -1
  7. package/dist/devices/contact.js +11 -14
  8. package/dist/devices/contact.js.map +1 -1
  9. package/dist/devices/curtains.js +9 -9
  10. package/dist/devices/curtains.js.map +1 -1
  11. package/dist/devices/humidifiers.d.ts.map +1 -1
  12. package/dist/devices/humidifiers.js +21 -16
  13. package/dist/devices/humidifiers.js.map +1 -1
  14. package/dist/devices/indoorcam.js +5 -5
  15. package/dist/devices/indoorcam.js.map +1 -1
  16. package/dist/devices/meters.d.ts.map +1 -1
  17. package/dist/devices/meters.js +13 -11
  18. package/dist/devices/meters.js.map +1 -1
  19. package/dist/devices/motion.js +3 -3
  20. package/dist/devices/motion.js.map +1 -1
  21. package/dist/devices/plugs.js +4 -4
  22. package/dist/devices/plugs.js.map +1 -1
  23. package/dist/irdevices/airconditioners.js +3 -3
  24. package/dist/irdevices/airconditioners.js.map +1 -1
  25. package/dist/irdevices/airpurifiers.js +1 -1
  26. package/dist/irdevices/airpurifiers.js.map +1 -1
  27. package/dist/irdevices/cameras.js +1 -1
  28. package/dist/irdevices/cameras.js.map +1 -1
  29. package/dist/irdevices/fans.js +1 -1
  30. package/dist/irdevices/fans.js.map +1 -1
  31. package/dist/irdevices/lights.js +1 -1
  32. package/dist/irdevices/lights.js.map +1 -1
  33. package/dist/irdevices/others.d.ts.map +1 -1
  34. package/dist/irdevices/others.js +1 -1
  35. package/dist/irdevices/others.js.map +1 -1
  36. package/dist/irdevices/tvs.d.ts.map +1 -1
  37. package/dist/irdevices/tvs.js +3 -2
  38. package/dist/irdevices/tvs.js.map +1 -1
  39. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  40. package/dist/irdevices/vacuumcleaners.js +2 -3
  41. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  42. package/dist/irdevices/waterheaters.js +2 -2
  43. package/dist/irdevices/waterheaters.js.map +1 -1
  44. package/dist/platform.d.ts.map +1 -1
  45. package/dist/platform.js +37 -18
  46. package/dist/platform.js.map +1 -1
  47. package/package.json +1 -1
  48. package/src/devices/bots.ts +7 -6
  49. package/src/devices/bulb.ts +7 -7
  50. package/src/devices/contact.ts +12 -14
  51. package/src/devices/curtains.ts +9 -9
  52. package/src/devices/humidifiers.ts +23 -17
  53. package/src/devices/indoorcam.ts +5 -5
  54. package/src/devices/meters.ts +15 -11
  55. package/src/devices/motion.ts +3 -3
  56. package/src/devices/plugs.ts +4 -4
  57. package/src/irdevices/airconditioners.ts +6 -6
  58. package/src/irdevices/airpurifiers.ts +1 -1
  59. package/src/irdevices/cameras.ts +1 -1
  60. package/src/irdevices/fans.ts +1 -1
  61. package/src/irdevices/lights.ts +1 -1
  62. package/src/irdevices/others.ts +2 -4
  63. package/src/irdevices/tvs.ts +4 -2
  64. package/src/irdevices/vacuumcleaners.ts +2 -6
  65. package/src/irdevices/waterheaters.ts +2 -2
  66. package/src/platform.ts +37 -18
@@ -88,7 +88,7 @@ export class Meter {
88
88
  // you can create multiple services for each accessory
89
89
  (this.service =
90
90
  accessory.getService(this.platform.Service.Battery) ||
91
- accessory.addService(this.platform.Service.Battery)), `${device.deviceName} ${device.deviceType}`;
91
+ accessory.addService(this.platform.Service.Battery)), `${accessory.displayName} Battery`;
92
92
 
93
93
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
94
94
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -113,7 +113,9 @@ export class Meter {
113
113
  this.platform.device('Adding Temperature Sensor Service');
114
114
  (this.temperatureservice =
115
115
  this.accessory.getService(this.platform.Service.TemperatureSensor) ||
116
- this.accessory.addService(this.platform.Service.TemperatureSensor)), `${device.deviceName} ${device.deviceType} TemperatureSensor`;
116
+ this.accessory.addService(this.platform.Service.TemperatureSensor)), `${accessory.displayName} Temperature Sensor`;
117
+
118
+ this.service.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
117
119
 
118
120
  this.temperatureservice
119
121
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
@@ -140,7 +142,9 @@ export class Meter {
140
142
  this.platform.device('Adding Humidity Sensor Service');
141
143
  (this.humidityservice =
142
144
  this.accessory.getService(this.platform.Service.HumiditySensor) ||
143
- this.accessory.addService(this.platform.Service.HumiditySensor)), `${device.deviceName} ${device.deviceType} HumiditySensor`;
145
+ this.accessory.addService(this.platform.Service.HumiditySensor)), `${accessory.displayName} Humidity Sensor`;
146
+
147
+ this.service.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
144
148
 
145
149
  this.humidityservice
146
150
  .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
@@ -312,28 +316,28 @@ export class Meter {
312
316
  */
313
317
  updateHomeKitCharacteristics() {
314
318
  if (this.StatusLowBattery === undefined) {
315
- this.platform.debug(`StatusLowBattery: ${this.StatusLowBattery}`);
319
+ this.platform.debug(`Meter ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
316
320
  } else {
317
321
  this.service.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
318
- this.platform.device(`updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
322
+ this.platform.device(`Meter ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
319
323
  }
320
324
  if (this.BatteryLevel === undefined) {
321
- this.platform.debug(`BatteryLevel: ${this.BatteryLevel}`);
325
+ this.platform.debug(`Meter ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
322
326
  } else {
323
327
  this.service.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
324
- this.platform.device(`updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
328
+ this.platform.device(`Meter ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
325
329
  }
326
330
  if (this.platform.config.options?.meter?.hide_humidity && this.CurrentRelativeHumidity === undefined) {
327
- this.platform.debug(`CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
331
+ this.platform.debug(`Meter ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
328
332
  } else {
329
333
  this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
330
- this.platform.device(`updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
334
+ this.platform.device(`Meter ${this.accessory.displayName} updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
331
335
  }
332
336
  if (this.platform.config.options?.meter?.hide_temperature && this.CurrentTemperature === undefined) {
333
- this.platform.debug(`CurrentTemperature: ${this.CurrentTemperature}`);
337
+ this.platform.debug(`Meter ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
334
338
  } else {
335
339
  this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
336
- this.platform.device(`updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
340
+ this.platform.device(`Meter ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
337
341
  }
338
342
  }
339
343
 
@@ -75,7 +75,7 @@ export class Motion {
75
75
  // you can create multiple services for each accessory
76
76
  (this.service =
77
77
  accessory.getService(this.platform.Service.MotionSensor) ||
78
- accessory.addService(this.platform.Service.MotionSensor)), `${device.deviceName} ${device.deviceType}`;
78
+ accessory.addService(this.platform.Service.MotionSensor)), `${accessory.displayName} Motion Sensor`;
79
79
 
80
80
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
81
81
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -203,10 +203,10 @@ export class Motion {
203
203
  */
204
204
  updateHomeKitCharacteristics() {
205
205
  if (this.MotionDetected === undefined) {
206
- this.platform.debug(`MotionDetected: ${this.MotionDetected}`);
206
+ this.platform.debug(`Motion ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
207
207
  } else {
208
208
  this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected);
209
- this.platform.device(`updateCharacteristic MotionDetected: ${this.MotionDetected}`);
209
+ this.platform.device(`Motion ${this.accessory.displayName} updateCharacteristic MotionDetected: ${this.MotionDetected}`);
210
210
  }
211
211
  }
212
212
 
@@ -241,16 +241,16 @@ export class Plug {
241
241
 
242
242
  updateHomeKitCharacteristics() {
243
243
  if (this.On === undefined) {
244
- this.platform.debug(`On: ${this.On}`);
244
+ this.platform.debug(`Plug ${this.accessory.displayName} On: ${this.On}`);
245
245
  } else {
246
246
  this.service.updateCharacteristic(this.platform.Characteristic.On, this.On);
247
- this.platform.device(`updateCharacteristic On: ${this.On}`);
247
+ this.platform.device(`Plug ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
248
248
  }
249
249
  if (this.OutletInUse === undefined) {
250
- this.platform.debug(`OutletInUse: ${this.OutletInUse}`);
250
+ this.platform.debug(`Plug ${this.accessory.displayName} OutletInUse: ${this.OutletInUse}`);
251
251
  } else {
252
252
  this.service.updateCharacteristic(this.platform.Characteristic.OutletInUse, this.OutletInUse);
253
- this.platform.device(`updateCharacteristic OutletInUse: ${this.OutletInUse}`);
253
+ this.platform.device(`Plug ${this.accessory.displayName} updateCharacteristic OutletInUse: ${this.OutletInUse}`);
254
254
  }
255
255
  }
256
256
 
@@ -45,7 +45,7 @@ export class AirConditioner {
45
45
  // you can create multiple services for each accessory
46
46
  (this.service =
47
47
  accessory.getService(this.platform.Service.HeaterCooler) ||
48
- accessory.addService(this.platform.Service.HeaterCooler)), `${device.deviceName} ${device.remoteType}`;
48
+ accessory.addService(this.platform.Service.HeaterCooler)), `${accessory.displayName} Air Conditioner`;
49
49
 
50
50
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
51
51
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -159,14 +159,14 @@ export class AirConditioner {
159
159
  private CurrentTemperatureGet(value: CharacteristicValue) {
160
160
  this.platform.debug('Trigger Get CurrentTemperture');
161
161
 
162
- if (this.CurrentTemperature === NaN) {
162
+ if (Number.isNaN(this.CurrentTemperature)) {
163
163
  this.CurrentTemperature = 24;
164
164
  } else {
165
- this.service
166
- .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
167
- .updateValue(Number(this.CurrentTemperature) || 24);
165
+ this.service
166
+ .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
167
+ .updateValue(Number(this.CurrentTemperature) || 24);
168
168
  }
169
- return (this.CurrentTemperature = Number(value));
169
+ return (this.CurrentTemperature === Number(value));
170
170
  }
171
171
 
172
172
  private TargetHeaterCoolerStateSet(value: CharacteristicValue) {
@@ -44,7 +44,7 @@ export class AirPurifier {
44
44
  // you can create multiple services for each accessory
45
45
  (this.service =
46
46
  accessory.getService(this.platform.Service.AirPurifier) ||
47
- accessory.addService(this.platform.Service.AirPurifier)), `${device.deviceName} ${device.remoteType}`;
47
+ accessory.addService(this.platform.Service.AirPurifier)), `${accessory.displayName} Air Purifier`;
48
48
 
49
49
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
50
50
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -29,7 +29,7 @@ export class Camera {
29
29
  // you can create multiple services for each accessory
30
30
  (this.service =
31
31
  accessory.getService(this.platform.Service.Switch) ||
32
- accessory.addService(this.platform.Service.Switch)), `${device.deviceName} ${device.remoteType}`;
32
+ accessory.addService(this.platform.Service.Switch)), `${accessory.displayName} Camera`;
33
33
 
34
34
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
35
35
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -37,7 +37,7 @@ export class Fan {
37
37
  // you can create multiple services for each accessory
38
38
  (this.service =
39
39
  accessory.getService(this.platform.Service.Fanv2) ||
40
- accessory.addService(this.platform.Service.Fanv2)), `${device.deviceName} ${device.remoteType}`;
40
+ accessory.addService(this.platform.Service.Fanv2)), `${accessory.displayName} Fan`;
41
41
 
42
42
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
43
43
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -29,7 +29,7 @@ export class Light {
29
29
  // you can create multiple services for each accessory
30
30
  (this.service =
31
31
  accessory.getService(this.platform.Service.Lightbulb) ||
32
- accessory.addService(this.platform.Service.Lightbulb)), `${device.deviceName} ${device.remoteType}`;
32
+ accessory.addService(this.platform.Service.Lightbulb)), `${accessory.displayName} Light Bulb`;
33
33
 
34
34
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
35
35
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -29,10 +29,8 @@ export class Others {
29
29
  // you can create multiple services for each accessory
30
30
  this.service = accessory.getService(this.platform.Service.Fanv2);
31
31
  if (!this.service && this.platform.config.options?.other?.deviceType === 'Fan') {
32
- this.service = accessory.addService(
33
- this.platform.Service.Fanv2,
34
- `${device.deviceName} ${device.remoteType} Fan`,
35
- );
32
+ this.service = accessory.addService(this.platform.Service.Fanv2, `${accessory.displayName} Fan`);
33
+
36
34
  this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
37
35
 
38
36
  this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
@@ -53,7 +53,7 @@ export class TV {
53
53
  // you can create multiple services for each accessory
54
54
  (this.service =
55
55
  accessory.getService(this.platform.Service.Television) ||
56
- accessory.addService(this.platform.Service.Television)), `${device.deviceName} ${device.remoteType}`;
56
+ accessory.addService(this.platform.Service.Television)), `${accessory.displayName} TV`;
57
57
 
58
58
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
59
59
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -86,7 +86,9 @@ export class TV {
86
86
  // create a new Television Speaker service
87
87
  (this.speakerService =
88
88
  accessory.getService(this.platform.Service.TelevisionSpeaker) ||
89
- accessory.addService(this.platform.Service.TelevisionSpeaker)), `${device.deviceName} ${device.remoteType} Speaker`;
89
+ accessory.addService(this.platform.Service.TelevisionSpeaker)), `${accessory.displayName} Speaker`;
90
+
91
+ this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
90
92
 
91
93
  this.speakerService
92
94
  .setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE)
@@ -29,8 +29,7 @@ export class VacuumCleaner {
29
29
  // you can create multiple services for each accessory
30
30
  (this.service =
31
31
  accessory.getService(this.platform.Service.Switch) ||
32
- accessory.addService(this.platform.Service.Switch)),
33
- `${device.deviceName} ${device.remoteType}`;
32
+ accessory.addService(this.platform.Service.Switch)), `${accessory.displayName} Vacuum`;
34
33
 
35
34
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
36
35
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -38,10 +37,7 @@ export class VacuumCleaner {
38
37
 
39
38
  // set the service name, this is what is displayed as the default name on the Home app
40
39
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
41
- this.service.setCharacteristic(
42
- this.platform.Characteristic.Name,
43
- `${device.deviceName} ${device.remoteType}`,
44
- );
40
+ this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
45
41
 
46
42
  // handle on / off events using the On characteristic
47
43
  this.service.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -28,8 +28,8 @@ export class WaterHeater {
28
28
  // get the Television service if it exists, otherwise create a new Television service
29
29
  // you can create multiple services for each accessory
30
30
  (this.service =
31
- accessory.getService(this.platform.Service.Valve) || accessory.addService(this.platform.Service.Valve)),
32
- `${device.deviceName} ${device.remoteType}`;
31
+ accessory.getService(this.platform.Service.Valve) ||
32
+ accessory.addService(this.platform.Service.Valve)), `${accessory.displayName} Water Heater`;
33
33
 
34
34
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
35
35
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
package/src/platform.ts CHANGED
@@ -347,6 +347,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
347
347
  //existingAccessory.context.firmwareRevision = firmware;
348
348
  existingAccessory.context.model = device.deviceType;
349
349
  existingAccessory.context.deviceID = device.deviceId;
350
+ existingAccessory.displayName = device.deviceName;
350
351
  existingAccessory.context.firmwareRevision = this.version;
351
352
  await this.connectionTypeExistingAccessory(device, existingAccessory);
352
353
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -362,7 +363,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
362
363
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
363
364
 
364
365
  // create a new accessory
365
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
366
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
366
367
 
367
368
  // store a copy of the device object in the `accessory.context`
368
369
  // the `context` property can be used to store any data about the accessory you may need
@@ -399,6 +400,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
399
400
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
400
401
  existingAccessory.context.model = device.deviceType;
401
402
  existingAccessory.context.deviceID = device.deviceId;
403
+ existingAccessory.displayName = device.deviceName;
402
404
  existingAccessory.context.firmwareRevision = this.version;
403
405
  await this.connectionTypeExistingAccessory(device, existingAccessory);
404
406
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -417,7 +419,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
417
419
  this.log.error('You must set your Bot to Press or Switch Mode');
418
420
  }
419
421
  // create a new accessory
420
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
422
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
421
423
 
422
424
  // store a copy of the device object in the `accessory.context`
423
425
  // the `context` property can be used to store any data about the accessory you may need
@@ -455,6 +457,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
455
457
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
456
458
  existingAccessory.context.model = device.deviceType;
457
459
  existingAccessory.context.deviceID = device.deviceId;
460
+ existingAccessory.displayName = device.deviceName;
458
461
  existingAccessory.context.firmwareRevision = this.version;
459
462
  await this.connectionTypeExistingAccessory(device, existingAccessory);
460
463
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -470,7 +473,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
470
473
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
471
474
 
472
475
  // create a new accessory
473
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
476
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
474
477
 
475
478
  // store a copy of the device object in the `accessory.context`
476
479
  // the `context` property can be used to store any data about the accessory you may need
@@ -507,6 +510,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
507
510
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
508
511
  existingAccessory.context.model = device.deviceType;
509
512
  existingAccessory.context.deviceID = device.deviceId;
513
+ existingAccessory.displayName = device.deviceName;
510
514
  existingAccessory.context.firmwareRevision = this.version;
511
515
  this.api.updatePlatformAccessories([existingAccessory]);
512
516
  // create the accessory handler for the restored accessory
@@ -521,7 +525,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
521
525
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
522
526
 
523
527
  // create a new accessory
524
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
528
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
525
529
 
526
530
  // store a copy of the device object in the `accessory.context`
527
531
  // the `context` property can be used to store any data about the accessory you may need
@@ -557,6 +561,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
557
561
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
558
562
  existingAccessory.context.model = device.deviceType;
559
563
  existingAccessory.context.deviceID = device.deviceId;
564
+ existingAccessory.displayName = device.deviceName;
560
565
  existingAccessory.context.firmwareRevision = this.version;
561
566
  this.api.updatePlatformAccessories([existingAccessory]);
562
567
  // create the accessory handler for the restored accessory
@@ -571,7 +576,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
571
576
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
572
577
 
573
578
  // create a new accessory
574
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
579
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
575
580
 
576
581
  // store a copy of the device object in the `accessory.context`
577
582
  // the `context` property can be used to store any data about the accessory you may need
@@ -607,6 +612,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
607
612
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
608
613
  existingAccessory.context.model = device.deviceType;
609
614
  existingAccessory.context.deviceID = device.deviceId;
615
+ existingAccessory.displayName = device.deviceName;
610
616
  existingAccessory.context.firmwareRevision = this.version;
611
617
  await this.connectionTypeExistingAccessory(device, existingAccessory);
612
618
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -632,7 +638,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
632
638
  }
633
639
 
634
640
  // create a new accessory
635
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
641
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
636
642
 
637
643
  // store a copy of the device object in the `accessory.context`
638
644
  // the `context` property can be used to store any data about the accessory you may need
@@ -677,6 +683,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
677
683
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
678
684
  existingAccessory.context.model = device.deviceType;
679
685
  existingAccessory.context.deviceID = device.deviceId;
686
+ existingAccessory.displayName = device.deviceName;
680
687
  existingAccessory.context.firmwareRevision = this.version;
681
688
  await this.connectionTypeExistingAccessory(device, existingAccessory);
682
689
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -692,7 +699,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
692
699
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
693
700
 
694
701
  // create a new accessory
695
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
702
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
696
703
 
697
704
  // store a copy of the device object in the `accessory.context`
698
705
  // the `context` property can be used to store any data about the accessory you may need
@@ -729,6 +736,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
729
736
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
730
737
  existingAccessory.context.model = device.deviceType;
731
738
  existingAccessory.context.deviceID = device.deviceId;
739
+ existingAccessory.displayName = device.deviceName;
732
740
  existingAccessory.context.firmwareRevision = this.version;
733
741
  await this.connectionTypeExistingAccessory(device, existingAccessory);
734
742
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -744,7 +752,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
744
752
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
745
753
 
746
754
  // create a new accessory
747
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
755
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
748
756
 
749
757
  // store a copy of the device object in the `accessory.context`
750
758
  // the `context` property can be used to store any data about the accessory you may need
@@ -779,6 +787,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
779
787
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
780
788
  existingAccessory.context.model = device.remoteType;
781
789
  existingAccessory.context.deviceID = device.deviceId;
790
+ existingAccessory.displayName = device.deviceName;
782
791
  existingAccessory.context.firmwareRevision = this.version;
783
792
  await this.connectionTypeExistingAccessory(device, existingAccessory);
784
793
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -791,7 +800,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
791
800
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
792
801
 
793
802
  // create a new accessory
794
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
803
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
795
804
 
796
805
  // store a copy of the device object in the `accessory.context`
797
806
  // the `context` property can be used to store any data about the accessory you may need
@@ -833,6 +842,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
833
842
 
834
843
  existingAccessory.context.model = device.remoteType;
835
844
  existingAccessory.context.deviceID = device.deviceId;
845
+ existingAccessory.displayName = device.deviceName;
836
846
  existingAccessory.context.firmwareRevision = this.version;
837
847
  await this.connectionTypeExistingAccessory(device, existingAccessory);
838
848
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -848,7 +858,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
848
858
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
849
859
 
850
860
  // create a new accessory
851
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
861
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
852
862
 
853
863
  // store a copy of the device object in the `accessory.context`
854
864
  // the `context` property can be used to store any data about the accessory you may need
@@ -885,6 +895,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
885
895
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
886
896
  existingAccessory.context.model = device.remoteType;
887
897
  existingAccessory.context.deviceID = device.deviceId;
898
+ existingAccessory.displayName = device.deviceName;
888
899
  existingAccessory.context.firmwareRevision = this.version;
889
900
  await this.connectionTypeExistingAccessory(device, existingAccessory);
890
901
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -900,7 +911,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
900
911
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
901
912
 
902
913
  // create a new accessory
903
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
914
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
904
915
 
905
916
  // store a copy of the device object in the `accessory.context`
906
917
  // the `context` property can be used to store any data about the accessory you may need
@@ -937,6 +948,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
937
948
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
938
949
  existingAccessory.context.model = device.remoteType;
939
950
  existingAccessory.context.deviceID = device.deviceId;
951
+ existingAccessory.displayName = device.deviceName;
940
952
  existingAccessory.context.firmwareRevision = this.version;
941
953
  await this.connectionTypeExistingAccessory(device, existingAccessory);
942
954
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -952,7 +964,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
952
964
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
953
965
 
954
966
  // create a new accessory
955
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
967
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
956
968
 
957
969
  // store a copy of the device object in the `accessory.context`
958
970
  // the `context` property can be used to store any data about the accessory you may need
@@ -989,6 +1001,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
989
1001
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
990
1002
  existingAccessory.context.model = device.remoteType;
991
1003
  existingAccessory.context.deviceID = device.deviceId;
1004
+ existingAccessory.displayName = device.deviceName;
992
1005
  existingAccessory.context.firmwareRevision = this.version;
993
1006
  await this.connectionTypeExistingAccessory(device, existingAccessory);
994
1007
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -1004,7 +1017,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1004
1017
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1005
1018
 
1006
1019
  // create a new accessory
1007
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1020
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1008
1021
 
1009
1022
  // store a copy of the device object in the `accessory.context`
1010
1023
  // the `context` property can be used to store any data about the accessory you may need
@@ -1041,6 +1054,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1041
1054
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1042
1055
  existingAccessory.context.model = device.remoteType;
1043
1056
  existingAccessory.context.deviceID = device.deviceId;
1057
+ existingAccessory.displayName = device.deviceName;
1044
1058
  existingAccessory.context.firmwareRevision = this.version;
1045
1059
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1046
1060
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -1056,7 +1070,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1056
1070
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1057
1071
 
1058
1072
  // create a new accessory
1059
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1073
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1060
1074
 
1061
1075
  // store a copy of the device object in the `accessory.context`
1062
1076
  // the `context` property can be used to store any data about the accessory you may need
@@ -1093,6 +1107,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1093
1107
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1094
1108
  existingAccessory.context.model = device.remoteType;
1095
1109
  existingAccessory.context.deviceID = device.deviceId;
1110
+ existingAccessory.displayName = device.deviceName;
1096
1111
  existingAccessory.context.firmwareRevision = this.version;
1097
1112
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1098
1113
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -1108,7 +1123,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1108
1123
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1109
1124
 
1110
1125
  // create a new accessory
1111
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1126
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1112
1127
 
1113
1128
  // store a copy of the device object in the `accessory.context`
1114
1129
  // the `context` property can be used to store any data about the accessory you may need
@@ -1145,6 +1160,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1145
1160
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1146
1161
  existingAccessory.context.model = device.remoteType;
1147
1162
  existingAccessory.context.deviceID = device.deviceId;
1163
+ existingAccessory.displayName = device.deviceName;
1148
1164
  existingAccessory.context.firmwareRevision = this.version;
1149
1165
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1150
1166
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -1160,7 +1176,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1160
1176
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1161
1177
 
1162
1178
  // create a new accessory
1163
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1179
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1164
1180
 
1165
1181
  // store a copy of the device object in the `accessory.context`
1166
1182
  // the `context` property can be used to store any data about the accessory you may need
@@ -1197,6 +1213,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1197
1213
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1198
1214
  existingAccessory.context.model = device.remoteType;
1199
1215
  existingAccessory.context.deviceID = device.deviceId;
1216
+ existingAccessory.displayName = device.deviceName;
1200
1217
  existingAccessory.context.firmwareRevision = this.version;
1201
1218
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1202
1219
  this.api.updatePlatformAccessories([existingAccessory]);
@@ -1212,7 +1229,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1212
1229
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1213
1230
 
1214
1231
  // create a new accessory
1215
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1232
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1216
1233
 
1217
1234
  // store a copy of the device object in the `accessory.context`
1218
1235
  // the `context` property can be used to store any data about the accessory you may need
@@ -1262,7 +1279,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1262
1279
  }
1263
1280
 
1264
1281
  public deviceListInfo(devices: deviceResponses) {
1265
- this.device(`deviceListInfoStatus: ${JSON.stringify(devices)}`);
1282
+ if (this.config.options?.debug === 'device') {
1283
+ this.device(`deviceListInfoStatus: ${JSON.stringify(devices)}`);
1284
+ }
1266
1285
  }
1267
1286
 
1268
1287
  public async deviceInfo(device: irdevice | device) {