@switchbot/homebridge-switchbot 2.0.0-beta.18 → 2.0.0-beta.19

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 (106) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/config.schema.json +11 -2
  3. package/dist/device/bot.d.ts +2 -0
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +201 -163
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts +2 -0
  8. package/dist/device/colorbulb.d.ts.map +1 -1
  9. package/dist/device/colorbulb.js +250 -218
  10. package/dist/device/colorbulb.js.map +1 -1
  11. package/dist/device/contact.d.ts +2 -0
  12. package/dist/device/contact.d.ts.map +1 -1
  13. package/dist/device/contact.js +85 -66
  14. package/dist/device/contact.js.map +1 -1
  15. package/dist/device/curtain.d.ts +2 -0
  16. package/dist/device/curtain.d.ts.map +1 -1
  17. package/dist/device/curtain.js +166 -136
  18. package/dist/device/curtain.js.map +1 -1
  19. package/dist/device/humidifier.d.ts.map +1 -1
  20. package/dist/device/humidifier.js +126 -115
  21. package/dist/device/humidifier.js.map +1 -1
  22. package/dist/device/lock.d.ts +2 -0
  23. package/dist/device/lock.d.ts.map +1 -1
  24. package/dist/device/lock.js +156 -130
  25. package/dist/device/lock.js.map +1 -1
  26. package/dist/device/meter.d.ts +2 -0
  27. package/dist/device/meter.d.ts.map +1 -1
  28. package/dist/device/meter.js +85 -64
  29. package/dist/device/meter.js.map +1 -1
  30. package/dist/device/meterplus.d.ts +2 -0
  31. package/dist/device/meterplus.d.ts.map +1 -1
  32. package/dist/device/meterplus.js +78 -59
  33. package/dist/device/meterplus.js.map +1 -1
  34. package/dist/device/motion.d.ts +2 -0
  35. package/dist/device/motion.d.ts.map +1 -1
  36. package/dist/device/motion.js +76 -57
  37. package/dist/device/motion.js.map +1 -1
  38. package/dist/device/plug.d.ts +2 -0
  39. package/dist/device/plug.d.ts.map +1 -1
  40. package/dist/device/plug.js +133 -107
  41. package/dist/device/plug.js.map +1 -1
  42. package/dist/device/striplight.d.ts +2 -0
  43. package/dist/device/striplight.d.ts.map +1 -1
  44. package/dist/device/striplight.js +224 -195
  45. package/dist/device/striplight.js.map +1 -1
  46. package/dist/irdevice/airconditioner.d.ts +2 -0
  47. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  48. package/dist/irdevice/airconditioner.js +127 -105
  49. package/dist/irdevice/airconditioner.js.map +1 -1
  50. package/dist/irdevice/airpurifier.d.ts +2 -0
  51. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  52. package/dist/irdevice/airpurifier.js +83 -66
  53. package/dist/irdevice/airpurifier.js.map +1 -1
  54. package/dist/irdevice/camera.d.ts +8 -6
  55. package/dist/irdevice/camera.d.ts.map +1 -1
  56. package/dist/irdevice/camera.js +83 -68
  57. package/dist/irdevice/camera.js.map +1 -1
  58. package/dist/irdevice/fan.d.ts +7 -5
  59. package/dist/irdevice/fan.d.ts.map +1 -1
  60. package/dist/irdevice/fan.js +90 -75
  61. package/dist/irdevice/fan.js.map +1 -1
  62. package/dist/irdevice/light.d.ts +8 -6
  63. package/dist/irdevice/light.d.ts.map +1 -1
  64. package/dist/irdevice/light.js +83 -68
  65. package/dist/irdevice/light.js.map +1 -1
  66. package/dist/irdevice/other.d.ts +8 -6
  67. package/dist/irdevice/other.d.ts.map +1 -1
  68. package/dist/irdevice/other.js +93 -78
  69. package/dist/irdevice/other.js.map +1 -1
  70. package/dist/irdevice/tv.d.ts +8 -6
  71. package/dist/irdevice/tv.d.ts.map +1 -1
  72. package/dist/irdevice/tv.js +68 -52
  73. package/dist/irdevice/tv.js.map +1 -1
  74. package/dist/irdevice/vacuumcleaner.d.ts +8 -6
  75. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.js +83 -69
  77. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  78. package/dist/irdevice/waterheater.d.ts +2 -0
  79. package/dist/irdevice/waterheater.d.ts.map +1 -1
  80. package/dist/irdevice/waterheater.js +75 -60
  81. package/dist/irdevice/waterheater.js.map +1 -1
  82. package/dist/settings.d.ts +12 -11
  83. package/dist/settings.d.ts.map +1 -1
  84. package/dist/settings.js.map +1 -1
  85. package/package.json +1 -1
  86. package/src/device/bot.ts +200 -163
  87. package/src/device/colorbulb.ts +252 -221
  88. package/src/device/contact.ts +85 -66
  89. package/src/device/curtain.ts +165 -136
  90. package/src/device/humidifier.ts +126 -115
  91. package/src/device/lock.ts +156 -131
  92. package/src/device/meter.ts +85 -64
  93. package/src/device/meterplus.ts +78 -59
  94. package/src/device/motion.ts +76 -57
  95. package/src/device/plug.ts +132 -107
  96. package/src/device/striplight.ts +226 -198
  97. package/src/irdevice/airconditioner.ts +126 -103
  98. package/src/irdevice/airpurifier.ts +84 -66
  99. package/src/irdevice/camera.ts +84 -68
  100. package/src/irdevice/fan.ts +91 -75
  101. package/src/irdevice/light.ts +84 -68
  102. package/src/irdevice/other.ts +94 -78
  103. package/src/irdevice/tv.ts +69 -53
  104. package/src/irdevice/vacuumcleaner.ts +83 -68
  105. package/src/irdevice/waterheater.ts +76 -60
  106. package/src/settings.ts +12 -11
