@switchbot/homebridge-switchbot 2.0.0-beta.17 → 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.
- package/CHANGELOG.md +1 -1
- package/config.schema.json +14 -4
- package/dist/device/bot.d.ts +2 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +201 -163
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts +2 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +250 -218
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +85 -66
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +166 -136
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +126 -115
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +2 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +156 -130
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +2 -0
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +85 -64
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +2 -0
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +78 -59
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +76 -57
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +2 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +133 -107
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +2 -0
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +224 -195
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -0
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +127 -105
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +2 -0
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +83 -66
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +8 -6
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +83 -68
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +7 -5
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +90 -75
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +8 -6
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +83 -68
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +8 -6
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +93 -78
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -6
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +68 -52
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +8 -6
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +83 -69
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +2 -0
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +75 -60
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +12 -11
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/device/bot.ts +200 -163
- package/src/device/colorbulb.ts +252 -221
- package/src/device/contact.ts +85 -66
- package/src/device/curtain.ts +165 -136
- package/src/device/humidifier.ts +126 -115
- package/src/device/lock.ts +156 -131
- package/src/device/meter.ts +85 -64
- package/src/device/meterplus.ts +78 -59
- package/src/device/motion.ts +76 -57
- package/src/device/plug.ts +132 -107
- package/src/device/striplight.ts +226 -198
- package/src/irdevice/airconditioner.ts +126 -103
- package/src/irdevice/airpurifier.ts +84 -66
- package/src/irdevice/camera.ts +84 -68
- package/src/irdevice/fan.ts +91 -75
- package/src/irdevice/light.ts +84 -68
- package/src/irdevice/other.ts +94 -78
- package/src/irdevice/tv.ts +69 -53
- package/src/irdevice/vacuumcleaner.ts +83 -68
- package/src/irdevice/waterheater.ts +76 -60
- package/src/settings.ts +12 -11
package/src/device/meterplus.ts
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
262
|
-
this.infoLog(
|
|
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(
|
|
270
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
|
|
269
271
|
this.debugLog(
|
|
270
|
-
|
|
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(
|
|
279
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
278
280
|
} else {
|
|
279
281
|
this.connected = false;
|
|
280
|
-
this.debugLog(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
433
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
428
434
|
}
|
|
429
435
|
if (this.StatusLowBattery === undefined) {
|
|
430
|
-
this.debugLog(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
527
|
-
|
|
528
|
-
this.debugLog(
|
|
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) {
|