@switchbot/homebridge-switchbot 1.8.3-beta.0 → 1.9.0

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 (105) hide show
  1. package/.eslintrc +1 -1
  2. package/.vscode/settings.json +1 -1
  3. package/CHANGELOG.md +8 -0
  4. package/config.schema.json +9 -0
  5. package/dist/devices/bots.d.ts +37 -34
  6. package/dist/devices/bots.d.ts.map +1 -1
  7. package/dist/devices/bots.js +196 -243
  8. package/dist/devices/bots.js.map +1 -1
  9. package/dist/devices/colorbulb.d.ts +50 -50
  10. package/dist/devices/colorbulb.d.ts.map +1 -1
  11. package/dist/devices/colorbulb.js +131 -145
  12. package/dist/devices/colorbulb.js.map +1 -1
  13. package/dist/devices/contact.d.ts +29 -27
  14. package/dist/devices/contact.d.ts.map +1 -1
  15. package/dist/devices/contact.js +115 -138
  16. package/dist/devices/contact.js.map +1 -1
  17. package/dist/devices/curtains.d.ts +31 -29
  18. package/dist/devices/curtains.d.ts.map +1 -1
  19. package/dist/devices/curtains.js +176 -211
  20. package/dist/devices/curtains.js.map +1 -1
  21. package/dist/devices/humidifiers.d.ts +33 -33
  22. package/dist/devices/humidifiers.d.ts.map +1 -1
  23. package/dist/devices/humidifiers.js +189 -214
  24. package/dist/devices/humidifiers.js.map +1 -1
  25. package/dist/devices/meters.d.ts +31 -30
  26. package/dist/devices/meters.d.ts.map +1 -1
  27. package/dist/devices/meters.js +100 -124
  28. package/dist/devices/meters.js.map +1 -1
  29. package/dist/devices/motion.d.ts +26 -25
  30. package/dist/devices/motion.d.ts.map +1 -1
  31. package/dist/devices/motion.js +102 -120
  32. package/dist/devices/motion.js.map +1 -1
  33. package/dist/devices/plugs.d.ts +23 -23
  34. package/dist/devices/plugs.d.ts.map +1 -1
  35. package/dist/devices/plugs.js +63 -81
  36. package/dist/devices/plugs.js.map +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +3 -22
  40. package/dist/index.js.map +1 -1
  41. package/dist/irdevices/airconditioners.d.ts +6 -6
  42. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  43. package/dist/irdevices/airconditioners.js +79 -105
  44. package/dist/irdevices/airconditioners.js.map +1 -1
  45. package/dist/irdevices/airpurifiers.d.ts +5 -5
  46. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  47. package/dist/irdevices/airpurifiers.js +42 -56
  48. package/dist/irdevices/airpurifiers.js.map +1 -1
  49. package/dist/irdevices/cameras.d.ts +5 -5
  50. package/dist/irdevices/cameras.d.ts.map +1 -1
  51. package/dist/irdevices/cameras.js +27 -31
  52. package/dist/irdevices/cameras.js.map +1 -1
  53. package/dist/irdevices/fans.d.ts +5 -5
  54. package/dist/irdevices/fans.d.ts.map +1 -1
  55. package/dist/irdevices/fans.js +38 -45
  56. package/dist/irdevices/fans.js.map +1 -1
  57. package/dist/irdevices/lights.d.ts +5 -5
  58. package/dist/irdevices/lights.d.ts.map +1 -1
  59. package/dist/irdevices/lights.js +33 -37
  60. package/dist/irdevices/lights.js.map +1 -1
  61. package/dist/irdevices/others.d.ts +5 -5
  62. package/dist/irdevices/others.d.ts.map +1 -1
  63. package/dist/irdevices/others.js +29 -34
  64. package/dist/irdevices/others.js.map +1 -1
  65. package/dist/irdevices/tvs.d.ts +5 -5
  66. package/dist/irdevices/tvs.d.ts.map +1 -1
  67. package/dist/irdevices/tvs.js +76 -91
  68. package/dist/irdevices/tvs.js.map +1 -1
  69. package/dist/irdevices/vacuumcleaners.d.ts +5 -5
  70. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  71. package/dist/irdevices/vacuumcleaners.js +27 -31
  72. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  73. package/dist/irdevices/waterheaters.d.ts +5 -5
  74. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  75. package/dist/irdevices/waterheaters.js +27 -31
  76. package/dist/irdevices/waterheaters.js.map +1 -1
  77. package/dist/platform.d.ts +12 -12
  78. package/dist/platform.d.ts.map +1 -1
  79. package/dist/platform.js +172 -241
  80. package/dist/platform.js.map +1 -1
  81. package/dist/settings.d.ts +2 -1
  82. package/dist/settings.d.ts.map +1 -1
  83. package/dist/settings.js +4 -4
  84. package/dist/settings.js.map +1 -1
  85. package/package.json +71 -72
  86. package/src/devices/bots.ts +455 -929
  87. package/src/devices/colorbulb.ts +246 -473
  88. package/src/devices/contact.ts +208 -381
  89. package/src/devices/curtains.ts +321 -613
  90. package/src/devices/humidifiers.ts +323 -594
  91. package/src/devices/meters.ts +186 -331
  92. package/src/devices/motion.ts +184 -327
  93. package/src/devices/plugs.ts +107 -175
  94. package/src/index.ts +5 -5
  95. package/src/irdevices/airconditioners.ts +149 -360
  96. package/src/irdevices/airpurifiers.ts +80 -178
  97. package/src/irdevices/cameras.ts +51 -109
  98. package/src/irdevices/fans.ts +77 -174
  99. package/src/irdevices/lights.ts +57 -110
  100. package/src/irdevices/others.ts +62 -137
  101. package/src/irdevices/tvs.ts +124 -249
  102. package/src/irdevices/vacuumcleaners.ts +52 -112
  103. package/src/irdevices/waterheaters.ts +53 -115
  104. package/src/platform.ts +357 -768
  105. package/src/settings.ts +24 -17
