@switchbot/homebridge-switchbot 1.4.1-beta.1 → 1.4.1-beta.2

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 (103) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/config.schema.json +82 -10
  3. package/dist/devices/bots.d.ts +12 -2
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +140 -89
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts +12 -2
  8. package/dist/devices/colorbulb.d.ts.map +1 -1
  9. package/dist/devices/colorbulb.js +138 -84
  10. package/dist/devices/colorbulb.js.map +1 -1
  11. package/dist/devices/contact.d.ts +12 -2
  12. package/dist/devices/contact.d.ts.map +1 -1
  13. package/dist/devices/contact.js +101 -52
  14. package/dist/devices/contact.js.map +1 -1
  15. package/dist/devices/curtains.d.ts +13 -4
  16. package/dist/devices/curtains.d.ts.map +1 -1
  17. package/dist/devices/curtains.js +173 -124
  18. package/dist/devices/curtains.js.map +1 -1
  19. package/dist/devices/humidifiers.d.ts +12 -2
  20. package/dist/devices/humidifiers.d.ts.map +1 -1
  21. package/dist/devices/humidifiers.js +156 -108
  22. package/dist/devices/humidifiers.js.map +1 -1
  23. package/dist/devices/meters.d.ts +12 -2
  24. package/dist/devices/meters.d.ts.map +1 -1
  25. package/dist/devices/meters.js +98 -49
  26. package/dist/devices/meters.js.map +1 -1
  27. package/dist/devices/motion.d.ts +12 -2
  28. package/dist/devices/motion.d.ts.map +1 -1
  29. package/dist/devices/motion.js +86 -37
  30. package/dist/devices/motion.js.map +1 -1
  31. package/dist/devices/plugs.d.ts +12 -2
  32. package/dist/devices/plugs.d.ts.map +1 -1
  33. package/dist/devices/plugs.js +80 -31
  34. package/dist/devices/plugs.js.map +1 -1
  35. package/dist/irdevices/airconditioners.d.ts +10 -2
  36. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  37. package/dist/irdevices/airconditioners.js +77 -37
  38. package/dist/irdevices/airconditioners.js.map +1 -1
  39. package/dist/irdevices/airpurifiers.d.ts +10 -2
  40. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  41. package/dist/irdevices/airpurifiers.js +65 -25
  42. package/dist/irdevices/airpurifiers.js.map +1 -1
  43. package/dist/irdevices/cameras.d.ts +10 -2
  44. package/dist/irdevices/cameras.d.ts.map +1 -1
  45. package/dist/irdevices/cameras.js +61 -21
  46. package/dist/irdevices/cameras.js.map +1 -1
  47. package/dist/irdevices/fans.d.ts +10 -2
  48. package/dist/irdevices/fans.d.ts.map +1 -1
  49. package/dist/irdevices/fans.js +71 -30
  50. package/dist/irdevices/fans.js.map +1 -1
  51. package/dist/irdevices/lights.d.ts +10 -2
  52. package/dist/irdevices/lights.d.ts.map +1 -1
  53. package/dist/irdevices/lights.js +62 -22
  54. package/dist/irdevices/lights.js.map +1 -1
  55. package/dist/irdevices/others.d.ts +10 -2
  56. package/dist/irdevices/others.d.ts.map +1 -1
  57. package/dist/irdevices/others.js +68 -28
  58. package/dist/irdevices/others.js.map +1 -1
  59. package/dist/irdevices/tvs.d.ts +10 -2
  60. package/dist/irdevices/tvs.d.ts.map +1 -1
  61. package/dist/irdevices/tvs.js +78 -38
  62. package/dist/irdevices/tvs.js.map +1 -1
  63. package/dist/irdevices/vacuumcleaners.d.ts +10 -2
  64. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  65. package/dist/irdevices/vacuumcleaners.js +61 -21
  66. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  67. package/dist/irdevices/waterheaters.d.ts +10 -2
  68. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  69. package/dist/irdevices/waterheaters.js +61 -21
  70. package/dist/irdevices/waterheaters.js.map +1 -1
  71. package/dist/platform.d.ts +9 -10
  72. package/dist/platform.d.ts.map +1 -1
  73. package/dist/platform.js +264 -285
  74. package/dist/platform.js.map +1 -1
  75. package/dist/settings.d.ts +4 -1
  76. package/dist/settings.d.ts.map +1 -1
  77. package/dist/settings.js.map +1 -1
  78. package/nodemon.json +1 -1
  79. package/package.json +1 -1
  80. package/src/devices/bots.ts +146 -89
  81. package/src/devices/colorbulb.ts +146 -86
  82. package/src/devices/contact.ts +107 -52
  83. package/src/devices/curtains.ts +182 -129
  84. package/src/devices/humidifiers.ts +162 -109
  85. package/src/devices/meters.ts +104 -49
  86. package/src/devices/motion.ts +91 -36
  87. package/src/devices/plugs.ts +84 -31
  88. package/src/irdevices/airconditioners.ts +81 -36
  89. package/src/irdevices/airpurifiers.ts +69 -24
  90. package/src/irdevices/cameras.ts +65 -20
  91. package/src/irdevices/fans.ts +75 -30
  92. package/src/irdevices/lights.ts +66 -21
  93. package/src/irdevices/others.ts +72 -27
  94. package/src/irdevices/tvs.ts +82 -37
  95. package/src/irdevices/vacuumcleaners.ts +65 -20
  96. package/src/irdevices/waterheaters.ts +65 -20
  97. package/src/platform.ts +267 -290
  98. package/src/settings.ts +4 -1
  99. package/dist/devices/indoorcam.d.ts +0 -64
  100. package/dist/devices/indoorcam.d.ts.map +0 -1
  101. package/dist/devices/indoorcam.js +0 -249
  102. package/dist/devices/indoorcam.js.map +0 -1
  103. package/src/devices/indoorcam.ts +0 -309