@@ -42,6 +42,7 @@ export class MeterPlus {
42
42
  humidity!: serviceData['humidity'];
43
43
 
44
44
  // Config
45
+ OpenAPI?: boolean;
45
46
  scanDuration!: number;
46
47
  deviceLogging!: string;
47
48
  deviceRefreshRate!: number;
@@ -53,6 +54,7 @@ export class MeterPlus {
53
54
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
54
55
  // default placeholders
55
56
  this.logs(device);
57
+ this.openAPI();
56
58
  this.scan(device);
57
59
  this.refreshRate(device);
58
60
  this.config(device);
@@ -86,11 +88,11 @@ export class MeterPlus {
86
88
 
87
89
  // Temperature Sensor Service
88
90
  if (device.meter?.hide_temperature) {
89
- this.debugLog(`Meter Plus: ${accessory.displayName} Removing Temperature Sensor Service`);
91
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
90
92
  this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor);
91
93
  accessory.removeService(this.temperatureservice!);
92
94
  } else if (!this.temperatureservice) {
93
- this.debugLog(`Meter Plus: ${accessory.displayName} Add Temperature Sensor Service`);
95
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
94
96
  (this.temperatureservice =
95
97
  this.accessory.getService(this.platform.Service.TemperatureSensor) || this.accessory.addService(this.platform.Service.TemperatureSensor)),
96
98
  `${accessory.displayName} Temperature Sensor`;
@@ -110,16 +112,16 @@ export class MeterPlus {
110
112
  return this.CurrentTemperature!;
111
113
  });
112
114
  } else {
113
- this.debugLog(`Meter Plus: ${accessory.displayName} Temperature Sensor Service Not Added`);
115
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Temperature Sensor Service Not Added`);
114
116
  }
115
117
 
116
118
  // Humidity Sensor Service
117
119
  if (device.meter?.hide_humidity) {
118
- this.debugLog(`Meter Plus: ${accessory.displayName} Removing Humidity Sensor Service`);
120
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Humidity Sensor Service`);
119
121
  this.humidityservice = this.accessory.getService(this.platform.Service.HumiditySensor);
120
122
  accessory.removeService(this.humidityservice!);
121
123
  } else if (!this.humidityservice) {
122
- this.debugLog(`Meter Plus: ${accessory.displayName} Add Humidity Sensor Service`);
124
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
123
125
  (this.humidityservice =
124
126
  this.accessory.getService(this.platform.Service.HumiditySensor) || this.accessory.addService(this.platform.Service.HumiditySensor)),
125
127
  `${accessory.displayName} Humidity Sensor`;
@@ -135,16 +137,16 @@ export class MeterPlus {
135
137
  return this.CurrentRelativeHumidity;
136
138
  });
