@switchbot/homebridge-switchbot 2.3.0-beta.3 → 2.3.0-beta.5

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 (91) hide show
  1. package/dist/device/bot.d.ts.map +1 -1
  2. package/dist/device/bot.js +33 -11
  3. package/dist/device/bot.js.map +1 -1
  4. package/dist/device/ceilinglight.d.ts.map +1 -1
  5. package/dist/device/ceilinglight.js +3 -1
  6. package/dist/device/ceilinglight.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts.map +1 -1
  8. package/dist/device/colorbulb.js +3 -1
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.d.ts.map +1 -1
  11. package/dist/device/contact.js +3 -1
  12. package/dist/device/contact.js.map +1 -1
  13. package/dist/device/curtain.d.ts.map +1 -1
  14. package/dist/device/curtain.js +9 -3
  15. package/dist/device/curtain.js.map +1 -1
  16. package/dist/device/humidifier.d.ts.map +1 -1
  17. package/dist/device/humidifier.js +6 -2
  18. package/dist/device/humidifier.js.map +1 -1
  19. package/dist/device/lock.d.ts.map +1 -1
  20. package/dist/device/lock.js +7 -3
  21. package/dist/device/lock.js.map +1 -1
  22. package/dist/device/meter.d.ts.map +1 -1
  23. package/dist/device/meter.js +9 -3
  24. package/dist/device/meter.js.map +1 -1
  25. package/dist/device/meterplus.d.ts.map +1 -1
  26. package/dist/device/meterplus.js +9 -3
  27. package/dist/device/meterplus.js.map +1 -1
  28. package/dist/device/motion.d.ts.map +1 -1
  29. package/dist/device/motion.js +3 -1
  30. package/dist/device/motion.js.map +1 -1
  31. package/dist/device/plug.d.ts.map +1 -1
  32. package/dist/device/plug.js +3 -1
  33. package/dist/device/plug.js.map +1 -1
  34. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  35. package/dist/device/robotvacuumcleaner.js +3 -1
  36. package/dist/device/robotvacuumcleaner.js.map +1 -1
  37. package/dist/device/striplight.d.ts.map +1 -1
  38. package/dist/device/striplight.js +3 -1
  39. package/dist/device/striplight.js.map +1 -1
  40. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  41. package/dist/irdevice/airconditioner.js +3 -1
  42. package/dist/irdevice/airconditioner.js.map +1 -1
  43. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  44. package/dist/irdevice/airpurifier.js +3 -1
  45. package/dist/irdevice/airpurifier.js.map +1 -1
  46. package/dist/irdevice/camera.d.ts.map +1 -1
  47. package/dist/irdevice/camera.js +3 -1
  48. package/dist/irdevice/camera.js.map +1 -1
  49. package/dist/irdevice/fan.d.ts.map +1 -1
  50. package/dist/irdevice/fan.js +3 -1
  51. package/dist/irdevice/fan.js.map +1 -1
  52. package/dist/irdevice/light.d.ts.map +1 -1
  53. package/dist/irdevice/light.js +4 -2
  54. package/dist/irdevice/light.js.map +1 -1
  55. package/dist/irdevice/other.d.ts.map +1 -1
  56. package/dist/irdevice/other.js +3 -1
  57. package/dist/irdevice/other.js.map +1 -1
  58. package/dist/irdevice/tv.d.ts.map +1 -1
  59. package/dist/irdevice/tv.js +9 -3
  60. package/dist/irdevice/tv.js.map +1 -1
  61. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  62. package/dist/irdevice/vacuumcleaner.js +3 -1
  63. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  64. package/dist/irdevice/waterheater.d.ts.map +1 -1
  65. package/dist/irdevice/waterheater.js +4 -2
  66. package/dist/irdevice/waterheater.js.map +1 -1
  67. package/dist/settings.d.ts +24 -24
  68. package/dist/settings.d.ts.map +1 -1
  69. package/package.json +7 -7
  70. package/src/device/bot.ts +33 -11
  71. package/src/device/ceilinglight.ts +3 -2
  72. package/src/device/colorbulb.ts +3 -1
  73. package/src/device/contact.ts +3 -2
  74. package/src/device/curtain.ts +9 -3
  75. package/src/device/humidifier.ts +6 -2
  76. package/src/device/lock.ts +7 -4
  77. package/src/device/meter.ts +9 -3
  78. package/src/device/meterplus.ts +9 -3
  79. package/src/device/motion.ts +3 -2
  80. package/src/device/plug.ts +3 -2
  81. package/src/device/robotvacuumcleaner.ts +3 -2
  82. package/src/device/striplight.ts +3 -2
  83. package/src/irdevice/airconditioner.ts +3 -1
  84. package/src/irdevice/airpurifier.ts +3 -2
  85. package/src/irdevice/camera.ts +3 -1
  86. package/src/irdevice/fan.ts +3 -1
  87. package/src/irdevice/light.ts +4 -2
  88. package/src/irdevice/other.ts +3 -1
  89. package/src/irdevice/tv.ts +10 -3
  90. package/src/irdevice/vacuumcleaner.ts +3 -1
  91. package/src/irdevice/waterheater.ts +4 -2