@@ -13,18 +13,18 @@ class Curtain {
13
13
  this.platform = platform;
14
14
  this.accessory = accessory;
15
15
  this.device = device;
16
- this.deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
17
- this.debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
18
- // Curtain Config
19
- this.platform.device(`Curtain: ${this.accessory.displayName} Config: (ble: ${device.ble}, disable_group: ${device.curtain?.disable_group},`
20
- + ` hide_lightsensor: ${device.curtain?.hide_lightsensor}, set_minLux: ${device.curtain?.set_minLux}, set_maxLux: `
21
- + `${device.curtain?.set_maxLux}, refreshRate: ${device.curtain?.refreshRate}, set_max: ${device.curtain?.set_max}, set_min: `
22
- + `${device.curtain?.set_min}, set_minStep: ${device.curtain?.set_minStep})`);
23
16
  // default placeholders
17
+ this.refreshRate();
18
+ this.logs();
24
19
  this.setMinMax();
25
20
  this.CurrentPosition = 0;
26
21
  this.TargetPosition = 0;
27
22
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
23
+ // Curtain Config
24
+ this.debugLog(`Curtain: ${this.accessory.displayName} Config: (ble: ${device.ble}, disable_group: ${device.curtain?.disable_group},`
25
+ + ` hide_lightsensor: ${device.curtain?.hide_lightsensor}, set_minLux: ${device.curtain?.set_minLux}, set_maxLux: `
26
+ + `${device.curtain?.set_maxLux}, refreshRate: ${device.curtain?.refreshRate}, set_max: ${device.curtain?.set_max}, set_min: `
27
+ + `${device.curtain?.set_min}, set_minStep: ${device.curtain?.set_minStep})`);
28
28
  // this is subject we use to track when we need to POST changes to the SwitchBot API
29
29
  this.doCurtainUpdate = new rxjs_1.Subject();
30
30
  this.curtainUpdateInProgress = false;
@@ -72,36 +72,36 @@ class Curtain {
72
72
  .onSet(this.TargetPositionSet.bind(this));
73
73
  // Light Sensor Service
74
74
  if (device.curtain?.hide_lightsensor) {
75
- this.platform.device(`Curtain: ${accessory.displayName} Removing Light Sensor Service`);
75
+ this.debugLog(`Curtain: ${accessory.displayName} Removing Light Sensor Service`);
76
76
  this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor);
77
77
  accessory.removeService(this.lightSensorService);
78
78
  }
79
79
  else if (!this.lightSensorService) {
80
- this.platform.device(`Curtain: ${accessory.displayName} Add Light Sensor Service`);
80
+ this.debugLog(`Curtain: ${accessory.displayName} Add Light Sensor Service`);
81
81
  (this.lightSensorService =
82
82
  this.accessory.getService(this.platform.Service.LightSensor) ||
83
83
  this.accessory.addService(this.platform.Service.LightSensor)), `${accessory.displayName} Light Sensor`;
84
84
  this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
85
85
  }
86
86
  else {
87
- this.platform.device(`Curtain: ${accessory.displayName} Light Sensor Service Not Added`);
87
+ this.debugLog(`Curtain: ${accessory.displayName} Light Sensor Service Not Added`);
88
88
  }
89
89
  // Update Homekit
90
90
  this.updateHomeKitCharacteristics();
91
91
  // Start an update interval
92
- (0, rxjs_1.interval)(this.platform.config.options.refreshRate * 1000)
92
+ (0, rxjs_1.interval)(this.deviceRefreshRate * 1000)
93
93
  .pipe((0, operators_1.skipWhile)(() => this.curtainUpdateInProgress))
94
94
  .subscribe(() => {
95
95
  this.refreshStatus();
96
96
  });
97
97
  // update slide progress
98
- (0, rxjs_1.interval)(this.curtainRefreshRate() * 1000)
98
+ (0, rxjs_1.interval)(this.curtainRefreshRate * 1000)
99
99
  .pipe((0, operators_1.skipWhile)(() => this.curtainUpdateInProgress))
100
100
  .subscribe(() => {
101
101
  if (this.PositionState === this.platform.Characteristic.PositionState.STOPPED) {
102
102
  return;
103
103
  }
104
- this.platform.debug(`Curtain: ${accessory.displayName} Refresh Status When Moving, PositionState: ${this.PositionState}`);
104
+ this.debugLog(`Curtain: ${accessory.displayName} Refresh Status When Moving, PositionState: ${this.PositionState}`);
105
105
  this.refreshStatus();
106
106
  });
107
107
  // Watch for Curtain change events
@@ -115,13 +115,13 @@ class Curtain {
115
115
  await this.pushChanges();
116
116
  }
117
117
  catch (e) {
118
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges`);
119
- if (this.deviceDebug) {
120
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges,`
118
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges`);
119
+ if (this.deviceLogging === 'debug') {
120
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges,`
121
121
  + ` Error Message: ${JSON.stringify(e.message)}`);
122
122
  }