@@ -1,8 +1,8 @@
1
- import * as homebridge from "homebridge";
2
- import * as rxjs from "rxjs";
3
- import * as operators from "rxjs/operators";
4
- import * as platform from "../platform";
5
- import * as settings from "../settings";
1
+ import { interval, Subject } from 'rxjs';
2
+ import { skipWhile } from 'rxjs/operators';
3
+ import { SwitchBotPlatform } from '../platform';
4
+ import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
5
+ import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse, deviceStatus } from '../settings';
6
6
 
7
7
  /**
8
8
  * Platform Accessory
@@ -11,32 +11,33 @@ import * as settings from "../settings";
11
11
  */
12
12
  export class Contact {
13
13
  // Services
14
- private service: homebridge.Service;
15
- private motionService?: homebridge.Service;
16
- private lightSensorService?: homebridge.Service;
17
- private batteryService?: homebridge.Service;
14
+ private service: Service;
15
+ private motionService?: Service;
16
+ private lightSensorService?: Service;
17
+ private batteryService?: Service;
18
18
 
19
19
  // Characteristic Values
20
- ContactSensorState!: homebridge.CharacteristicValue;
21
- MotionDetected!: homebridge.CharacteristicValue;
22
- CurrentAmbientLightLevel!: homebridge.CharacteristicValue;
23
- BatteryLevel!: homebridge.CharacteristicValue;
24
- StatusLowBattery!: homebridge.CharacteristicValue;
20
+ ContactSensorState!: CharacteristicValue;
21
+ MotionDetected!: CharacteristicValue;
22
+ CurrentAmbientLightLevel!: CharacteristicValue;
23
+ BatteryLevel!: CharacteristicValue;
24
+ StatusLowBattery!: CharacteristicValue;
25
25
 
26
26
  // OpenAPI others
27
- openState: settings.deviceStatus["openState"];
28
- moveDetected: settings.deviceStatus["moveDetected"];
29
- brightness: settings.deviceStatus["brightness"];
30
- deviceStatus!: settings.deviceStatusResponse;
27
+ openState: deviceStatus['openState'];
28
+ moveDetected: deviceStatus['moveDetected'];
29
+ brightness: deviceStatus['brightness'];
30
+ deviceStatus!: deviceStatusResponse;
31
31
 
32
32
  // BLE Others
33
33
  connected?: boolean;
34
+ switchbot!: switchbot;
34
35
  SwitchToOpenAPI!: boolean;
35
- serviceData!: settings.serviceData;
36
- battery!: settings.serviceData["battery"];
37
- movement!: settings.serviceData["movement"];
38
- doorState!: settings.serviceData["doorState"];
39
- lightLevel!: settings.serviceData["lightLevel"];
36
+ serviceData!: serviceData;
37
+ battery!: serviceData['battery'];
38
+ movement!: serviceData['movement'];
39
+ doorState!: serviceData['doorState'];
40
+ lightLevel!: serviceData['lightLevel'];
40
41
 
41
42
  // Config
42
43
  set_minLux!: number;
@@ -47,23 +48,22 @@ export class Contact {
47
48
 
48
49
  // Updates
49
50
  contactUbpdateInProgress!: boolean;
50
- doContactUpdate!: rxjs.Subject<void>;
51
+ doContactUpdate!: Subject<void>;
51
52
 
52
53
  constructor(
53
- private readonly platform: platform.SwitchBotPlatform,
54
- private accessory: homebridge.PlatformAccessory,
55
- public device: settings.device & settings.devicesConfig,
54
+ private readonly platform: SwitchBotPlatform,
55
+ private accessory: PlatformAccessory,
56
+ public device: device & devicesConfig,
56
57
  ) {
57
58
  // default placeholders
58
59
  this.logs(device);
59
60
  this.scan(device);
60
61
  this.refreshRate(device);
61
62
  this.config(device);
62
- this.ContactSensorState =
63
- this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
63
+ this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
64
64
 
65
65
  // this is subject we use to track when we need to POST changes to the SwitchBot API
66
- this.doContactUpdate = new rxjs.Subject();
66
+ this.doContactUpdate = new Subject();
67
67
  this.contactUbpdateInProgress = false;
68
68
 
69
69
  // Retrieve initial values and updateHomekit
@@ -72,22 +72,15 @@ export class Contact {
72
72
  // set accessory information
73
73
  accessory
74
74
  .getService(this.platform.Service.AccessoryInformation)!
75
- .setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
76
- .setCharacteristic(
77
- this.platform.Characteristic.Model,
78
- "SWITCHBOT-WOCONTACT-W1201500",
79
- )
80
- .setCharacteristic(
81
- this.platform.Characteristic.SerialNumber,
82
- device.deviceId!,
83
- );
75
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
76
+ .setCharacteristic(this.platform.Characteristic.Model, 'SWITCHBOT-WOCONTACT-W1201500')
77
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
84
78
 
85
79
  // get the Contact service if it exists, otherwise create a new Contact service
86
80
  // you can create multiple services for each accessory
87
81
  (this.service =
88
82
  accessory.getService(this.platform.Service.ContactSensor) ||
89
- accessory.addService(this.platform.Service.ContactSensor)),
90
- `${accessory.displayName} Contact Sensor`;
83
+ accessory.addService(this.platform.Service.ContactSensor)), `${accessory.displayName} Contact Sensor`;
91
84
 
92
85
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
93
86
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -95,105 +88,68 @@ export class Contact {
95
88
 
96
89
  // set the service name, this is what is displayed as the default name on the Home app
97
90
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
98
- this.service.setCharacteristic(
99
- this.platform.Characteristic.Name,
100
- accessory.displayName,
101
- );
91
+ this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
102
92
 
103
93
  // each service must implement at-minimum the "required characteristics" for the given service type
104
94
  // see https://developers.homebridge.io/#/service/ContactSensor
105
95
 
106
96
  // Motion Sensor Service
107
97
  if (device.contact?.hide_motionsensor) {
108
- this.debugLog(
109
- `Contact Sensor: ${accessory.displayName} Removing Motion Sensor Service`,
110
- );
111
- this.motionService = this.accessory.getService(
112
- this.platform.Service.MotionSensor,
113
- );
98
+ this.debugLog(`Contact Sensor: ${accessory.displayName} Removing Motion Sensor Service`);
99
+ this.motionService = this.accessory.getService(this.platform.Service.MotionSensor);
114
100
  accessory.removeService(this.motionService!);
115
101
  } else if (!this.motionService) {
116
- this.debugLog(
117
- `Contact Sensor: ${accessory.displayName} Add Motion Sensor Service`,
118
- );
102
+ this.debugLog(`Contact Sensor: ${accessory.displayName} Add Motion Sensor Service`);
119
103
  (this.motionService =
120
104
  this.accessory.getService(this.platform.Service.MotionSensor) ||
121
- this.accessory.addService(this.platform.Service.MotionSensor)),
122
- `${accessory.displayName} Motion Sensor`;
105
+ this.accessory.addService(this.platform.Service.MotionSensor)), `${accessory.displayName} Motion Sensor`;
106
+
107
+ this.motionService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Motion Sensor`);
123
108
 
124
- this.motionService.setCharacteristic(
125
- this.platform.Characteristic.Name,
126
- `${accessory.displayName} Motion Sensor`,
127
- );
128
109
  } else {
129
- this.debugLog(
130
- `Contact Sensor: ${accessory.displayName} Motion Sensor Service Not Added`,
131
- );
110
+ this.debugLog(`Contact Sensor: ${accessory.displayName} Motion Sensor Service Not Added`);
132
111
  }
133
112
 
134
113
  // Light Sensor Service
135
114
  if (device.contact?.hide_lightsensor) {
136
- this.debugLog(
137
- `Contact Sensor: ${accessory.displayName} Removing Light Sensor Service`,
138
- );
139
- this.lightSensorService = this.accessory.getService(
140
- this.platform.Service.LightSensor,
141
- );
115
+ this.debugLog(`Contact Sensor: ${accessory.displayName} Removing Light Sensor Service`);
116
+ this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor);
142
117
  accessory.removeService(this.lightSensorService!);
143
118
  } else if (!this.lightSensorService) {
144
- this.debugLog(
145
- `Contact Sensor: ${accessory.displayName} Add Light Sensor Service`,
146
- );
119
+ this.debugLog(`Contact Sensor: ${accessory.displayName} Add Light Sensor Service`);
147
120
  (this.lightSensorService =
148
121
  this.accessory.getService(this.platform.Service.LightSensor) ||
149
- this.accessory.addService(this.platform.Service.LightSensor)),
150
- `${accessory.displayName} Light Sensor`;
122
+ this.accessory.addService(this.platform.Service.LightSensor)), `${accessory.displayName} Light Sensor`;
123
+
124
+ this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
151
125
 
152
- this.lightSensorService.setCharacteristic(
153
- this.platform.Characteristic.Name,
154
- `${accessory.displayName} Light Sensor`,
155
- );
156
126
  } else {
157
- this.debugLog(
158
- `Contact Sensor: ${accessory.displayName} Light Sensor Service Not Added`,
159
- );
127
+ this.debugLog(`Contact Sensor: ${accessory.displayName} Light Sensor Service Not Added`);
160
128
  }
161
129
 
162
130
  // Battery Service
163
131
  if (!device.ble) {
164
- this.debugLog(
165
- `Contact Sensor: ${accessory.displayName} Removing Battery Service`,
166
- );
167
- this.batteryService = this.accessory.getService(
168
- this.platform.Service.Battery,
169
- );
132
+ this.debugLog(`Contact Sensor: ${accessory.displayName} Removing Battery Service`);
133
+ this.batteryService = this.accessory.getService(this.platform.Service.Battery);
170
134
  accessory.removeService(this.batteryService!);
171
135
  } else if (device.ble && !this.batteryService) {
172
- this.debugLog(
173
- `Contact Sensor: ${accessory.displayName} Add Battery Service`,
174
- );
136
+ this.debugLog(`Contact Sensor: ${accessory.displayName} Add Battery Service`);
175
137
  (this.batteryService =
176
138
  this.accessory.getService(this.platform.Service.Battery) ||
177
- this.accessory.addService(this.platform.Service.Battery)),
178
- `${accessory.displayName} Battery`;
139
+ this.accessory.addService(this.platform.Service.Battery)), `${accessory.displayName} Battery`;
140
+
141
+ this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
179
142
 
180
- this.batteryService.setCharacteristic(
181
- this.platform.Characteristic.Name,
182
- `${accessory.displayName} Battery`,
183
- );
184
143
  } else {
185
- this.debugLog(
186
- `Contact Sensor: ${accessory.displayName} Battery Service Not Added`,
187
- );
144
+ this.debugLog(`Contact Sensor: ${accessory.displayName} Battery Service Not Added`);
188
145
  }
189
146
 
190
147
  // Retrieve initial values and updateHomekit
191
148
  this.updateHomeKitCharacteristics();
192
149
 
193
150
  // Start an update interval
194
- rxjs
195
- .interval(this.deviceRefreshRate * 1000)
196
- .pipe(operators.skipWhile(() => this.contactUbpdateInProgress))
151
+ interval(this.deviceRefreshRate * 1000)
152
+ .pipe(skipWhile(() => this.contactUbpdateInProgress))
197
153
  .subscribe(() => {
198
154
  this.refreshStatus();
199
155
  });
@@ -211,65 +167,51 @@ export class Contact {
211
167
  }
212
168
 
213
169
  async BLEparseStatus() {
214
- this.debugLog(
215
- `Contact Sensor: ${this.accessory.displayName} BLE parseStatus`,
216
- );
170
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} BLE parseStatus`);
217
171
  // Door State
218
172
  switch (this.doorState) {
219
- case "open":
173
+ case 'open':
220
174
  case 1:
221
- this.ContactSensorState =
222
- this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
175
+ this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
223
176
  break;
224
- case "close":
177
+ case 'close':
225
178
  case 0:
226
- this.ContactSensorState =
227
- this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
179
+ this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
228
180
  break;
229
181
  default:
230
- this.errorLog(
231
- `Contact Sensor: ${this.accessory.displayName} timeout no closed, doorstate: ${this.doorState}`,
232
- );
182
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} timeout no closed, doorstate: ${this.doorState}`);
233
183
  }
234
184
  // Movement
235
185
  if (!this.device.contact?.hide_motionsensor) {
236
186
  this.MotionDetected = Boolean(this.movement);
237
- this.debugLog(
238
- `Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`,
239
- );
187
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
240
188
  }
241
189
  // Light Level
242
190
  if (!this.device.contact?.hide_lightsensor) {
243
191
  this.set_minLux = this.minLux();
244
192
  this.set_maxLux = this.maxLux();
245
193
  switch (this.lightLevel) {
246
- case "dark":
194
+ case 'dark':
247
195
  case 0:
248
196
  this.CurrentAmbientLightLevel = this.set_minLux;
249
197
  break;
250
198
  default:
251
199
  this.CurrentAmbientLightLevel = this.set_maxLux;
252
200
  }
253
- this.debugLog(
254
- `Contact Sensor: ${this.accessory.displayName} LightLevel: ${this.lightLevel},` +
255
- ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
256
- );
201
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} LightLevel: ${this.lightLevel},`
202
+ + ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
257
203
  }
258
204
  // Battery
259
205
  if (this.battery === undefined) {
260
206
  this.battery === 100;
261
207
  }
262
- this.BatteryLevel = this.battery!;
208
+ this.BatteryLevel = Number(this.battery);
263
209
  if (this.BatteryLevel < 10) {
264
- this.StatusLowBattery =
265
- this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
210
+ this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
266
211
  } else {
267
- this.StatusLowBattery =
268
- this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
212
+ this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
269
213
  }
270
- this.debugLog(
271
- `Contact Sensor: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`,
272
- );
214
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
273
215
  }
274
216
 
275
217
  async openAPIparseStatus() {
@@ -277,49 +219,35 @@ export class Contact {
277
219
  this.SwitchToOpenAPI = false;
278
220
  }
279
221
  if (this.platform.config.credentials?.openToken) {
280
- this.debugLog(
281
- `Contact Sensor: ${this.accessory.displayName} OpenAPI parseStatus`,
282
- );
222
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} OpenAPI parseStatus`);
283
223
  // Contact State
284
- if (this.openState === "open") {
285
- this.ContactSensorState =
286
- this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
287
- this.debugLog(
288
- `Contact Sensor: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`,
289
- );
290
- } else if (this.openState === "close") {
291
- this.ContactSensorState =
292
- this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
293
- this.debugLog(
294
- `Contact Sensor: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`,
295
- );
224
+ if (this.openState === 'open') {
225
+ this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
226
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
227
+ } else if (this.openState === 'close') {
228
+ this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
229
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
296
230
  } else {
297
- this.debugLog(
298
- `Contact Sensor: ${this.accessory.displayName} openState: ${this.openState}`,
299
- );
231
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} openState: ${this.openState}`);
300
232
  }
