@switchbot/homebridge-switchbot 1.3.1-beta.9 → 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.
- package/CHANGELOG.md +18 -2
- package/config.schema.json +82 -32
- package/dist/devices/bots.d.ts +15 -3
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +227 -165
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +14 -3
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +163 -105
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +13 -3
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +102 -63
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +14 -5
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +180 -140
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +14 -3
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +173 -133
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +17 -13
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +150 -105
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +13 -3
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +89 -45
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +15 -3
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +115 -53
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +13 -3
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +97 -46
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +13 -3
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +85 -31
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +12 -3
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +73 -24
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +12 -3
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +83 -35
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +12 -3
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +74 -25
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +12 -3
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +80 -31
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +12 -3
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +90 -42
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +12 -3
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +73 -24
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +12 -3
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +73 -24
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +10 -10
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +290 -307
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +9 -6
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/nodemon.json +1 -1
- package/package.json +6 -6
- package/src/devices/bots.ts +221 -152
- package/src/devices/colorbulb.ts +172 -108
- package/src/devices/contact.ts +109 -64
- package/src/devices/curtains.ts +190 -146
- package/src/devices/humidifiers.ts +181 -135
- package/src/devices/meters.ts +156 -105
- package/src/devices/motion.ts +95 -45
- package/src/devices/plugs.ts +121 -53
- package/src/irdevices/airconditioners.ts +102 -46
- package/src/irdevices/airpurifiers.ts +91 -31
- package/src/irdevices/cameras.ts +79 -24
- package/src/irdevices/fans.ts +89 -36
- package/src/irdevices/lights.ts +80 -25
- package/src/irdevices/others.ts +86 -31
- package/src/irdevices/tvs.ts +96 -42
- package/src/irdevices/vacuumcleaners.ts +79 -24
- package/src/irdevices/waterheaters.ts +79 -24
- package/src/platform.ts +285 -302
- package/src/settings.ts +10 -6
- package/dist/devices/indoorcam.d.ts +0 -64
- package/dist/devices/indoorcam.d.ts.map +0 -1
- package/dist/devices/indoorcam.js +0 -249
- package/dist/devices/indoorcam.js.map +0 -1
- package/src/devices/indoorcam.ts +0 -309
package/dist/devices/curtains.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
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,37 +115,55 @@ class Curtain {
|
|
|
115
115
|
await this.pushChanges();
|
|
116
116
|
}
|
|
117
117
|
catch (e) {
|
|
118
|
-
this.
|
|
119
|
-
if (this.
|
|
120
|
-
this.
|
|
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.
|
|
124
|
-
this.
|
|
123
|
+
if (this.platform.debugMode) {
|
|
124
|
+
this.errorLog(`Curtain: ${this.accessory.displayName} failed pushChanges,`
|
|
125
125
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
126
126
|
}
|
|
127
|
-
this.apiError(
|
|
127
|
+
this.apiError();
|
|
128
128
|
}
|
|
129
129
|
this.curtainUpdateInProgress = false;
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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.
|
|
142
|
+
this.curtainRefreshRate = this.device?.curtain?.refreshRate;
|
|
141
143
|
}
|
|
142
144
|
else {
|
|
143
|
-
this.
|
|
144
|
-
if (this.
|
|
145
|
-
this.
|
|
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
|
-
|
|
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.
|
|
204
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} BLE parseStatus`);
|
|
187
205
|
this.setMinMax();
|
|
188
206
|
this.CurrentPosition = 100 - Number(this.position);
|
|
189
|
-
this.
|
|
207
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} CurrentPosition ${this.CurrentPosition}`);
|
|
190
208
|
if (this.setNewTarget) {
|
|
191
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
282
|
+
this.debugLog();
|
|
265
283
|
}
|
|
266
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
303
|
+
this.debugLog(`Curtain ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition}`);
|
|
286
304
|
if (this.setNewTarget) {
|
|
287
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
355
|
-
this.
|
|
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.
|
|
377
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
360
378
|
}
|
|
361
379
|
else {
|
|
362
380
|
this.connected = false;
|
|
363
|
-
this.
|
|
381
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
364
382
|
}
|
|
365
383
|
};
|
|
366
384
|
// Wait 10 seconds
|
|
@@ -373,49 +391,49 @@ class Curtain {
|
|
|
373
391
|
this.updateHomeKitCharacteristics();
|
|
374
392
|
}
|
|
375
393
|
else {
|
|
376
|
-
this.
|
|
394
|
+
this.errorLog(`Curtain: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
377
395
|
if (this.platform.config.credentials?.openToken) {
|
|
378
|
-
this.
|
|
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.
|
|
384
|
-
if (this.
|
|
385
|
-
this.
|
|
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.
|
|
389
|
-
this.
|
|
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.
|
|
411
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
394
412
|
await this.openAPIRefreshStatus();
|
|
395
413
|
}
|
|
396
|
-
this.apiError(
|
|
414
|
+
this.apiError();
|
|
397
415
|
});
|
|
398
416
|
}
|
|
399
417
|
async openAPIRefreshStatus() {
|
|
400
418
|
if (this.platform.config.credentials?.openToken) {
|
|
401
|
-
this.
|
|
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.
|
|
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.
|
|
410
|
-
if (this.
|
|
411
|
-
this.
|
|
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.
|
|
415
|
-
this.
|
|
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
|
-
this.apiError(
|
|
436
|
+
this.apiError();
|
|
419
437
|
}
|
|
420
438
|
}
|
|
421
439
|
}
|
|
@@ -435,183 +453,174 @@ class Curtain {
|
|
|
435
453
|
}
|
|
436
454
|
async BLEpushChanges() {
|
|
437
455
|
if (this.TargetPosition !== this.CurrentPosition) {
|
|
438
|
-
this.
|
|
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.
|
|
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.
|
|
462
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Done.`);
|
|
445
463
|
}).catch(async (e) => {
|
|
446
|
-
this.
|
|
447
|
-
if (this.
|
|
448
|
-
this.
|
|
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.
|
|
452
|
-
this.
|
|
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.
|
|
474
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
457
475
|
await this.OpenAPIpushChanges();
|
|
458
476
|
}
|
|
459
|
-
this.apiError(
|
|
477
|
+
this.apiError();
|
|
460
478
|
});
|
|
461
479
|
}
|
|
462
480
|
else {
|
|
463
|
-
this.
|
|
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.
|
|
488
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} OpenAPI pushChanges`);
|
|
471
489
|
if (this.TargetPosition !== this.CurrentPosition) {
|
|
472
|
-
this.
|
|
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.
|
|
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.
|
|
501
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
|
|
484
502
|
this.statusCode(push);
|
|
485
503
|
}
|
|
486
504
|
else {
|
|
487
|
-
this.
|
|
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.
|
|
493
|
-
if (this.
|
|
494
|
-
this.
|
|
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.
|
|
498
|
-
this.
|
|
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
|
-
this.apiError(
|
|
519
|
+
this.apiError();
|
|
502
520
|
}
|
|
503
521
|
}
|
|
504
522
|
}
|
|
505
523
|
updateHomeKitCharacteristics() {
|
|
506
524
|
this.setMinMax();
|
|
507
525
|
if (this.CurrentPosition === undefined || Number.isNaN(this.CurrentPosition)) {
|
|
508
|
-
this.
|
|
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.
|
|
530
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} updateCharacteristic CurrentPosition: ${this.CurrentPosition}`);
|
|
513
531
|
}
|
|
514
532
|
if (this.PositionState === undefined) {
|
|
515
|
-
this.
|
|
533
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} PositionState: ${this.PositionState}`);
|
|
516
534
|
}
|
|
517
535
|
else {
|
|
518
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
561
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
544
562
|
}
|
|
545
563
|
if (this.StatusLowBattery === undefined) {
|
|
546
|
-
this.
|
|
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.
|
|
568
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
551
569
|
}
|
|
552
570
|
}
|
|
553
571
|
}
|
|
554
|
-
apiError(
|
|
555
|
-
this.
|
|
556
|
-
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
557
|
-
this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
558
|
-
if (!this.device.curtain?.hide_lightsensor) {
|
|
559
|
-
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
|
|
560
|
-
}
|
|
561
|
-
if (this.device.ble) {
|
|
562
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
563
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
564
|
-
}
|
|
572
|
+
apiError() {
|
|
573
|
+
throw new this.platform.api.hap.HapStatusError(-70402 /* SERVICE_COMMUNICATION_FAILURE */);
|
|
565
574
|
}
|
|
566
575
|
statusCode(push) {
|
|
567
576
|
switch (push.data.statusCode) {
|
|
568
577
|
case 151:
|
|
569
|
-
this.
|
|
578
|
+
this.errorLog(`Curtain: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
570
579
|
break;
|
|
571
580
|
case 152:
|
|
572
|
-
this.
|
|
581
|
+
this.errorLog(`Curtain: ${this.accessory.displayName} Device not found.`);
|
|
573
582
|
break;
|
|
574
583
|
case 160:
|
|
575
|
-
this.
|
|
584
|
+
this.errorLog(`Curtain: ${this.accessory.displayName} Command is not supported.`);
|
|
576
585
|
break;
|
|
577
586
|
case 161:
|
|
578
|
-
this.
|
|
587
|
+
this.errorLog(`Curtain: ${this.accessory.displayName} Device is offline.`);
|
|
579
588
|
break;
|
|
580
589
|
case 171:
|
|
581
|
-
this.
|
|
590
|
+
this.errorLog(`Curtain: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
582
591
|
break;
|
|
583
592
|
case 190:
|
|
584
|
-
this.
|
|
593
|
+
this.errorLog(`Curtain: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
585
594
|
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
586
595
|
break;
|
|
587
596
|
case 100:
|
|
588
|
-
this.
|
|
597
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Command successfully sent.`);
|
|
589
598
|
break;
|
|
590
599
|
default:
|
|
591
|
-
this.
|
|
600
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Unknown statusCode.`);
|
|
592
601
|
}
|
|
593
602
|
}
|
|
594
603
|
/**
|
|
595
604
|
* Handle requests to set the value of the "Target Position" characteristic
|
|
596
605
|
*/
|
|
597
606
|
TargetPositionSet(value) {
|
|
598
|
-
this.
|
|
607
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} TargetPosition: ${value}`);
|
|
599
608
|
this.TargetPosition = value;
|
|
600
609
|
this.setMinMax();
|
|
601
610
|
if (value > this.CurrentPosition) {
|
|
602
611
|
this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
|
|
603
612
|
this.setNewTarget = true;
|
|
604
|
-
this.
|
|
613
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
|
|
605
614
|
}
|
|
606
615
|
else if (value < this.CurrentPosition) {
|
|
607
616
|
this.PositionState = this.platform.Characteristic.PositionState.DECREASING;
|
|
608
617
|
this.setNewTarget = true;
|
|
609
|
-
this.
|
|
618
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
|
|
610
619
|
}
|
|
611
620
|
else {
|
|
612
621
|
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
613
622
|
this.setNewTarget = false;
|
|
614
|
-
this.
|
|
623
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`);
|
|
615
624
|
}
|
|
616
625
|
this.service.setCharacteristic(this.platform.Characteristic.PositionState, this.PositionState);
|
|
617
626
|
this.service.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
|
|
@@ -622,7 +631,7 @@ class Curtain {
|
|
|
622
631
|
clearTimeout(this.setNewTargetTimer);
|
|
623
632
|
if (this.setNewTarget) {
|
|
624
633
|
this.setNewTargetTimer = setTimeout(() => {
|
|
625
|
-
this.
|
|
634
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} setNewTarget ${this.setNewTarget} timeout`);
|
|
626
635
|
this.setNewTarget = false;
|
|
627
636
|
}, 10000);
|
|
628
637
|
}
|
|
@@ -640,6 +649,37 @@ class Curtain {
|
|
|
640
649
|
}
|
|
641
650
|
}
|
|
642
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
|
+
}
|
|
643
683
|
}
|
|
644
684
|
exports.Curtain = Curtain;
|
|
645
685
|
//# sourceMappingURL=curtains.js.map
|