package/src/device/bot.ts CHANGED
@@ -110,7 +110,9 @@ export class Bot {
110
110
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Switch`);
111
111
 
112
112
  this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
113
- this.switchService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
113
+ if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
114
+ this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
115
+ }
114
116
  this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
115
117
  } else if (device.bot?.deviceType === 'garagedoor') {
116
118
  this.removeFanService(accessory);
@@ -130,7 +132,9 @@ export class Bot {
130
132
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Garage Door Opener`);
131
133
 
132
134
  this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
133
- this.garageDoorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
135
+ if (!this.garageDoorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
136
+ this.garageDoorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
137
+ }
134
138
  this.garageDoorService.getCharacteristic(this.platform.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
135
139
  this.garageDoorService.setCharacteristic(this.platform.Characteristic.ObstructionDetected, false);
136
140
  } else if (device.bot?.deviceType === 'door') {
@@ -150,7 +154,9 @@ export class Bot {
150
154
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Door`);
151
155
 
152
156
  this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
153
- this.doorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
157
+ if (!this.doorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
158
+ this.doorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
159
+ }
154
160
  this.doorService
155
161
  .getCharacteristic(this.platform.Characteristic.TargetPosition)
156
162
  .setProps({
@@ -178,7 +184,9 @@ export class Bot {
178
184
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window`);
179
185
 
180
186
  this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
181
- this.windowService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
187
+ if (!this.windowService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
188
+ this.windowService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
189
+ }
182
190
  this.windowService
183
191
  .getCharacteristic(this.platform.Characteristic.TargetPosition)
184
192
  .setProps({
@@ -207,7 +215,9 @@ export class Bot {
207
215
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window Covering`);
208
216
 
209
217
  this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
210
- this.windowCoveringService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
218
+ if (!this.windowCoveringService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
219
+ this.windowCoveringService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
220
+ }
211
221
  this.windowCoveringService
212
222
  .getCharacteristic(this.platform.Characteristic.TargetPosition)
213
223
  .setProps({
@@ -235,7 +245,9 @@ export class Bot {
235
245
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Lock`);
236
246
 
237
247
  this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
238
- this.lockService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
248
+ if (!this.lockService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
249
+ this.lockService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
250
+ }
239
251
  this.lockService.getCharacteristic(this.platform.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
240
252
  } else if (device.bot?.deviceType === 'faucet') {
241
253
  this.removeFanService(accessory);
@@ -254,7 +266,9 @@ export class Bot {
254
266
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Faucet`);
255
267
 
256
268
  this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
257
- this.faucetService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
269
+ if (!this.faucetService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
270
+ this.faucetService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
271
+ }
258
272
  this.faucetService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.OnSet.bind(this));
259
273
  } else if (device.bot?.deviceType === 'fan') {
260
274
  this.removeLockService(accessory);
@@ -273,7 +287,9 @@ export class Bot {
273
287
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Fan`);
274
288
 
275
289
  this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
276
- this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
290
+ if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
291
+ this.fanService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
292
+ }
277
293
  this.fanService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
278
294
  } else if (device.bot?.deviceType === 'stateful') {
279
295
  this.removeFanService(accessory);
@@ -294,7 +310,9 @@ export class Bot {
294
310
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
295
311
 
296
312
  this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
297
- this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
313
+ if (!this.statefulProgrammableSwitchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
314
+ this.statefulProgrammableSwitchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
315
+ }
298
316
  this.statefulProgrammableSwitchService
299
317
  .getCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState)
300
318
  .onSet(this.OnSet.bind(this));
@@ -315,7 +333,9 @@ export class Bot {
315
333
  this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Outlet`);
316
334
 
317
335
  this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
318
- this.outletService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
336
+ if (!this.outletService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
337
+ this.outletService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
338
+ }
319
339
  this.outletService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
320
340
  }
321
341
 
@@ -330,7 +350,9 @@ export class Bot {
330
350
  `${accessory.displayName} Battery`;
331
351
 
332
352
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
333
- this.batteryService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
353
+ if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
354
+ this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
355
+ }
334
356
  } else {
335
357
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
336
358
  }
@@ -108,8 +108,9 @@ export class CeilingLight {
108
108
  // set the service name, this is what is displayed as the default name on the Home app
109
109
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
110
110
  this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
111
- this.lightBulbService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
112
-
111
+ if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
112
+ this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
113
+ }
113
114
  // handle on / off events using the On characteristic
114
115
  this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
115
116
 
@@ -118,7 +118,9 @@ export class ColorBulb {
118
118
  // set the service name, this is what is displayed as the default name on the Home app
119
119
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
120
120
  this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
121
- this.lightBulbService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
121
+ if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
122
+ this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
123
+ }
122
124
 
123
125
  // handle on / off events using the On characteristic
124
126
  this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -102,8 +102,9 @@ export class Contact {
102
102
  // set the service name, this is what is displayed as the default name on the Home app
103
103
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
104
104
  this.contactSensorservice.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
105
- this.contactSensorservice.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
106
-
105
+ if (!this.contactSensorservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
106
+ this.contactSensorservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
107
+ }
107
108
  // each service must implement at-minimum the "required characteristics" for the given service type
108
109
  // see https://developers.homebridge.io/#/service/ContactSensor
109
110
 
@@ -111,7 +111,9 @@ export class Curtain {
111
111
  // set the service name, this is what is displayed as the default name on the Home app
112
112
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
113
113
  this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
114
- this.windowCoveringService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
114
+ if (!this.windowCoveringService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
115
+ this.windowCoveringService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
116
+ }
115
117
 
116
118
  // each service must implement at-minimum the "required characteristics" for the given service type
117
119
  // see https://developers.homebridge.io/#/service/WindowCovering
@@ -151,7 +153,9 @@ export class Curtain {
151
153
  `${accessory.displayName} Light Sensor`;
152
154
 
153
155
  this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
154
- this.lightSensorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Light Sensor`);
156
+ if (!this.lightSensorService?.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
157
+ this.lightSensorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Light Sensor`);
158
+ }
155
159
  } else {
156
160
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Light Sensor Service Not Added`);
157
161
  }
@@ -167,7 +171,9 @@ export class Curtain {
167
171
  `${accessory.displayName} Battery`;
168
172
 
169
173
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
170
- this.batteryService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
174
+ if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
175
+ this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
176
+ }
171
177
  } else {
172
178
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
173
179
  }
@@ -97,7 +97,9 @@ export class Humidifier {
97
97
  // set the service name, this is what is displayed as the default name on the Home app
98
98
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
99
99
  this.humidifierService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
100
- this.humidifierService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
100
+ if (!this.humidifierService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
101
+ this.humidifierService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
102
+ }
101
103
 
102
104
  // each service must implement at-minimum the "required characteristics" for the given service type
103
105
  // see https://developers.homebridge.io/#/service/HumidifierDehumidifier
@@ -142,7 +144,9 @@ export class Humidifier {
142
144
  `${accessory.displayName} Temperature Sensor`;
143
145
 
144
146
  this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
145
- this.temperatureservice.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
147
+ if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
148
+ this.temperatureservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
149
+ }
146
150
  this.temperatureservice
147
151
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
148
152
  .setProps({
@@ -79,7 +79,10 @@ export class Lock {
79
79
 
80
80
  // set the service name, this is what is displayed as the default name on the Home app
81
81
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
82
- this.lockService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
82
+ this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
83
+ if (!this.lockService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
84
+ this.lockService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
85
+ }
83
86
 
84
87
  // each service must implement at-minimum the "required characteristics" for the given service type
85
88
  // see https://developers.homebridge.io/#/service/LockMechanism
@@ -99,7 +102,9 @@ export class Lock {
99
102
  `${accessory.displayName} Contact Sensor`;
100
103
 
101
104
  this.contactSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Contact Sensor`);
102
- this.contactSensorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Contact Sensor`);
105
+ if (!this.contactSensorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
106
+ this.contactSensorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Contact Sensor`);
107
+ }
103
108
  } else {
104
109
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Contact Sensor Service Not Added`);
105
110
  }
@@ -173,8 +178,6 @@ export class Lock {
173
178
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LockTargetState}`);
174
179
  }
175
180
 
176
- //{"deviceId":"DBDC23B53139","deviceType":"Smart Lock","hubDeviceId":"E68B14109DA2","lockState":"locked","doorState":"opened","calibrate":true}
177
-
178
181
  async openAPIparseStatus(): Promise<void> {
179
182
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
180
183
  switch (this.lockState) {
@@ -104,7 +104,9 @@ export class Meter {
104
104
  `${accessory.displayName} Temperature Sensor`;
105
105
 
106
106
  this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
107
- this.temperatureservice.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
107
+ if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
108
+ this.temperatureservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
109
+ }
108
110
  this.temperatureservice
109
111
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
110
112
  .setProps({
@@ -133,7 +135,9 @@ export class Meter {
133
135
  `${accessory.displayName} Humidity Sensor`;
134
136
 
135
137
  this.humidityservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
136
- this.humidityservice.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
138
+ if (!this.humidityservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
139
+ this.humidityservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
140
+ }
137
141
  this.humidityservice
138
142
  .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
139
143
  .setProps({
@@ -157,7 +161,9 @@ export class Meter {
157
161
  `${accessory.displayName} Battery`;
158
162
 
159
163
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
160
- this.batteryService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
164
+ if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
165
+ this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
166
+ }
161
167
  this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
162
168
  } else {
163
169
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
@@ -104,7 +104,9 @@ export class MeterPlus {
104
104
  `${accessory.displayName} Temperature Sensor`;
105
105
 
106
106
  this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
107
- this.temperatureservice.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
107
+ if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
108
+ this.temperatureservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
109
+ }
108
110
  this.temperatureservice
109
111
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
110
112
  .setProps({
@@ -133,7 +135,9 @@ export class MeterPlus {
133
135
  `${accessory.displayName} Humidity Sensor`;
134
136
 
135
137
  this.humidityservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
136
- this.humidityservice.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
138
+ if (!this.humidityservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
139
+ this.humidityservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
140
+ }
137
141
  this.humidityservice
138
142
  .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
139
143
  .setProps({
@@ -157,7 +161,9 @@ export class MeterPlus {
157
161
  `${accessory.displayName} Battery`;
158
162
 
159
163
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
160
- this.batteryService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
164
+ if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
165
+ this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
166
+ }
161
167
  this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
162
168
  } else {
163
169
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
@@ -98,8 +98,9 @@ export class Motion {
98
98
  // set the service name, this is what is displayed as the default name on the Home app
99
99
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
100
100
  this.motionSensorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
101
- this.motionSensorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
102
-
101
+ if (!this.motionSensorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
102
+ this.motionSensorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
103
+ }
103
104
  // each service must implement at-minimum the "required characteristics" for the given service type
104
105
  // see https://developers.homebridge.io/#/service/MotionSensor
105
106
 
@@ -83,8 +83,9 @@ export class Plug {
83
83
  // set the service name, this is what is displayed as the default name on the Home app
84
84
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
85
85
  this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
86
- this.outletService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
87
-
86
+ if (!this.outletService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
87
+ this.outletService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
88
+ }
88
89
  // each service must implement at-minimum the "required characteristics" for the given service type
89
90
  // see https://developers.homebridge.io/#/service/Outlet
90
91
 
@@ -81,8 +81,9 @@ export class RobotVacuumCleaner {
81
81
  // set the service name, this is what is displayed as the default name on the Home app
82
82
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
83
83
  this.robotVacuumCleanerService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
84
- this.robotVacuumCleanerService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
85
-
84
+ if (!this.robotVacuumCleanerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
85
+ this.robotVacuumCleanerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
86
+ }
86
87
  // each service must implement at-minimum the "required characteristics" for the given service type
87
88
  // see https://developers.homebridge.io/#/service/Lightbulb
88
89
 
@@ -108,8 +108,9 @@ export class StripLight {
108
108
  // set the service name, this is what is displayed as the default name on the Home app
109
109
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
110
110
  this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
111
- this.lightBulbService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
112
-
111
+ if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
112
+ this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
113
+ }
113
114
  // handle on / off events using the On characteristic
114
115
  this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
115
116
 
@@ -76,7 +76,9 @@ export class AirConditioner {
76
76
  // set the service name, this is what is displayed as the default name on the Home app
77
77
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
78
78
  this.coolerService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
79
- this.coolerService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
79
+ if (!this.coolerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
80
+ this.coolerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
81
+ }
80
82
 
81
83
  // handle on / off events using the Active characteristic
82
84
  this.coolerService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
@@ -71,8 +71,9 @@ export class AirPurifier {
71
71
  // set the service name, this is what is displayed as the default name on the Home app
72
72
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
73
73
  this.airPurifierService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
74
- this.airPurifierService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
75
-
74
+ if (!this.airPurifierService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
75
+ this.airPurifierService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
76
+ }
76
77
  // handle on / off events using the Active characteristic
77
78
  this.airPurifierService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
78
79
 
@@ -53,7 +53,9 @@ export class Camera {
53
53
  // set the service name, this is what is displayed as the default name on the Home app
54
54
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
55
55
  this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
56
- this.switchService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
56
+ if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
57
59
 
58
60
  // handle on / off events using the On characteristic
59
61
  this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -63,7 +63,9 @@ export class Fan {
63
63
  // set the service name, this is what is displayed as the default name on the Home app
64
64
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
65
65
  this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
66
- this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
66
+ if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
67
+ this.fanService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
68
+ }
67
69
 
68
70
  // handle on / off events using the Active characteristic
69
71
  this.fanService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
@@ -41,7 +41,7 @@ export class Light {
41
41
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
42
42
  .updateValue(this.FirmwareRevision(accessory, device));
43
43
 
44
- // get the Television service if it exists, otherwise create a new Television service
44
+ // get the Light service if it exists, otherwise create a new Light service
45
45
  // you can create multiple services for each accessory
46
46
  (this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb) || accessory.addService(this.platform.Service.Lightbulb)),
47
47
  `${accessory.displayName} ${device.remoteType}`;
@@ -53,7 +53,9 @@ export class Light {
53
53
  // set the service name, this is what is displayed as the default name on the Home app
54
54
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
55
55
  this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
56
- this.lightBulbService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
56
+ if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
57
59
 
58
60
  // handle on / off events using the On characteristic
59
61
  this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -59,7 +59,9 @@ export class Others {
59
59
  `${accessory.displayName} Fan`;
60
60
 
61
61
  this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Fan`);
62
- this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Fan`);
62
+ if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
63
+ this.fanService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Fan`);
64
+ }
63
65
  this.fanService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
64
66
  } else {
65
67
  this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
@@ -41,8 +41,6 @@ export class TV {
41
41
  // set accessory information
42
42
  accessory
43
43
  .getService(this.platform.Service.AccessoryInformation)!
44
- .setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`)
45
- .setCharacteristic(this.platform.Characteristic.ConfiguredName, `${device.deviceName} ${device.remoteType}`)
46
44
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
47
45
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
48
46
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
@@ -50,6 +48,13 @@ export class TV {
50
48
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
51
49
  .updateValue(this.FirmwareRevision(accessory, device));
52
50
 
51
+ // get the Television service if it exists, otherwise create a new Television service
52
+ // you can create multiple services for each accessory
53
+ this.tvService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
54
+ if (!this.tvService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
55
+ this.tvService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
56
+ }
57
+
53
58
  // set the accessory category
54
59
  switch (device.remoteType) {
55
60
  case 'Speaker':
@@ -115,7 +120,9 @@ export class TV {
115
120
  `${accessory.displayName} Speaker`;
116
121
 
117
122
  this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
118
- this.speakerService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Speaker`);
123
+ if (!this.speakerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
124
+ this.speakerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Speaker`);
125
+ }
119
126
  this.speakerService
120
127
  .setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE)
121
128
  .setCharacteristic(this.platform.Characteristic.VolumeControlType, this.platform.Characteristic.VolumeControlType.ABSOLUTE);
@@ -53,7 +53,9 @@ export class VacuumCleaner {
53
53
  // set the service name, this is what is displayed as the default name on the Home app
54
54
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
55
55
  this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
56
- this.switchService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
56
+ if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
57
59
 
58
60
  // handle on / off events using the On characteristic
59
61
  this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -52,8 +52,10 @@ export class WaterHeater {
52
52
 
53
53
  // set the service name, this is what is displayed as the default name on the Home app
54
54
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
55
- this.valveService.setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`);
56
- this.valveService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${device.deviceName} ${device.remoteType}`);
55
+ this.valveService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
56
+ if (!this.valveService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.valveService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
57
59
 
58
60
  // set sleep discovery characteristic
59
61
  this.valveService.setCharacteristic(this.platform.Characteristic.ValveType, this.platform.Characteristic.ValveType.GENERIC_VALVE);