301
233
  // Motion State
302
234
  if (!this.device.contact?.hide_motionsensor) {
303
235
  this.MotionDetected = this.moveDetected!;
304
- this.debugLog(
305
- `Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`,
306
- );
236
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
307
237
  }
308
238
  // Light Level
309
239
  if (!this.device.contact?.hide_lightsensor) {
310
240
  this.set_minLux = this.minLux();
311
241
  this.set_maxLux = this.maxLux();
312
242
  switch (this.brightness) {
313
- case "dim":
243
+ case 'dim':
314
244
  this.CurrentAmbientLightLevel = this.set_minLux;
315
245
  break;
316
- case "bright":
246
+ case 'bright':
317
247
  default:
318
248
  this.CurrentAmbientLightLevel = this.set_maxLux;
319
249
  }
320
- this.debugLog(
321
- `Contact Sensor: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
322
- );
250
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
323
251
  }
324
252
  }
325
253
  }
@@ -336,127 +264,102 @@ export class Contact {
336
264
  }
337
265
 
338
266
  private async BLERefreshStatus() {
339
- this.debugLog(
340
- `Contact Sensor: ${this.accessory.displayName} BLE refreshStatus`,
341
- );
267
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} BLE refreshStatus`);
342
268
  const switchbot = await this.platform.connectBLE();
343
269
  // Convert to BLE Address
344
- this.device.bleMac = this.device
345
- .deviceId!.match(/.{1,2}/g)!
346
- .join(":")
347
- .toLowerCase();
348
- this.debugLog(
349
- `Contact Sensor: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`,
350
- );
351
- try {
352
- await switchbot.discover({
353
- model: "d",
354
- quick: false,
355
- });
356
- // Start to monitor advertisement packets
357
- await switchbot.startScan({
358
- model: "d",
270
+ this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
271
+ this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
272
+ // Start to monitor advertisement packets
273
+ if (switchbot !== false) {
274
+ switchbot.startScan({
275
+ model: 'd',
359
276
  id: this.device.bleMac,
360
- });
361
- // Set an event hander
362
- switchbot.onadvertisement = (ad: settings.ad) => {
363
- this.serviceData = ad.serviceData;
364
- this.movement = ad.serviceData.movement;
365
- this.doorState = ad.serviceData.doorState;
366
- this.lightLevel = ad.serviceData.lightLevel;
367
- this.battery = ad.serviceData.battery;
368
- this.debugLog(
369
- `Contact Sensor: ${
370
- this.accessory.displayName
371
- } serviceData: ${JSON.stringify(ad.serviceData)}`,
372
- );
373
- this.debugLog(
374
- `Contact Sensor: ${this.accessory.displayName} movement: ${ad.serviceData.movement}, doorState: ` +
375
- `${ad.serviceData.doorState}, lightLevel: ${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}`,
376
- );
377
-
378
- if (this.serviceData) {
379
- this.connected = true;
380
- this.debugLog(
381
- `Contact Sensor: ${this.accessory.displayName} connected: ${this.connected}`,
382
- );
277
+ }).then(() => {
278
+ // Set an event hander
279
+ switchbot.onadvertisement = (ad: any) => {
280
+ this.serviceData = ad.serviceData;
281
+ this.movement = ad.serviceData.movement;
282
+ this.doorState = ad.serviceData.doorState;
283
+ this.lightLevel = ad.serviceData.lightLevel;
284
+ this.battery = ad.serviceData.battery;
285
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
286
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} movement: ${ad.serviceData.movement}, doorState: `
287
+ + `${ad.serviceData.doorState}, lightLevel: ${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}`);
288
+
289
+ if (this.serviceData) {
290
+ this.connected = true;
291
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} connected: ${this.connected}`);
292
+ } else {
293
+ this.connected = false;
294
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} connected: ${this.connected}`);
295
+ }
296
+ };
297
+ // Wait 2 seconds
298
+ return switchbot.wait(this.scanDuration * 1000);
299
+ }).then(async () => {
300
+ // Stop to monitor
301
+ switchbot.stopScan();
302
+ if (this.connected) {
303
+ this.parseStatus();
304
+ this.updateHomeKitCharacteristics();
383
305
  } else {
384
- this.connected = false;
385
- this.debugLog(
386
- `Contact Sensor: ${this.accessory.displayName} connected: ${this.connected}`,
387
- );
306
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
307
+ if (this.platform.config.credentials?.openToken) {
308
+ this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
309
+ await this.openAPIRefreshStatus();
310
+ }
311
+ }
312
+ }).catch(async (e: any) => {
313
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
314
+ if (this.deviceLogging === 'debug') {
315
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
316
+ + ` Error Message: ${JSON.stringify(e.message)}`);
317
+ }
318
+ if (this.platform.debugMode) {
319
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
320
+ + ` Error: ${JSON.stringify(e)}`);
388
321
  }
389
- };
390
- // Wait 10 seconds
391
- await switchbot.wait(this.scanDuration * 1000);
392
- // Stop to monitor
393
- switchbot.stopScan();
394
- if (this.connected) {
395
- this.parseStatus();
396
- this.updateHomeKitCharacteristics();
397
- } else {
398
- this.errorLog(
399
- `Contact Sensor: ${this.accessory.displayName} wasn't able to establish BLE Connection`,
400
- );
401
322
  if (this.platform.config.credentials?.openToken) {
402
- this.warnLog(
403
- `Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`,
404
- );
323
+ this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
405
324
  this.SwitchToOpenAPI = true;
406
325
  await this.openAPIRefreshStatus();
407
326
  }
408
- }
409
- } catch (e: any) {
410
- this.errorLog(
411
- `Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection`,
412
- );
413
- if (this.deviceLogging.includes("debug")) {
414
- this.errorLog(
415
- `Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` +
416
- ` Error Message: ${e.message}`,
417
- );
418
- }
419
- if (this.platform.config.credentials?.openToken) {
420
- this.warnLog(
421
- `Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`,
422
- );
423
- this.SwitchToOpenAPI = true;
424
- await this.openAPIRefreshStatus();
425
- }
426
- this.apiError(e);
327
+ this.apiError(e);
328
+ });
329
+ } else {
330
+ await this.BLEconnection(switchbot);
331
+ }
332
+ }
333
+
334
+ public async BLEconnection(switchbot: any) {
335
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
336
+ if (this.platform.config.credentials?.openToken) {
337
+ this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
338
+ this.SwitchToOpenAPI = true;
339
+ await this.openAPIRefreshStatus();
427
340
  }
428
341
  }