137
139
  } else {
138
- this.debugLog(`Meter Plus: ${accessory.displayName} Humidity Sensor Service Not Added`);
140
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Humidity Sensor Service Not Added`);
139
141
  }
140
142
 
141
143
  // Battery Service
142
144
  if (!device.ble) {
143
- this.debugLog(`Meter Plus: ${accessory.displayName} Removing Battery Service`);
145
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
144
146
  this.batteryService = this.accessory.getService(this.platform.Service.Battery);
145
147
  accessory.removeService(this.batteryService!);
146
148
  } else if (device.ble && !this.batteryService) {
147
- this.debugLog(`Meter Plus: ${accessory.displayName} Add Battery Service`);
149
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
148
150
  (this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
149
151
  `${accessory.displayName} Battery`;
150
152
 
@@ -152,7 +154,7 @@ export class MeterPlus {
152
154
 
153
155
  this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
154
156
  } else {
155
- this.debugLog(`Meter Plus: ${accessory.displayName} Battery Service Not Added`);
157
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
156
158
  }
157
159
 
158
160
  // Retrieve initial values and updateHomekit
@@ -178,7 +180,7 @@ export class MeterPlus {
178
180
  }
179
181
 
180
182
  async BLEparseStatus(): Promise<void> {
181
- this.debugLog(`Meter Plus: ${this.accessory.displayName} BLE parseStatus`);
183
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE parseStatus`);
182
184
 
183
185
  // Battery
184
186
  this.BatteryLevel = Number(this.battery);
@@ -192,14 +194,14 @@ export class MeterPlus {
192
194
  // Humidity
193
195
  if (!this.device.meter?.hide_humidity) {
194
196
  this.CurrentRelativeHumidity = this.humidity!;
195
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Humidity: ${this.CurrentRelativeHumidity}%`);
197
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Humidity: ${this.CurrentRelativeHumidity}%`);
196
198
  }
197
199
 
198
200
  // Current Temperature
199
201
  if (!this.device.meter?.hide_temperature) {
200
202
  this.temperature < 0 ? 0 : this.temperature > 100 ? 100 : this.temperature;
201
203
  this.CurrentTemperature = this.temperature;
202
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c`);
204
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c`);
203
205
  }
204
206
  }
205
207
 
@@ -208,17 +210,17 @@ export class MeterPlus {
208
210
  this.SwitchToOpenAPI = false;
209
211
  }
210
212
  if (this.platform.config.credentials?.token) {
211
- this.debugLog(`Meter Plus: ${this.accessory.displayName} OpenAPI parseStatus`);
213
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI parseStatus`);
212
214
  // Current Relative Humidity
213
215
  if (!this.device.meter?.hide_humidity) {
214
216
  this.CurrentRelativeHumidity = this.Humidity!;
215
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Humidity: ${this.CurrentRelativeHumidity}%`);
217
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Humidity: ${this.CurrentRelativeHumidity}%`);
216
218
  }
217
219
 
218
220
  // Current Temperature
219
221
  if (!this.device.meter?.hide_temperature) {
220
222
  this.CurrentTemperature = this.Temperature!;
221
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c`);
223
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c`);
222
224
  }
223
225
  }
224
226
  }
@@ -235,14 +237,14 @@ export class MeterPlus {
235
237
  }
236
238
 
237
239
  async BLErefreshStatus(): Promise<void> {
238
- this.debugLog(`Meter Plus: ${this.accessory.displayName} BLE RefreshStatus`);
240
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE RefreshStatus`);
239
241
  const switchbot = await this.platform.connectBLE();
240
242
  // Convert to BLE Address
241
243
  this.device.bleMac = this.device
242
244
  .deviceId!.match(/.{1,2}/g)!
243
245
  .join(':')
244
246
  .toLowerCase();
245
- this.debugLog(`Meter Plus: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
247
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
246
248
  this.getCustomBLEAddress(switchbot);
247
249
  // Start to monitor advertisement packets
248
250
  if (switchbot !== false) {
@@ -258,26 +260,26 @@ export class MeterPlus {
258
260
  if (this.deviceLogging.includes('debug')) {
259
261
  this.infoLog(this.address);
260
262
  this.infoLog(this.device.bleMac);
261
- this.infoLog(`Meter Plus: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
262
- this.infoLog(`Meter Plus: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
263
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
264
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
263
265
  }
264
266
  this.serviceData = ad.serviceData;
265
267
  this.temperature = ad.serviceData.temperature!.c;
266
268
  this.humidity = ad.serviceData.humidity;
267
269
  this.battery = ad.serviceData.battery;
268
- this.debugLog(`Meter Plus: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
270
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
269
271
  this.debugLog(
270
- `Meter Plus: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName}, ` +
272
+ `${this.device.deviceType}: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName}, ` +
271
273
  `temperature: ${superStringify(ad.serviceData.temperature?.c)}, humidity: ${ad.serviceData.humidity}, ` +
272
274
  `battery: ${ad.serviceData.battery}`,
273
275
  );
274
276
 
275
277
  if (this.serviceData) {
276
278
  this.connected = true;
277
- this.debugLog(`Meter Plus: ${this.accessory.displayName} connected: ${this.connected}`);
279
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
278
280
  } else {
279
281
  this.connected = false;
280
- this.debugLog(`Meter Plus: ${this.accessory.displayName} connected: ${this.connected}`);
282
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
281
283
  }
282
284
  };
283
285
  // Wait 10 seconds
@@ -294,14 +296,15 @@ export class MeterPlus {
294
296
  }
295
297
  })