123
- if (this.debugDebug) {
124
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges,`
123
+ if (this.platform.debugMode) {
124
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges,`
125
125
  + ` Error: ${JSON.stringify(e)}`);
126
126
  }
127
127
  this.apiError();
@@ -129,23 +129,41 @@ class Curtain {
129
129
  this.curtainUpdateInProgress = false;
130
130
  });
131
131
  }
132
- connectBLE() {
133
- const switchbot = new node_switchbot_1.default();
134
- this.device.bleMac = ((this.device.deviceId.match(/.{1,2}/g)).join(':')).toLowerCase();
135
- this.platform.device(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
136
- return switchbot;
137
- }
138
- curtainRefreshRate() {
132
+ refreshRate() {
133
+ // refreshRate
134
+ if (this.device.refreshRate) {
135
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
136
+ }
137
+ else if (this.platform.config.options.refreshRate) {
138
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
139
+ }
140
+ // curtainRefreshRate
139
141
  if (this.device?.curtain?.refreshRate) {
140
- this.refreshRate = this.device?.curtain?.refreshRate;
142
+ this.curtainRefreshRate = this.device?.curtain?.refreshRate;
141
143
  }
142
144
  else {
143
- this.refreshRate = 5;
144
- if (this.platform.config.options?.debug === 'device') {
145
- this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using Default Curtain Refresh Rate.`);
145
+ this.curtainRefreshRate = 5;
146
+ if (this.deviceLogging === 'debug') {
147
+ this.warnLog(`Curtain: ${this.accessory.displayName} Using Default Curtain Refresh Rate.`);
146
148
  }
147
149
  }
148
- return this.refreshRate;
150
+ }
151
+ logs() {
152
+ if (this.device.logging) {
153
+ this.deviceLogging = this.accessory.context.logging = this.device.logging;
154
+ }
155
+ else if (this.platform.config.options?.logging) {
156
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
157
+ }
158
+ else {
159
+ this.deviceLogging = this.accessory.context.logging = 'standard';
160
+ }
161
+ }
162
+ connectBLE() {
163
+ const switchbot = new node_switchbot_1.default();
164
+ this.device.bleMac = ((this.device.deviceId.match(/.{1,2}/g)).join(':')).toLowerCase();
165
+ this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
166
+ return switchbot;
149
167
  }
150
168
  minStep() {
151
169
  if (this.device.curtain?.set_minStep) {
@@ -183,37 +201,37 @@ class Curtain {
183
201
  }
184
202
  }
185
203
  async BLEparseStatus() {
186
- this.platform.debug(`Curtain: ${this.accessory.displayName} BLE parseStatus`);
204
+ this.debugLog(`Curtain: ${this.accessory.displayName} BLE parseStatus`);
187
205
  this.setMinMax();
188
206
  this.CurrentPosition = 100 - Number(this.position);
189
- this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentPosition ${this.CurrentPosition}`);
207
+ this.debugLog(`Curtain: ${this.accessory.displayName} CurrentPosition ${this.CurrentPosition}`);
190
208
  if (this.setNewTarget) {
191
- this.platform.log.info(`Curtain: ${this.accessory.displayName} Checking Status ...`);
209
+ this.infoLog(`Curtain: ${this.accessory.displayName} Checking Status ...`);
192
210
  }
193
211
  if (this.setNewTarget) {
194
212
  this.setMinMax();
195
213
  if (this.TargetPosition > this.CurrentPosition) {
196
- this.platform.debug(`Curtain: ${this.accessory.displayName} Closing, CurrentPosition: ${this.CurrentPosition}`);
214
+ this.debugLog(`Curtain: ${this.accessory.displayName} Closing, CurrentPosition: ${this.CurrentPosition}`);
197
215
  this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
198
216
  }
199
217
  else if (this.TargetPosition < this.CurrentPosition) {
200
- this.platform.debug(`Curtain: ${this.accessory.displayName} Opening, CurrentPosition: ${this.CurrentPosition}`);
218
+ this.debugLog(`Curtain: ${this.accessory.displayName} Opening, CurrentPosition: ${this.CurrentPosition}`);
201
219
  this.PositionState = this.platform.Characteristic.PositionState.DECREASING;
202
220
  }
203
221
  else {
204
- this.platform.debug(`Curtain: ${this.CurrentPosition} Standby, CurrentPosition: ${this.CurrentPosition}`);
222
+ this.debugLog(`Curtain: ${this.CurrentPosition} Standby, CurrentPosition: ${this.CurrentPosition}`);
205
223
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
206
224
  }
207
225
  }
208
226
  else {
209
- this.platform.debug(`Curtain: ${this.accessory.displayName} Standby, CurrentPosition: ${this.CurrentPosition}`);
227
+ this.debugLog(`Curtain: ${this.accessory.displayName} Standby, CurrentPosition: ${this.CurrentPosition}`);
210
228
  if (!this.setNewTarget) {
211
229
  // If Curtain calibration distance is short, there will be an error between the current percentage and the target percentage.
212
230
  this.TargetPosition = this.CurrentPosition;
213
231
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
214
232
  }
215
233
  }
216
- this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},`
234
+ this.debugLog(`Curtain: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},`
217
235
  + ` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState},`);
218
236
  if (!this.device.curtain?.hide_lightsensor) {
219
237
  this.set_minLux = this.minLux();
@@ -223,47 +241,47 @@ class Curtain {
223
241
  switch (this.lightLevel) {
224
242
  case 1:
225
243
  this.CurrentAmbientLightLevel = this.set_minLux;
226
- this.platform.device(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
244
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
227
245
  break;
228
246
  case 2:
229
247
  this.CurrentAmbientLightLevel = ((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels);
230
- this.platform.device(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel},`
248
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel},`
231
249
  + ` Calculation: ${((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels)}`);
232
250
  break;
233
251
  case 3:
234
252
  this.CurrentAmbientLightLevel = (((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 2);
235
- this.platform.device(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
253
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
236
254
  break;
237
255
  case 4:
238
256
  this.CurrentAmbientLightLevel = (((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 3);
239
- this.platform.device(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
257
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
240
258
  break;
241
259
  case 5:
242
260
  this.CurrentAmbientLightLevel = (((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 4);
243
- this.platform.device(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
261
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
244
262
  break;
245
263
  case 6:
246
264
  this.CurrentAmbientLightLevel = (((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 5);
247
- this.platform.device(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
265
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
248
266
  break;
249
267
  case 7:
250
268
  this.CurrentAmbientLightLevel = (((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 6);
251
- this.platform.device(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
269
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
252
270
  break;
253
271
  case 8:
254
272
  this.CurrentAmbientLightLevel = (((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 7);
255
- this.platform.device(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
273
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
256
274
  break;
257
275
  case 9:
258
276
  this.CurrentAmbientLightLevel = (((this.set_maxLux - this.set_minLux) / this.spaceBetweenLevels) * 8);
259
- this.platform.device(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
277
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel}`);
260
278
  break;