429
342
 
430
343
  private async openAPIRefreshStatus() {
431
344
  if (this.platform.config.credentials?.openToken) {
432
- this.debugLog(
433
- `Contact Sensor: ${this.accessory.displayName} OpenAPI refreshStatus`,
434
- );
345
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} OpenAPI refreshStatus`);
435
346
  try {
436
- this.deviceStatus = (
437
- await this.platform.axios.get(
438
- `${settings.DeviceURL}/${this.device.deviceId}/status`,
439
- )
440
- ).data;
441
- this.debugLog(
442
- `Contact Sensor: ${
443
- this.accessory.displayName
444
- } refreshStatus: ${JSON.stringify(this.deviceStatus)}`,
445
- );
347
+ this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
348
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
446
349
  this.openState = this.deviceStatus.body.openState;
447
350
  this.moveDetected = this.deviceStatus.body.moveDetected;
448
351
  this.brightness = this.deviceStatus.body.brightness;
449
352
  this.parseStatus();
450
353
  this.updateHomeKitCharacteristics();
451
354
  } catch (e: any) {
452
- this.errorLog(
453
- `Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`,
454
- );
455
- if (this.deviceLogging.includes("debug")) {
456
- this.errorLog(
457
- `Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
458
- ` Error Message: ${JSON.stringify(e.message)}`,
459
- );
355
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
356
+ if (this.deviceLogging === 'debug') {
357
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
358
+ + ` Error Message: ${JSON.stringify(e.message)}`);
359
+ }
360
+ if (this.platform.debugMode) {
361
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
362
+ + ` Error: ${JSON.stringify(e)}`);
460
363
  }