296
298
  .catch(async (e: any) => {
297
- this.errorLog(`Meter Plus: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
299
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
298
300
  if (this.deviceLogging.includes('debug')) {
299
301
  this.errorLog(
300
- `Meter Plus: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${superStringify(e.message)}`,
302
+ `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
303
+ + ` Error Message: ${superStringify(e.message)}`,
301
304
  );
302
305
  }
303
306
  if (this.platform.config.credentials?.token) {
304
- this.warnLog(`Meter Plus: ${this.accessory.displayName} Using OpenAPI Connection`);
307
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
305
308
  this.SwitchToOpenAPI = true;
306
309
  this.openAPIRefreshStatus();
307
310
  }
@@ -321,7 +324,7 @@ export class MeterPlus {
321
324
  });
322
325
  // Set an event handler
323
326
  switchbot.onadvertisement = (ad: any) => {
324
- this.warnLog(`Meter Plus: ${this.accessory.displayName} ad: ${superStringify(ad, null, ' ')}`);
327
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${superStringify(ad, null, ' ')}`);
325
328
  };
326
329
  await switchbot.wait(10000);
327
330
  // Stop to monitor
@@ -331,24 +334,24 @@ export class MeterPlus {
331
334
  }
332
335
 
333
336
  async BLEconnection(switchbot: any): Promise<void> {
334
- this.errorLog(`Meter Plus: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
337
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
335
338
  if (this.platform.config.credentials?.token) {
336
- this.warnLog(`Meter Plus: ${this.accessory.displayName} Using OpenAPI Connection`);
339
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
337
340
  this.SwitchToOpenAPI = true;
338
341
  await this.openAPIRefreshStatus();
339
342
  }
340
343
  }
341
344
 