261
279
  case 10:
262
280
  default:
263
281
  this.CurrentAmbientLightLevel = this.set_maxLux;
264
- this.platform.device();
282
+ this.debugLog();
265
283
  }
266
- this.platform.debug(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel},`
284
+ this.debugLog(`Curtain: ${this.accessory.displayName} LightLevel: ${this.lightLevel},`
267
285
  + ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
268
286
  }
269
287
  // Battery
@@ -274,42 +292,42 @@ class Curtain {
274
292
  else {
275
293
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
276
294
  }
277
- this.platform.debug(`Curtain: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
295
+ this.debugLog(`Curtain: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
278
296
  }
279
297
  async openAPIparseStatus() {
280
298
  if (this.platform.config.credentials?.openToken) {
281
- this.platform.debug(`Curtain: ${this.accessory.displayName} OpenAPI parseStatus`);
299
+ this.debugLog(`Curtain: ${this.accessory.displayName} OpenAPI parseStatus`);
282
300
  // CurrentPosition
283
301
  this.setMinMax();
284
302
  this.CurrentPosition = 100 - this.deviceStatus.body.slidePosition;
285
- this.platform.debug(`Curtain ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition}`);
303
+ this.debugLog(`Curtain ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition}`);
286
304
  if (this.setNewTarget) {
287
- this.platform.log.info(`Checking ${this.accessory.displayName} Status ...`);
305
+ this.infoLog(`Checking ${this.accessory.displayName} Status ...`);
288
306
  }
289
307
  if (this.deviceStatus.body.moving) {
290
308
  this.setMinMax();
291
309
  if (this.TargetPosition > this.CurrentPosition) {
292
- this.platform.debug(`Curtain: ${this.accessory.displayName} Closing, CurrentPosition: ${this.CurrentPosition} `);
310
+ this.debugLog(`Curtain: ${this.accessory.displayName} Closing, CurrentPosition: ${this.CurrentPosition} `);
293
311
  this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
294
312
  }
295
313
  else if (this.TargetPosition < this.CurrentPosition) {
296
- this.platform.debug(`Curtain: ${this.accessory.displayName} Opening, CurrentPosition: ${this.CurrentPosition} `);
314
+ this.debugLog(`Curtain: ${this.accessory.displayName} Opening, CurrentPosition: ${this.CurrentPosition} `);
297
315
  this.PositionState = this.platform.Characteristic.PositionState.DECREASING;
298
316
  }
299
317
  else {
300
- this.platform.debug(`Curtain: ${this.CurrentPosition} Standby, CurrentPosition: ${this.CurrentPosition}`);
318
+ this.debugLog(`Curtain: ${this.CurrentPosition} Standby, CurrentPosition: ${this.CurrentPosition}`);
301
319
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
302
320
  }
303
321
  }
304
322
  else {
305
- this.platform.debug(`Curtain: ${this.accessory.displayName} Standby, CurrentPosition: ${this.CurrentPosition}`);
323
+ this.debugLog(`Curtain: ${this.accessory.displayName} Standby, CurrentPosition: ${this.CurrentPosition}`);
306
324
  if (!this.setNewTarget) {
307
325
  /*If Curtain calibration distance is short, there will be an error between the current percentage and the target percentage.*/
308
326
  this.TargetPosition = this.CurrentPosition;
309
327
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
310
328
  }
311
329
  }
312
- this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},`
330
+ this.debugLog(`Curtain: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition},`
313
331
  + ` TargetPosition: ${this.TargetPosition}, PositionState: ${this.PositionState},`);