461
364
  this.apiError(e);
462
365
  }
@@ -468,192 +371,118 @@ export class Contact {
468
371
  */
469
372
  updateHomeKitCharacteristics() {
470
373
  if (this.ContactSensorState === undefined) {
471
- this.debugLog(
472
- `Contact Sensor: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`,
473
- );
374
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
474
375
  } else {
475
- this.service.updateCharacteristic(
476
- this.platform.Characteristic.ContactSensorState,
477
- this.ContactSensorState,
478
- );
479
- this.debugLog(
480
- `Contact Sensor: ${this.accessory.displayName} updateCharacteristic ContactSensorState: ${this.ContactSensorState}`,
481
- );
376
+ this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.ContactSensorState);
377
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} updateCharacteristic ContactSensorState: ${this.ContactSensorState}`);
482
378
  }
483
379
  if (!this.device.contact?.hide_motionsensor) {
484
380
  if (this.MotionDetected === undefined) {
485
- this.debugLog(
486
- `Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`,
487
- );
381
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
488
382
  } else {
489
- this.motionService?.updateCharacteristic(
490
- this.platform.Characteristic.MotionDetected,
491
- this.MotionDetected,
492
- );
493
- this.debugLog(
494
- `Contact Sensor: ${this.accessory.displayName} updateCharacteristic MotionDetected: ${this.MotionDetected}`,
495
- );
383
+ this.motionService?.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected);
384
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} updateCharacteristic MotionDetected: ${this.MotionDetected}`);
496
385
  }