342
345
  async openAPIRefreshStatus(): Promise<void> {
343
- if (this.platform.config.credentials?.token) {
344
- this.debugLog(`Meter Plus: ${this.accessory.displayName} OpenAPI RefreshStatus`);
346
+ if (this.platform.config.credentials?.token && this.OpenAPI) {
347
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI RefreshStatus`);
345
348
  try {
346
349
  const t = Date.now();
347
350
  const nonce = 'requestID';
348
351
  const data = this.platform.config.credentials?.token + t + nonce;
349
352
  const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
350
353
  const sign = signTerm.toString('base64');
351
- this.debugLog(`Meter Plus: ${this.accessory.displayName} sign: ${sign}`);
354
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
352
355
  const options = {
353
356
  hostname: HostDomain,
354
357
  port: 443,
@@ -363,39 +366,41 @@ export class MeterPlus {
363
366
  },
364
367
  };
365
368
  const req = https.request(options, (res) => {
366
- this.debugLog(`Meter Plus: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
369
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
367
370
  let rawData = '';
368
371
  res.on('data', (d) => {
369
372
  rawData += d;
370
- this.debugLog(`Meter Plus: ${this.accessory.displayName} d: ${d}`);
373
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
371
374
  });
372
375
  res.on('end', () => {
373
376
  try {
374
377
  this.deviceStatus = JSON.parse(rawData);
375
- this.debugLog(`Meter Plus: ${this.accessory.displayName} openAPIRefreshStatus: ${superStringify(this.deviceStatus)}`);
378
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus: ${superStringify(this.deviceStatus)}`);
376
379
  this.Humidity = this.deviceStatus.body.humidity!;
377
380
  this.Temperature = this.deviceStatus.body.temperature!;
378
381
  this.parseStatus();
379
382
  this.updateHomeKitCharacteristics();
380
383
  } catch (e: any) {
381
- this.errorLog(`Meter Plus: ${this.accessory.displayName} error message: ${e.message}`);
384
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
382
385
  }
383
386
  });
384
387
  });
385
388
  req.on('error', (e: any) => {
386
- this.errorLog(`Meter Plus: ${this.accessory.displayName} error message: ${e.message}`);
389
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
387
390
  });
388
391
  req.end();
389
392
  } catch (e: any) {
390
- this.errorLog(`Meter Plus: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
393
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
391
394
  if (this.deviceLogging.includes('debug')) {
392
395
  this.errorLog(
393
- `Meter Plus: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
396
+ `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
394
397
  ` Error Message: ${superStringify(e.message)}`,
395
398
  );
396
399
  }
397
400
  this.apiError(e);
398
401
  }
402
+ } else {
403
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, commands will not be sent.`);
399
404
  }
400
405
  }
401
406
 
@@ -405,32 +410,33 @@ export class MeterPlus {
405
410
  async updateHomeKitCharacteristics(): Promise<void> {
406
411
  if (!this.device.meter?.hide_humidity) {
407
412
  if (this.CurrentRelativeHumidity === undefined) {
408
- this.debugLog(`Meter Plus: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
413
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
409
414
  } else {
410
415
  this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
411
- this.debugLog(`Meter Plus: ${this.accessory.displayName} updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
416
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
417
+ + ` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
412
418
  }
413
419
  }
414
420
  if (!this.device.meter?.hide_temperature) {
415
421
  if (this.CurrentTemperature === undefined) {
416
- this.debugLog(`Meter Plus: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
422
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
417
423
  } else {
418
424
  this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
419
- this.debugLog(`Meter Plus: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
425
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
420
426
  }
421
427
  }
422
428
  if (this.device.ble) {
423
429
  if (this.BatteryLevel === undefined) {
424
- this.debugLog(`Meter Plus: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
430
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
425
431
  } else {
426
432
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
427
- this.debugLog(`Meter Plus: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
433
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
428
434
  }
429
435
  if (this.StatusLowBattery === undefined) {
430
- this.debugLog(`Meter Plus: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
436
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
431
437
  } else {
432
438
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
433
- this.debugLog(`Meter Plus: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
439
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
434
440
  }
435
441
  }
436
442
  }
@@ -467,6 +473,9 @@ export class MeterPlus {
467
473
  if (device.ble !== undefined) {
468
474
  config['ble'] = device.ble;
469
475
  }
476
+ if (device.openAPI !== undefined) {
477
+ config['openAPI'] = device.openAPI;
478
+ }
470
479
  if (device.logging !== undefined) {
471
480
  config['logging'] = device.logging;
472
481
  }
@@ -477,30 +486,39 @@ export class MeterPlus {
477
486
  config['scanDuration'] = device.scanDuration;
478
487
  }
479
488
  if (Object.entries(config).length !== 0) {
480
- this.infoLog(`Meter Plus: ${this.accessory.displayName} Config: ${superStringify(config)}`);
489
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
481
490
  }
482
491
  }
483
492
 
484
493
  async refreshRate(device: device & devicesConfig): Promise<void> {
485
494
  if (device.refreshRate) {
486
495
  this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
487
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
496
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
488
497
  } else if (this.platform.config.options!.refreshRate) {
489
498
  this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
490
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
499
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
500
+ }
501
+ }
502
+
503
+ async openAPI() {
504
+ if (!this.device.openAPI) {
505
+ this.OpenAPI = true;
506
+ } else {
507
+ this.OpenAPI = this.device.openAPI;
491
508
  }
509
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
492
510
  }
493
511
 
494
512
  async scan(device: device & devicesConfig): Promise<void> {
495
513
  if (device.scanDuration) {
496
514
  this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
497
515
  if (device.ble) {
498
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
516
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
499
517
  }
500
518
  } else {
501
519
  this.scanDuration = this.accessory.context.scanDuration = 1;
502
520
  if (this.device.ble) {
503
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
521
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
504
522
  }
505
523
  }
506
524
  }
@@ -508,24 +526,25 @@ export class MeterPlus {
508
526
  async logs(device: device & devicesConfig): Promise<void> {
509
527
  if (this.platform.debugMode) {
510
528
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
511
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
529
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
512
530
  } else if (device.logging) {
513
531
  this.deviceLogging = this.accessory.context.logging = device.logging;
514
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
532
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
515
533
  } else if (this.platform.config.options?.logging) {
516
534
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
517
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
535
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
518
536
  } else {
519
537
  this.deviceLogging = this.accessory.context.logging = 'standard';
520
- this.debugLog(`Meter Plus: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
538
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
521
539
  }
522
540
  }
523
541
 
524
542
  FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
525
543
  let FirmwareRevision: string;
526
- this.debugLog(`Meter Plus: ${this.accessory.displayName} accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
527
- this.debugLog(`Meter Plus: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
528
- this.debugLog(`Meter Plus: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
544
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
545
+ + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
546
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
547
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
529
548
  if (accessory.context.FirmwareRevision) {
530
549
  FirmwareRevision = accessory.context.FirmwareRevision;
531
550
  } else if (device.firmware) {