@switchbot/homebridge-switchbot 0.1.2-beta.11 → 0.1.2-beta.15

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 (43) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/devices/bots.d.ts.map +1 -1
  3. package/dist/devices/bots.js +10 -13
  4. package/dist/devices/bots.js.map +1 -1
  5. package/dist/devices/bulb.d.ts.map +1 -1
  6. package/dist/devices/bulb.js +4 -5
  7. package/dist/devices/bulb.js.map +1 -1
  8. package/dist/devices/contact.d.ts.map +1 -1
  9. package/dist/devices/contact.js +22 -14
  10. package/dist/devices/contact.js.map +1 -1
  11. package/dist/devices/curtains.d.ts.map +1 -1
  12. package/dist/devices/curtains.js +9 -12
  13. package/dist/devices/curtains.js.map +1 -1
  14. package/dist/devices/humidifiers.d.ts.map +1 -1
  15. package/dist/devices/humidifiers.js +4 -10
  16. package/dist/devices/humidifiers.js.map +1 -1
  17. package/dist/devices/indoorcam.d.ts.map +1 -1
  18. package/dist/devices/indoorcam.js +8 -11
  19. package/dist/devices/indoorcam.js.map +1 -1
  20. package/dist/devices/meters.d.ts.map +1 -1
  21. package/dist/devices/meters.js +14 -28
  22. package/dist/devices/meters.js.map +1 -1
  23. package/dist/devices/motion.d.ts.map +1 -1
  24. package/dist/devices/motion.js +6 -9
  25. package/dist/devices/motion.js.map +1 -1
  26. package/dist/devices/plugs.d.ts.map +1 -1
  27. package/dist/devices/plugs.js +8 -11
  28. package/dist/devices/plugs.js.map +1 -1
  29. package/dist/platform.d.ts +5 -0
  30. package/dist/platform.d.ts.map +1 -1
  31. package/dist/platform.js +44 -70
  32. package/dist/platform.js.map +1 -1
  33. package/package.json +3 -3
  34. package/src/devices/bots.ts +10 -16
  35. package/src/devices/bulb.ts +4 -9
  36. package/src/devices/contact.ts +19 -18
  37. package/src/devices/curtains.ts +9 -16
  38. package/src/devices/humidifiers.ts +4 -10
  39. package/src/devices/indoorcam.ts +8 -14
  40. package/src/devices/meters.ts +14 -33
  41. package/src/devices/motion.ts +6 -13
  42. package/src/devices/plugs.ts +8 -14
  43. package/src/platform.ts +47 -161
@@ -55,9 +55,7 @@ export class Bulb {
55
55
  const colon = device.deviceId!.match(/.{1,2}/g);
56
56
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
57
57
  this.device.bleMac = bleMac.toLowerCase();
58
- if (this.platform.config.options.debug === 'device') {
59
- this.platform.debug(this.device.bleMac.toLowerCase());
60
- }
58
+ this.platform.device(this.device.bleMac.toLowerCase());
61
59
  }
62
60
 
63
61
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -171,16 +169,13 @@ export class Bulb {
171
169
  ).data;