497
386
  }
498
387
  if (!this.device.contact?.hide_lightsensor) {
499
388
  if (this.CurrentAmbientLightLevel === undefined) {
500
- this.debugLog(
501
- `Contact Sensor: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
502
- );
389
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
503
390
  } else {
504
- this.lightSensorService?.updateCharacteristic(
505
- this.platform.Characteristic.CurrentAmbientLightLevel,
506
- this.CurrentAmbientLightLevel,
507
- );
508
- this.debugLog(
509
- `Contact Sensor: ${this.accessory.displayName}` +
510
- ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
511
- );
391
+ this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
392
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName}`
393
+ + ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
512
394
  }
513
395
  }
514
396
  if (this.device.ble) {
515
397
  if (this.BatteryLevel === undefined) {
516
- this.debugLog(
517
- `Contact Sensor: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`,
518
- );
398
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
519
399
  } else {
520
- this.batteryService?.updateCharacteristic(
521
- this.platform.Characteristic.BatteryLevel,
522
- this.BatteryLevel,
523
- );
524
- this.debugLog(
525
- `Contact Sensor: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`,
526
- );
400
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
401
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
527
402
  }
528
403
  if (this.StatusLowBattery === undefined) {
529
- this.debugLog(
530
- `Contact Sensor: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`,
531
- );
404
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
532
405
  } else {
533
- this.batteryService?.updateCharacteristic(
534
- this.platform.Characteristic.StatusLowBattery,
535
- this.StatusLowBattery,
536
- );
537
- this.debugLog(
538
- `Contact Sensor: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`,
539
- );
406
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
407
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
540
408
  }
541
409
  }
542
410
  }