314
332
  if (!this.device.curtain?.hide_lightsensor) {
315
333
  this.set_minLux = this.minLux();
@@ -323,7 +341,7 @@ class Curtain {
323
341
  default:
324
342
  this.CurrentAmbientLightLevel = this.set_maxLux;
325
343
  }
326
- this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
344
+ this.debugLog(`Curtain: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
327
345
  }
328
346
  }
329
347
  }
@@ -336,7 +354,7 @@ class Curtain {
336
354
  }
337
355
  }
338
356
  async BLERefreshStatus() {
339
- this.platform.debug(`Curtain: ${this.accessory.displayName} BLE refreshStatus`);
357
+ this.debugLog(`Curtain: ${this.accessory.displayName} BLE refreshStatus`);
340
358
  // eslint-disable-next-line @typescript-eslint/no-var-requires
341
359
  const switchbot = this.connectBLE();
342
360
  // Start to monitor advertisement packets
@@ -351,16 +369,16 @@ class Curtain {
351
369
  this.battery = ad.serviceData.battery;
352
370
  this.position = ad.serviceData.position;
353
371
  this.lightLevel = ad.serviceData.lightLevel;
354
- this.platform.device(`Curtain: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
355
- this.platform.device(`Curtain: ${this.accessory.displayName} calibration: ${ad.serviceData.calibration}, `
372
+ this.debugLog(`Curtain: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
373
+ this.debugLog(`Curtain: ${this.accessory.displayName} calibration: ${ad.serviceData.calibration}, `
356
374
  + `position: ${ad.serviceData.position}, lightLevel: ${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}`);
357
375
  if (this.serviceData) {
358
376
  this.connected = true;
359
- this.platform.device(`Curtain: ${this.accessory.displayName} connected: ${this.connected}`);
377
+ this.debugLog(`Curtain: ${this.accessory.displayName} connected: ${this.connected}`);
360
378
  }
361
379
  else {
362
380
  this.connected = false;
363
- this.platform.device(`Curtain: ${this.accessory.displayName} connected: ${this.connected}`);
381
+ this.debugLog(`Curtain: ${this.accessory.displayName} connected: ${this.connected}`);
364
382
  }
365
383
  };
366
384
  // Wait 10 seconds
@@ -373,24 +391,24 @@ class Curtain {
373
391
  this.updateHomeKitCharacteristics();
374
392
  }
375
393
  else {
376
- this.platform.log.error(`Curtain: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
394
+ this.errorLog(`Curtain: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
377
395
  if (this.platform.config.credentials?.openToken) {
378
- this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
396
+ this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
379
397
  await this.openAPIRefreshStatus();
380
398
  }
381
399
  }
382
400
  }).catch(async (e) => {
383
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
384
- if (this.deviceDebug) {
385
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
401
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
402
+ if (this.deviceLogging === 'debug') {
403
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
386
404
  + ` Error Message: ${JSON.stringify(e.message)}`);
387
405
  }
388
- if (this.debugDebug) {
389
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
406
+ if (this.platform.debugMode) {
407
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
390
408
  + ` Error: ${JSON.stringify(e)}`);
391
409
  }
392
410
  if (this.platform.config.credentials?.openToken) {
393
- this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
411
+ this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
394
412
  await this.openAPIRefreshStatus();
395
413
  }
396
414
  this.apiError();
@@ -398,21 +416,21 @@ class Curtain {
398
416
  }
399
417
  async openAPIRefreshStatus() {
400
418
  if (this.platform.config.credentials?.openToken) {
401
- this.platform.debug(`Curtain: ${this.accessory.displayName} OpenAPI refreshStatus`);
419
+ this.debugLog(`Curtain: ${this.accessory.displayName} OpenAPI refreshStatus`);
402
420
  try {
403
421
  this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
404
- this.platform.debug(`Curtain: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
422
+ this.debugLog(`Curtain: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
405
423
  this.parseStatus();
406
424
  this.updateHomeKitCharacteristics();
407
425
  }
408
426
  catch (e) {
409
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
410
- if (this.deviceDebug) {
411
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
427
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
428
+ if (this.deviceLogging === 'debug') {
429
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
412
430
  + ` Error Message: ${JSON.stringify(e.message)}`);
413
431
  }
414
- if (this.debugDebug) {
415
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
432
+ if (this.platform.debugMode) {
433
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
416
434
  + ` Error: ${JSON.stringify(e)}`);
417
435
  }
418
436
  this.apiError();
@@ -435,67 +453,67 @@ class Curtain {
435
453
  }
436
454
  async BLEpushChanges() {
437
455
  if (this.TargetPosition !== this.CurrentPosition) {
438
- this.platform.debug(`Curtain: ${this.accessory.displayName} BLE pushChanges`);
456
+ this.debugLog(`Curtain: ${this.accessory.displayName} BLE pushChanges`);
439
457
  const switchbot = this.connectBLE();
440
458
  switchbot.discover({ model: 'c', quick: true, id: this.device.bleMac }).then((device_list) => {
441
- this.platform.log.info(`${this.accessory.displayName} Target Position: ${this.TargetPosition}`);
459
+ this.infoLog(`${this.accessory.displayName} Target Position: ${this.TargetPosition}`);
442
460
  return device_list[0].runToPos(100 - Number(this.TargetPosition));
443
461
  }).then(() => {
444
- this.platform.device(`Curtain: ${this.accessory.displayName} Done.`);
462
+ this.debugLog(`Curtain: ${this.accessory.displayName} Done.`);
445
463
  }).catch(async (e) => {
446
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
447
- if (this.deviceDebug) {
448
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
464
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
465
+ if (this.deviceLogging === 'debug') {
466
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
449
467
  + ` Error Message: ${JSON.stringify(e.message)}`);
450
468
  }
451
- if (this.debugDebug) {
452
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
469
+ if (this.platform.debugMode) {
470
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
453
471
  + ` Error: ${JSON.stringify(e)}`);
454
472
  }
455
473
  if (this.platform.config.credentials?.openToken) {
456
- this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
474
+ this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
457
475
  await this.OpenAPIpushChanges();
458
476
  }
459
477
  this.apiError();
460
478
  });
461
479
  }
462
480
  else {
463
- this.platform.debug(`Curtain: ${this.accessory.displayName} No BLE Changes, CurrentPosition & TargetPosition Are the Same.`
481
+ this.debugLog(`Curtain: ${this.accessory.displayName} No BLE Changes, CurrentPosition & TargetPosition Are the Same.`
464
482
  + ` CurrentPosition: ${this.CurrentPosition}, TargetPosition ${this.TargetPosition}`);
465
483
  }
466
484
  }
467
485
  async OpenAPIpushChanges() {
468
486
  if (this.platform.config.credentials?.openToken) {
469
487
  try {
470
- this.platform.debug(`Curtain: ${this.accessory.displayName} OpenAPI pushChanges`);
488
+ this.debugLog(`Curtain: ${this.accessory.displayName} OpenAPI pushChanges`);
471
489
  if (this.TargetPosition !== this.CurrentPosition) {
472
- this.platform.debug(`Pushing ${this.TargetPosition}`);
490
+ this.debugLog(`Pushing ${this.TargetPosition}`);
473
491
  const adjustedTargetPosition = 100 - Number(this.TargetPosition);
474
492
  const payload = {
475
493
  commandType: 'command',
476
494
  command: 'setPosition',
477
495
  parameter: `0,ff,${adjustedTargetPosition}`,
478
496
  };
479
- this.platform.log.info(`Curtain: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
497
+ this.infoLog(`Curtain: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
480
498
  + ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
481
499
  // Make the API request
482
500
  const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
483
- this.platform.debug(`Curtain: ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
501
+ this.debugLog(`Curtain: ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
484
502
  this.statusCode(push);
485
503
  }
486
504
  else {
487
- this.platform.debug(`Curtain: ${this.accessory.displayName} No OpenAPI Changes, CurrentPosition & TargetPosition Are the Same.`
505
+ this.debugLog(`Curtain: ${this.accessory.displayName} No OpenAPI Changes, CurrentPosition & TargetPosition Are the Same.`
488
506
  + ` CurrentPosition: ${this.CurrentPosition}, TargetPosition ${this.TargetPosition}`);
489
507
  }
490
508
  }
491
509
  catch (e) {
492
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
493
- if (this.deviceDebug) {
494
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
510
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
511
+ if (this.deviceLogging === 'debug') {
512
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
495
513
  + ` Error Message: ${JSON.stringify(e.message)}`);
496
514
  }
497
- if (this.debugDebug) {
498
- this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
515
+ if (this.platform.debugMode) {
516
+ this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
499
517
  + ` Error: ${JSON.stringify(e)}`);
500
518
  }
501
519
  this.apiError();
@@ -505,49 +523,49 @@ class Curtain {
505
523
  updateHomeKitCharacteristics() {
506
524
  this.setMinMax();
507
525
  if (this.CurrentPosition === undefined || Number.isNaN(this.CurrentPosition)) {
508
- this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition}`);
526
+ this.debugLog(`Curtain: ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition}`);
509
527
  }
510
528
  else {
511
529
  this.service.updateCharacteristic(this.platform.Characteristic.CurrentPosition, Number(this.CurrentPosition));
512
- this.platform.device(`Curtain: ${this.accessory.displayName} updateCharacteristic CurrentPosition: ${this.CurrentPosition}`);
530
+ this.debugLog(`Curtain: ${this.accessory.displayName} updateCharacteristic CurrentPosition: ${this.CurrentPosition}`);
513
531
  }
514
532
  if (this.PositionState === undefined) {
515
- this.platform.debug(`Curtain: ${this.accessory.displayName} PositionState: ${this.PositionState}`);
533
+ this.debugLog(`Curtain: ${this.accessory.displayName} PositionState: ${this.PositionState}`);
516
534
  }
517
535
  else {
518
- this.platform.device(`Curtain: ${this.accessory.displayName} updateCharacteristic PositionState: ${this.PositionState}`);
536
+ this.debugLog(`Curtain: ${this.accessory.displayName} updateCharacteristic PositionState: ${this.PositionState}`);
519
537
  }
520
538
  if (this.TargetPosition === undefined || Number.isNaN(this.TargetPosition)) {
521
- this.platform.debug(`Curtain: ${this.accessory.displayName} TargetPosition: ${this.TargetPosition}`);
539
+ this.debugLog(`Curtain: ${this.accessory.displayName} TargetPosition: ${this.TargetPosition}`);
522
540
  }
523
541
  else {
524
542
  this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, Number(this.TargetPosition));
525
- this.platform.device(`Curtain: ${this.accessory.displayName} updateCharacteristic TargetPosition: ${this.TargetPosition}`);
543
+ this.debugLog(`Curtain: ${this.accessory.displayName} updateCharacteristic TargetPosition: ${this.TargetPosition}`);
526
544
  }
527
545
  if (!this.device.curtain?.hide_lightsensor) {
528
546
  if (this.CurrentAmbientLightLevel === undefined || Number.isNaN(this.CurrentAmbientLightLevel)) {
529
- this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
547
+ this.debugLog(`Curtain: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
530
548
  }
531
549
  else {
532
550
  this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
533
- this.platform.device(`Curtain: ${this.accessory.displayName}`
551
+ this.debugLog(`Curtain: ${this.accessory.displayName}`
534
552
  + ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
535
553
  }
536
554
  }
537
555
  if (this.device.ble) {
538
556
  if (this.BatteryLevel === undefined) {
539
- this.platform.debug(`Curtain: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
557
+ this.debugLog(`Curtain: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
540
558
  }
541
559
  else {
542
560
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
543
- this.platform.device(`Curtain: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
561
+ this.debugLog(`Curtain: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
544
562
  }
545
563
  if (this.StatusLowBattery === undefined) {
546
- this.platform.debug(`Curtain: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
564
+ this.debugLog(`Curtain: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
547
565
  }
548
566
  else {
549
567
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
550
- this.platform.device(`Curtain: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
568
+ this.debugLog(`Curtain: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
551
569
  }
552
570
  }
553
571
  }
@@ -557,52 +575,52 @@ class Curtain {
557
575
  statusCode(push) {
558
576
  switch (push.data.statusCode) {
559
577
  case 151:
560
- this.platform.log.error(`Curtain: ${this.accessory.displayName} Command not supported by this device type.`);
578
+ this.errorLog(`Curtain: ${this.accessory.displayName} Command not supported by this device type.`);
561
579
  break;
562
580
  case 152:
563
- this.platform.log.error(`Curtain: ${this.accessory.displayName} Device not found.`);
581
+ this.errorLog(`Curtain: ${this.accessory.displayName} Device not found.`);
564
582
  break;
565
583
  case 160:
566
- this.platform.log.error(`Curtain: ${this.accessory.displayName} Command is not supported.`);
584
+ this.errorLog(`Curtain: ${this.accessory.displayName} Command is not supported.`);
567
585
  break;
568
586
  case 161:
569
- this.platform.log.error(`Curtain: ${this.accessory.displayName} Device is offline.`);
587
+ this.errorLog(`Curtain: ${this.accessory.displayName} Device is offline.`);
570
588
  break;
571
589
  case 171:
572
- this.platform.log.error(`Curtain: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
590
+ this.errorLog(`Curtain: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
573
591
  break;
574
592
  case 190:
575
- this.platform.log.error(`Curtain: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
593
+ this.errorLog(`Curtain: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
576
594
  + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
577
595
  break;
578
596
  case 100:
579
- this.platform.debug(`Curtain: ${this.accessory.displayName} Command successfully sent.`);
597
+ this.debugLog(`Curtain: ${this.accessory.displayName} Command successfully sent.`);
580
598
  break;
581
599
  default:
582
- this.platform.debug(`Curtain: ${this.accessory.displayName} Unknown statusCode.`);
600
+ this.debugLog(`Curtain: ${this.accessory.displayName} Unknown statusCode.`);
583
601
  }
584
602
  }
585
603
  /**
586
604
  * Handle requests to set the value of the "Target Position" characteristic
587
605
  */
588
606
  TargetPositionSet(value) {
589
- this.platform.debug(`Curtain: ${this.accessory.displayName} TargetPosition: ${value}`);
607
+ this.debugLog(`Curtain: ${this.accessory.displayName} TargetPosition: ${value}`);
590
608
  this.TargetPosition = value;
591
609
  this.setMinMax();
592
610
  if (value > this.CurrentPosition) {
593
611
  this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
594
612
  this.setNewTarget = true;
595
- this.platform.debug(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
613
+ this.debugLog(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
596
614
  }
597
615
  else if (value < this.CurrentPosition) {
598
616
  this.PositionState = this.platform.Characteristic.PositionState.DECREASING;
599
617
  this.setNewTarget = true;
600
- this.platform.debug(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
618
+ this.debugLog(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
601
619
  }
602
620
  else {
603
621
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
604
622
  this.setNewTarget = false;
605
- this.platform.debug(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
623
+ this.debugLog(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
606
624
  }
607
625
  this.service.setCharacteristic(this.platform.Characteristic.PositionState, this.PositionState);
608
626
  this.service.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
@@ -613,7 +631,7 @@ class Curtain {
613
631
  clearTimeout(this.setNewTargetTimer);
614
632
  if (this.setNewTarget) {
615
633
  this.setNewTargetTimer = setTimeout(() => {
616
- this.platform.debug(`Curtain: ${this.accessory.displayName} setNewTarget ${this.setNewTarget} timeout`);
634
+ this.debugLog(`Curtain: ${this.accessory.displayName} setNewTarget ${this.setNewTarget} timeout`);
617
635
  this.setNewTarget = false;
618
636
  }, 10000);
619
637
  }
@@ -631,6 +649,37 @@ class Curtain {
631
649
  }
632
650
  }
633
651
  }
652
+ /**
653
+ * Logging for Device
654
+ */
655
+ infoLog(...log) {
656
+ if (this.enablingDeviceLogging()) {
657
+ this.platform.log.info(String(...log));
658
+ }
659
+ }
660
+ warnLog(...log) {
661
+ if (this.enablingDeviceLogging()) {
662
+ this.platform.log.warn(String(...log));
663
+ }
664
+ }
665
+ errorLog(...log) {
666
+ if (this.enablingDeviceLogging()) {
667
+ this.platform.log.error(String(...log));
668
+ }
669
+ }
670
+ debugLog(...log) {
671
+ if (this.enablingDeviceLogging()) {
672
+ if (this.deviceLogging === 'debug') {
673
+ this.platform.log.info('[DEBUG]', String(...log));
674
+ }
675
+ else {
676
+ this.platform.log.debug(String(...log));
677
+ }
678
+ }
679
+ }
680
+ enablingDeviceLogging() {
681
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
682
+ }
634
683
  }
635
684
  exports.Curtain = Curtain;
636
685
  //# sourceMappingURL=curtains.js.map