172
170
  if (deviceStatus.message === 'success') {
173
171
  this.deviceStatus = deviceStatus;
174
- this.platform.log.warn(`Plug ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
172
+ this.platform.device(`Plug ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
175
173
  this.parseStatus();
176
174
  this.updateHomeKitCharacteristics();
177
175
  }
178
176
  } catch (e: any) {
179
- this.platform.log.error(
180
- `Plug - Failed to refresh status of ${this.device.deviceName}`,
181
- JSON.stringify(e.message),
182
- this.platform.debug(`Plug ${this.accessory.displayName} - ${JSON.stringify(e)}`),
183
- );
177
+ this.platform.log.error(`Plug - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
178
+ this.platform.debug(`Plug ${this.accessory.displayName} - ${JSON.stringify(e)}`);
184
179
  this.apiError(e);
185
180
  }
186
181
  }
@@ -53,9 +53,7 @@ export class Contact {
53
53
  const colon = device.deviceId!.match(/.{1,2}/g);
54
54
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
55
55
  this.device.bleMac = bleMac.toLowerCase();
56
- if (this.platform.config.options.debug === 'device') {
57
- this.platform.debug(this.device.bleMac.toLowerCase());
58
- }
56
+ this.platform.device(this.device.bleMac.toLowerCase());
59
57
  }
60
58
  // this is subject we use to track when we need to POST changes to the SwitchBot API
61
59
  this.doContactUpdate = new Subject();
@@ -109,11 +107,15 @@ export class Contact {
109
107
  * Parse the device status from the SwitchBot api
110
108
  */
111
109
  parseStatus() {
112
- // Set Room Sensor State
113
- if (this.deviceStatus.body.openState) {
110
+ // Conact Sensor
111
+ if (this.deviceStatus.body.openState === 'open') {
114
112
  this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
115
- } else {
113
+ this.platform.log.info(`${this.accessory.displayName} ${this.deviceStatus.body.openState}`);
114
+ } else if (this.deviceStatus.body.openState === 'close') {
116
115
  this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
116
+ this.platform.device(`${this.accessory.displayName} ${this.deviceStatus.body.openState}`);
117
+ } else {
118
+ this.platform.device(`${this.accessory.displayName} ${this.deviceStatus.body.openState}`);
117
119
  }
118
120
  this.MotionDetected = Boolean(this.deviceStatus.body.moveDetected);
119
121
  this.platform.debug(`${this.accessory.displayName}
@@ -132,12 +134,10 @@ export class Contact {
132
134
  const colon = this.device.deviceId!.match(/.{1,2}/g);
133
135
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
134
136
  this.device.bleMac = bleMac.toLowerCase();
135
- if (this.platform.config.options.debug === 'device') {
136
- this.platform.debug(this.device.bleMac!);
137
- }
137
+ this.platform.device(this.device.bleMac!);
138
138
  switchbot.onadvertisement = (ad: any) => {
139
139
  this.platform.log.info(JSON.stringify(ad, null, ' '));
140
- this.platform.log.warn('ad:', JSON.stringify(ad));
140
+ this.platform.device('ad:', JSON.stringify(ad));
141
141
  };
142
142
  switchbot
143
143
  .startScan({
@@ -190,11 +190,8 @@ export class Contact {
190
190
  this.updateHomeKitCharacteristics();
191
191
  }
192
192
  } catch (e: any) {
193
- this.platform.log.error(
194
- 'Contact - Failed to update status of',
195
- this.device.deviceName,
196
- JSON.stringify(e.message),
197
- this.platform.debug(`Contact ${this.accessory.displayName} - ${JSON.stringify(e)}`));
193
+ this.platform.log.error(`Contact - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
194
+ this.platform.debug(`Contact ${this.accessory.displayName} - ${JSON.stringify(e)}`);
198
195
  this.apiError(e);
199
196
  }
200
197
  }
@@ -203,11 +200,15 @@ export class Contact {
203
200
  * Updates the status for each of the HomeKit Characteristics
204
201
  */
205
202
  updateHomeKitCharacteristics() {
206
- if (this.ContactSensorState !== undefined) {
203
+ if (this.ContactSensorState === undefined) {
204
+ this.platform.debug(`ContactSensorState: ${this.ContactSensorState}`);
205
+ } else {
207
206
  this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.ContactSensorState);
208
207
  }
209
- if (this.MotionDetected !== undefined) {
210
- this.motionService.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected);
208
+ if (this.MotionDetected === undefined) {
209
+ this.platform.debug(`ContactSensorState: ${this.ContactSensorState}`);
210
+ } else {
211
+ this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected);
211
212
  }
212
213
  }
213
214
 
@@ -71,9 +71,7 @@ export class Curtain {
71
71
  const colon = device.deviceId!.match(/.{1,2}/g);
72
72
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
73
73
  this.device.bleMac = bleMac.toLowerCase();
74
- if (this.platform.config.options.debug === 'device') {
75
- this.platform.debug(this.device.bleMac.toLowerCase());
76
- }
74
+ this.platform.device(this.device.bleMac.toLowerCase());
77
75
  }
78
76
 
79
77
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -191,7 +189,7 @@ export class Curtain {
191
189
 
192
190
  parseStatus() {
193
191
  if (this.platform.config.options?.ble?.includes(this.device.deviceId!)) {
194
- this.platform.log.warn('BLE DEVICE-3');
192
+ this.platform.device('Curtains BLE Device parseStatus');
195
193
  } else {
196
194
  // CurrentPosition
197
195
  this.setMinMax();
@@ -238,19 +236,17 @@ export class Curtain {
238
236
 
239
237
  async refreshStatus() {
240
238
  if (this.platform.config.options?.ble?.includes(this.device.deviceId!)) {
241
- this.platform.log.warn('BLE DEVICE-REFRESH-1');
239
+ this.platform.debug('Curtains BLE Device RefreshStatus');
242
240
  // eslint-disable-next-line @typescript-eslint/no-var-requires
243
241
  const Switchbot = require('node-switchbot');
244
242
  const switchbot = new Switchbot();
245
243
  const colon = this.device.deviceId!.match(/.{1,2}/g);
246
244
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
247
245
  this.device.bleMac = bleMac.toLowerCase();
248
- if (this.platform.config.options.debug === 'device') {
249
- this.platform.debug(this.device.bleMac!);
250
- }
246
+ this.platform.debug(this.device.bleMac!);
251
247
  switchbot.onadvertisement = (ad: any) => {
252
- this.platform.log.info(JSON.stringify(ad, null, ' '));
253
- this.platform.log.warn('ad:', JSON.stringify(ad));
248
+ this.platform.debug(JSON.stringify(ad, null, ' '));
249
+ this.platform.device(`ad: ${JSON.stringify(ad)}`);
254
250
  };
255
251
  switchbot
256
252
  .startScan({
@@ -304,18 +300,15 @@ export class Curtain {
304
300
  this.updateHomeKitCharacteristics();
305
301
  }
306
302
  } catch (e: any) {
307
- this.platform.log.error(
308
- `Curtain - Failed to refresh status of ${this.device.deviceName}`,
309
- JSON.stringify(e.message),
310
- this.platform.debug(`Curtain ${this.accessory.displayName} - ${JSON.stringify(e)}`),
311
- );
303
+ this.platform.log.error(`Curtain - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
304
+ this.platform.debug(`Curtain ${this.accessory.displayName} - ${JSON.stringify(e)}`);
312
305
  this.apiError(e);
313
306
  }
314
307
  }
315
308
 
316
309
  async pushChanges() {
317
310
  if (this.platform.config.options?.ble?.includes(this.device.deviceId!)) {
318
- this.platform.log.warn('BLE DEVICE-2');
311
+ this.platform.device('Curtains BLE Device pushChanges');
319
312
  } else {
320
313
  if (this.TargetPosition !== this.CurrentPosition) {
321
314
  this.platform.debug(`Pushing ${this.TargetPosition}`);
@@ -107,15 +107,11 @@ export class Humidifier {
107
107
  // create a new Temperature Sensor service
108
108
  // Temperature Sensor Service
109
109
  if (this.platform.config.options?.humidifier?.hide_temperature) {
110
- if (this.platform.config.options.debug === 'device') {
111
- this.platform.log.error('Removing service');
112
- }
110
+ this.platform.device('Removing Temerature Sensor Service');
113
111
  this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor);
114
112
  accessory.removeService(this.temperatureservice!);
115
113
  } else if (!this.temperatureservice) {
116
- if (this.platform.config.options?.debug === 'device') {
117
- this.platform.log.warn('Adding service');
118
- }
114
+ this.platform.device('Adding Temerature Sensor Service');
119
115
  (this.temperatureservice =
120
116
  this.accessory.getService(this.platform.Service.TemperatureSensor) ||
121
117
  this.accessory.addService(this.platform.Service.TemperatureSensor)), `${device.deviceName} ${device.deviceType} TemperatureSensor`;
@@ -133,7 +129,7 @@ export class Humidifier {
133
129
  });
134
130
  } else {
135
131
  if (this.platform.config.options?.debug) {
136
- this.platform.log.warn('TemperatureSensor not added.');
132
+ this.platform.device('Temperature Sensor Not Added');
137
133
  }
138
134
  }
139
135
 
@@ -175,9 +171,7 @@ export class Humidifier {
175
171
  // Current Relative Humidity
176
172
  this.CurrentRelativeHumidity = this.deviceStatus.body.humidity!;
177
173
  this.platform.debug(`Humidifier ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
178
- if (this.platform.config.options?.debug) {
179
- this.platform.log.warn(JSON.stringify(this.deviceStatus.body));
180
- }
174
+ this.platform.device(JSON.stringify(this.deviceStatus.body));
181
175
  // Water Level
182
176
  if (this.deviceStatus.body.lackWater) {
183
177
  this.WaterLevel = 0;
@@ -51,9 +51,7 @@ export class IndoorCam {
51
51
  const colon = device.deviceId!.match(/.{1,2}/g);
52
52
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
53
53
  this.device.bleMac = bleMac.toLowerCase();
54
- if (this.platform.config.options.debug === 'device') {
55
- this.platform.debug(this.device.bleMac.toLowerCase());
56
- }
54
+ this.platform.device(this.device.bleMac.toLowerCase());
57
55
  }
58
56
 
59
57
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -136,19 +134,17 @@ export class IndoorCam {
136
134
 
137
135
  async refreshStatus() {
138
136
  if (this.platform.config.options?.ble?.includes(this.device.deviceId!)) {
139
- this.platform.log.warn('BLE DEVICE-REFRESH');
137
+ this.platform.debug('IndoorCam BLE Device RefreshStatus');
140
138
  // eslint-disable-next-line @typescript-eslint/no-var-requires
141
139
  const Switchbot = require('node-switchbot');
142
140
  const switchbot = new Switchbot();
143
141
  const colon = this.device.deviceId!.match(/.{1,2}/g);
144
142
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
145
143
  this.device.bleMac = bleMac.toLowerCase();
146
- if (this.platform.config.options.debug === 'device') {
147
- this.platform.debug(this.device.bleMac!);
148
- }
144
+ this.platform.device(this.device.bleMac!);
149
145
  switchbot.onadvertisement = (ad: any) => {
150
- this.platform.log.info(JSON.stringify(ad, null, ' '));
151
- this.platform.log.warn('ad:', JSON.stringify(ad));
146
+ this.platform.debug(JSON.stringify(ad, null, ' '));
147
+ this.platform.device(`ad: ${JSON.stringify(ad)}`);
152
148
  };
153
149
  switchbot
154
150
  .startScan({
@@ -196,15 +192,13 @@ export class IndoorCam {
196
192
  ).data;
197
193
  if (deviceStatus.message === 'success') {
198
194
  this.deviceStatus = deviceStatus;
199
- this.platform.log.warn(`Camera ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
195
+ this.platform.device(`Camera ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
200
196
  this.parseStatus();
201
197
  this.updateHomeKitCharacteristics();
202
198
  }
203
199
  } catch (e: any) {
204
- this.platform.log.error(
205
- `Camera - Failed to refresh status of ${this.device.deviceName}`,
206
- JSON.stringify(e.message),
207
- this.platform.debug(`Camera ${this.accessory.displayName} - ${JSON.stringify(e)}`));
200
+ this.platform.log.error(`IndoorCam - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
201
+ this.platform.debug(`IndoorCam ${this.accessory.displayName} - ${JSON.stringify(e)}`);
208
202
  this.apiError(e);
209
203
  }
210
204
  }
@@ -65,9 +65,7 @@ export class Meter {
65
65
  const colon = device.deviceId!.match(/.{1,2}/g);
66
66
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
67
67
  this.device.bleMac = bleMac.toLowerCase();
68
- if (this.platform.config.options.debug === 'device') {
69
- this.platform.debug(this.device.bleMac.toLowerCase());
70
- }
68
+ this.platform.device(this.device.bleMac.toLowerCase());
71
69
  }
72
70
 
73
71
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -106,15 +104,11 @@ export class Meter {
106
104
 
107
105
  // Temperature Sensor Service
108
106
  if (this.platform.config.options?.meter?.hide_temperature) {
109
- if (this.platform.config.options.debug === 'device') {
110
- this.platform.log.error('Removing service');
111
- }
107
+ this.platform.device('Removing Temperature Sensor Service');
112
108
  this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor);
113
109
  accessory.removeService(this.temperatureservice!);
114
110
  } else if (!this.temperatureservice) {
115
- if (this.platform.config.options?.debug === 'device') {
116
- this.platform.log.warn('Adding service');
117
- }
111
+ this.platform.device('Adding Temperature Sensor Service');
118
112
  (this.temperatureservice =
119
113
  this.accessory.getService(this.platform.Service.TemperatureSensor) ||
120
114
  this.accessory.addService(this.platform.Service.TemperatureSensor)), `${device.deviceName} ${device.deviceType} TemperatureSensor`;
@@ -131,21 +125,17 @@ export class Meter {
131
125
  .onGet(() => {
132
126
  return this.CurrentTemperature;
133
127
  });
134
- //this.platform.log.info(this.device.deviceName + ' current temperature: ' + this.CurrentTemperature + '\u2103');
135
128
  } else {
136
- if (this.platform.config.options?.debug === 'device') {
137
- this.platform.log.warn('TemperatureSensor not added.');
138
- }
129
+ this.platform.device('Temperature Sensor Not Added');
139
130
  }
140
131
 
141
132
  // Humidity Sensor Service
142
133
  if (this.platform.config.options?.meter?.hide_humidity) {
143
- if (this.platform.config.options.debug === 'device') {
144
- this.platform.log.error('Removing service');
145
- }
134
+ this.platform.device('Removing Humidity Sensor Service');
146
135
  this.humidityservice = this.accessory.getService(this.platform.Service.HumiditySensor);
147
136
  accessory.removeService(this.humidityservice!);
148
137
  } else if (!this.humidityservice) {
138
+ this.platform.device('Adding Humidity Sensor Service');
149
139
  (this.humidityservice =
150
140
  this.accessory.getService(this.platform.Service.HumiditySensor) ||
151
141
  this.accessory.addService(this.platform.Service.HumiditySensor)), `${device.deviceName} ${device.deviceType} HumiditySensor`;
@@ -158,11 +148,8 @@ export class Meter {
158
148
  .onGet(() => {
159
149
  return this.CurrentRelativeHumidity;
160
150
  });
161
- //this.platform.log.info(this.device.deviceName + ' current humidity: ' + this.CurrentRelativeHumidity + '%');
162
151
  } else {
163
- if (this.platform.config.options?.debug) {
164
- this.platform.log.warn('HumiditySensor not added.');
165
- }
152
+ this.platform.device('Adding Humidity Sensor Not Added');
166
153
  }
167
154
 
168
155
  // Retrieve initial values and updateHomekit
@@ -230,14 +217,12 @@ export class Meter {
230
217
  const colon = this.device.deviceId!.match(/.{1,2}/g);
231
218
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
232
219
  this.device.bleMac = bleMac.toLowerCase();
233
- if (this.platform.config.options.debug === 'device') {
234
- this.platform.debug(this.device.bleMac!);
235
- }
220
+ this.platform.device(this.device.bleMac!);
236
221
  switchbot.onadvertisement = (ad: any) => {
237
- this.platform.log.info(JSON.stringify(ad, null, ' '));
238
- this.platform.log.warn('ad:', JSON.stringify(ad));
239
- this.platform.log.info('Temperature:', ad.serviceData.temperature.c);
240
- this.platform.log.info('Humidity:', ad.serviceData.humidity);
222
+ this.platform.debug(JSON.stringify(ad, null, ' '));
223
+ this.platform.device('ad:', JSON.stringify(ad));
224
+ this.platform.device(`Temperature: ${ad.serviceData.temperature.c}`);
225
+ this.platform.device(`Humidity: ${ad.serviceData.humidity}`);
241
226
  this.BLEtemperature = ad.serviceData.temperature.c;
242
227
  this.BLEHumidity = ad.serviceData.humidity;
243
228
  };
@@ -291,12 +276,8 @@ export class Meter {
291
276
  this.updateHomeKitCharacteristics();
292
277
  }
293
278
  } catch (e: any) {
294
- this.platform.log.error(
295
- 'Meter - Failed to update status of',
296
- this.device.deviceName,
297
- JSON.stringify(e.message),
298
- this.platform.debug(`Meter ${this.accessory.displayName} - ${JSON.stringify(e)}`),
299
- );
279
+ this.platform.log.error(`Meter - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
280
+ this.platform.debug(`Meter ${this.accessory.displayName} - ${JSON.stringify(e)}`);
300
281
  this.apiError(e);
301
282
  }
302
283
  }
@@ -53,9 +53,7 @@ export class Motion {
53
53
  const colon = device.deviceId!.match(/.{1,2}/g);
54
54
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
55
55
  this.device.bleMac = bleMac.toLowerCase();
56
- if (this.platform.config.options.debug === 'device') {
57
- this.platform.debug(this.device.bleMac.toLowerCase());
58
- }
56
+ this.platform.device(this.device.bleMac.toLowerCase());
59
57
  }
60
58
 
61
59
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -124,12 +122,10 @@ export class Motion {
124
122
  const colon = this.device.deviceId!.match(/.{1,2}/g);
125
123
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
126
124
  this.device.bleMac = bleMac.toLowerCase();
127
- if (this.platform.config.options.debug === 'device') {
128
- this.platform.debug(this.device.bleMac!);
129
- }
125
+ this.platform.device(this.device.bleMac!);
130
126
  switchbot.onadvertisement = (ad: any) => {
131
- this.platform.log.info(JSON.stringify(ad, null, ' '));
132
- this.platform.log.warn('ad:', JSON.stringify(ad));
127
+ this.platform.debug(JSON.stringify(ad, null, ' '));
128
+ this.platform.device('ad:', JSON.stringify(ad));
133
129
  };
134
130
  switchbot
135
131
  .startScan({
@@ -182,11 +178,8 @@ export class Motion {
182
178
  this.updateHomeKitCharacteristics();
183
179
  }
184
180
  } catch (e: any) {
185
- this.platform.log.error(
186
- 'Motion - Failed to update status of',
187
- this.device.deviceName,
188
- JSON.stringify(e.message),
189
- this.platform.debug(`Motion ${this.accessory.displayName} - ${JSON.stringify(e)}`));
181
+ this.platform.log.error(`Motion - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
182
+ this.platform.debug(`Motion ${this.accessory.displayName} - ${JSON.stringify(e)}`);
190
183
  this.apiError(e);
191
184
  }
192
185
  }
@@ -51,9 +51,7 @@ export class Plug {
51
51
  const colon = device.deviceId!.match(/.{1,2}/g);
52
52
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
53
53
  this.device.bleMac = bleMac.toLowerCase();
54
- if (this.platform.config.options.debug === 'device') {
55
- this.platform.debug(this.device.bleMac.toLowerCase());
56
- }
54
+ this.platform.device(this.device.bleMac.toLowerCase());
57
55
  }
58
56
 
59
57
  // this is subject we use to track when we need to POST changes to the SwitchBot API
@@ -136,19 +134,17 @@ export class Plug {
136
134
 
137
135
  async refreshStatus() {
138
136
  if (this.platform.config.options?.ble?.includes(this.device.deviceId!)) {
139
- this.platform.log.warn('BLE DEVICE-REFRESH');
137
+ this.platform.debug('Plug BLE Device RefreshStatus');
140
138
  // eslint-disable-next-line @typescript-eslint/no-var-requires
141
139
  const Switchbot = require('node-switchbot');
142
140
  const switchbot = new Switchbot();
143
141
  const colon = this.device.deviceId!.match(/.{1,2}/g);
144
142
  const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
145
143
  this.device.bleMac = bleMac.toLowerCase();
146
- if (this.platform.config.options.debug === 'device') {
147
- this.platform.debug(this.device.bleMac!);
148
- }
144
+ this.platform.device(this.device.bleMac!);
149
145
  switchbot.onadvertisement = (ad: any) => {
150
- this.platform.log.info(JSON.stringify(ad, null, ' '));
151
- this.platform.log.warn('ad:', JSON.stringify(ad));
146
+ this.platform.debug(JSON.stringify(ad, null, ' '));
147
+ this.platform.device('ad:', JSON.stringify(ad));
152
148
  };
153
149
  switchbot
154
150
  .startScan({
@@ -196,15 +192,13 @@ export class Plug {
196
192
  ).data;
197
193
  if (deviceStatus.message === 'success') {
198
194
  this.deviceStatus = deviceStatus;
199
- this.platform.log.warn(`Plug ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
195
+ this.platform.device(`Plug ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
200
196
  this.parseStatus();
201
197
  this.updateHomeKitCharacteristics();
202
198
  }
203
199
  } catch (e: any) {
204
- this.platform.log.error(
205
- `Plug - Failed to refresh status of ${this.device.deviceName}`,
206
- JSON.stringify(e.message),
207
- this.platform.debug(`Plug ${this.accessory.displayName} - ${JSON.stringify(e)}`));
200
+ this.platform.log.error(`Plug - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
201
+ this.platform.debug(`Plug ${this.accessory.displayName} - ${JSON.stringify(e)}`);
208
202
  this.apiError(e);
209
203
  }
210
204
  }