543
411
 
544
412
  public apiError(e: any) {
545
- this.service.updateCharacteristic(
546
- this.platform.Characteristic.ContactSensorState,
547
- e,
548
- );
413
+ this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, e);
549
414
  if (!this.device.contact?.hide_motionsensor) {
550
- this.motionService?.updateCharacteristic(
551
- this.platform.Characteristic.MotionDetected,
552
- e,
553
- );
415
+ this.motionService?.updateCharacteristic(this.platform.Characteristic.MotionDetected, e);
554
416
  }
555
417
  if (!this.device.contact?.hide_lightsensor) {
556
- this.lightSensorService?.updateCharacteristic(
557
- this.platform.Characteristic.CurrentAmbientLightLevel,
558
- e,
559
- );
418
+ this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
560
419
  }
561
420
  if (this.device.ble) {
562
- this.batteryService?.updateCharacteristic(
563
- this.platform.Characteristic.BatteryLevel,
564
- e,
565
- );
566
- this.batteryService?.updateCharacteristic(
567
- this.platform.Characteristic.StatusLowBattery,
568
- e,
569
- );
421
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
422
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
570
423
  }
571
424
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
572
425
  }
573
426
 
574
- config(device: settings.device & settings.devicesConfig) {
427
+ config(device: device & devicesConfig) {
575
428
  let config = {};
576
429
  if (device.contact) {
577
430
  config = device.contact;
578
431
  }
579
432
  if (device.ble) {
580
- config["ble"] = device.ble;
433
+ config['ble'] = device.ble;
581
434
  }
582
435
  if (device.logging !== undefined) {
583
- config["logging"] = device.logging;
436
+ config['logging'] = device.logging;
584
437
  }
585
438
  if (device.refreshRate !== undefined) {
586
- config["refreshRate"] = device.refreshRate;
439
+ config['refreshRate'] = device.refreshRate;
587
440
  }
588
441
  if (device.scanDuration !== undefined) {
589
- config["scanDuration"] = device.scanDuration;
442
+ config['scanDuration'] = device.scanDuration;
590
443
  }
591
444
  if (Object.entries(config).length !== 0) {
592
- this.warnLog(
593
- `Contact Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(
594
- config,
595
- )}`,
596
- );
445
+ this.warnLog(`Contact Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
597
446
  }
598
447
  }
599
448
 
600
- refreshRate(device: settings.device & settings.devicesConfig) {
449
+ refreshRate(device: device & devicesConfig) {
601
450
  if (device.refreshRate) {
602
- this.deviceRefreshRate = this.accessory.context.refreshRate =
603
- device.refreshRate;
604
- this.debugLog(
605
- `Contact Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`,
606
- );
451
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
452
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
607
453
  } else if (this.platform.config.options!.refreshRate) {
608
- this.deviceRefreshRate = this.accessory.context.refreshRate =
609
- this.platform.config.options!.refreshRate;
610
- this.debugLog(
611
- `Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`,
612
- );
454
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
455
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
613
456
  }
614
457
  }
615
458
 
616
- scan(device: settings.device & settings.devicesConfig) {
459
+ scan(device: device & devicesConfig) {
617
460
  if (device.scanDuration) {
618
- this.scanDuration = this.accessory.context.scanDuration =
619
- device.scanDuration;
461
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
620
462
  if (device.ble) {
621
- this.debugLog(
622
- `Contact Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`,
623
- );
463
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
624
464
  }
625
465
  } else {
626
466
  this.scanDuration = this.accessory.context.scanDuration = 1;
627
467
  if (this.device.ble) {
628
- this.debugLog(
629
- `Contact Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`,
630
- );
468
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
631
469
  }
632
470
  }
633
471
  }
634
472
 
635
- logs(device: settings.device & settings.devicesConfig) {
473
+ logs(device: device & devicesConfig) {
636
474
  if (this.platform.debugMode) {
637
- this.deviceLogging = this.accessory.context.logging = "debugMode";
638
- this.debugLog(
639
- `Contact Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
640
- );
475
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
476
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
641
477
  } else if (device.logging) {
642
478
  this.deviceLogging = this.accessory.context.logging = device.logging;
643
- this.debugLog(
644
- `Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
645
- );
479
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
646
480
  } else if (this.platform.config.options?.logging) {
647
- this.deviceLogging = this.accessory.context.logging =
648
- this.platform.config.options?.logging;
649
- this.debugLog(
650
- `Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
651
- );
481
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
482
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
652
483
  } else {
653
- this.deviceLogging = this.accessory.context.logging = "standard";
654
- this.debugLog(
655
- `Contact Sensor: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
656
- );
484
+ this.deviceLogging = this.accessory.context.logging = 'standard';
485
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
657
486
  }
658
487
  }
659
488
 
@@ -676,8 +505,8 @@ export class Contact {
676
505
  }
677
506
 
678
507
  /**
679
- * Logging for Device
680
- */
508
+ * Logging for Device
509
+ */
681
510
  infoLog(...log: any[]) {
682
511
  if (this.enablingDeviceLogging()) {
683
512
  this.platform.log.info(String(...log));
@@ -698,8 +527,8 @@ export class Contact {
698
527
 
699
528
  debugLog(...log: any[]) {
700
529
  if (this.enablingDeviceLogging()) {
701
- if (this.deviceLogging === "debug") {
702
- this.platform.log.info("[DEBUG]", String(...log));
530
+ if (this.deviceLogging === 'debug') {
531
+ this.platform.log.info('[DEBUG]', String(...log));
703
532
  } else {
704
533
  this.platform.log.debug(String(...log));
705
534
  }
@@ -707,8 +536,6 @@ export class Contact {
707
536
  }
708
537
 
709
538
  enablingDeviceLogging(): boolean {
710
- return (
711
- this.deviceLogging.includes("debug") || this.deviceLogging === "standard"
712
- );
539
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
713
540
  }
714
541
  }