@switchbot/homebridge-switchbot 1.8.2 → 1.8.3-beta.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.
- package/.eslintrc +1 -1
- package/.vscode/extensions.json +5 -0
- package/.vscode/settings.json +15 -0
- package/dist/devices/bots.d.ts +34 -35
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +241 -184
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +50 -50
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +145 -131
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +27 -29
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +138 -115
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +29 -31
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +211 -176
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +33 -33
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +214 -189
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +30 -31
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +124 -100
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +25 -26
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +120 -102
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +23 -23
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +81 -63
- package/dist/devices/plugs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +6 -6
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +105 -79
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +5 -5
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +56 -42
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +5 -5
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +31 -27
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +5 -5
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +45 -38
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +5 -5
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +37 -33
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +5 -5
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +34 -29
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +5 -5
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +91 -76
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +5 -5
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +31 -27
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +5 -5
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +31 -27
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +12 -12
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +241 -172
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -4
- package/dist/settings.js.map +1 -1
- package/package.json +72 -71
- package/src/devices/bots.ts +927 -442
- package/src/devices/colorbulb.ts +473 -246
- package/src/devices/contact.ts +381 -208
- package/src/devices/curtains.ts +613 -321
- package/src/devices/humidifiers.ts +594 -323
- package/src/devices/meters.ts +331 -186
- package/src/devices/motion.ts +327 -184
- package/src/devices/plugs.ts +175 -107
- package/src/index.ts +5 -5
- package/src/irdevices/airconditioners.ts +360 -149
- package/src/irdevices/airpurifiers.ts +178 -80
- package/src/irdevices/cameras.ts +109 -51
- package/src/irdevices/fans.ts +174 -77
- package/src/irdevices/lights.ts +110 -57
- package/src/irdevices/others.ts +137 -62
- package/src/irdevices/tvs.ts +249 -124
- package/src/irdevices/vacuumcleaners.ts +112 -52
- package/src/irdevices/waterheaters.ts +115 -53
- package/src/platform.ts +768 -357
- package/src/settings.ts +17 -23
package/src/irdevices/fans.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { AxiosResponse } from
|
|
2
|
-
import { SwitchBotPlatform } from
|
|
3
|
-
import { CharacteristicValue, PlatformAccessory, Service } from
|
|
4
|
-
import {
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
2
|
+
import { SwitchBotPlatform } from "../platform";
|
|
3
|
+
import { CharacteristicValue, PlatformAccessory, Service } from "homebridge";
|
|
4
|
+
import {
|
|
5
|
+
DeviceURL,
|
|
6
|
+
irdevice,
|
|
7
|
+
deviceStatusResponse,
|
|
8
|
+
irDevicesConfig,
|
|
9
|
+
payload,
|
|
10
|
+
} from "../settings";
|
|
5
11
|
|
|
6
12
|
/**
|
|
7
13
|
* Platform Accessory
|
|
@@ -46,15 +52,19 @@ export class Fan {
|
|
|
46
52
|
// set accessory information
|
|
47
53
|
accessory
|
|
48
54
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
49
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer,
|
|
55
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
|
|
50
56
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
51
|
-
.setCharacteristic(
|
|
57
|
+
.setCharacteristic(
|
|
58
|
+
this.platform.Characteristic.SerialNumber,
|
|
59
|
+
device.deviceId!,
|
|
60
|
+
);
|
|
52
61
|
|
|
53
62
|
// get the Television service if it exists, otherwise create a new Television service
|
|
54
63
|
// you can create multiple services for each accessory
|
|
55
64
|
(this.service =
|
|
56
65
|
accessory.getService(this.platform.Service.Fanv2) ||
|
|
57
|
-
accessory.addService(this.platform.Service.Fanv2)),
|
|
66
|
+
accessory.addService(this.platform.Service.Fanv2)),
|
|
67
|
+
`${accessory.displayName} Fan`;
|
|
58
68
|
|
|
59
69
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
60
70
|
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
@@ -62,10 +72,15 @@ export class Fan {
|
|
|
62
72
|
|
|
63
73
|
// set the service name, this is what is displayed as the default name on the Home app
|
|
64
74
|
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
65
|
-
this.service.setCharacteristic(
|
|
75
|
+
this.service.setCharacteristic(
|
|
76
|
+
this.platform.Characteristic.Name,
|
|
77
|
+
accessory.displayName,
|
|
78
|
+
);
|
|
66
79
|
|
|
67
80
|
// handle on / off events using the Active characteristic
|
|
68
|
-
this.service
|
|
81
|
+
this.service
|
|
82
|
+
.getCharacteristic(this.platform.Characteristic.Active)
|
|
83
|
+
.onSet(this.ActiveSet.bind(this));
|
|
69
84
|
|
|
70
85
|
if (device.irfan?.rotation_speed) {
|
|
71
86
|
if (device.irfan?.set_minStep) {
|
|
@@ -93,27 +108,46 @@ export class Fan {
|
|
|
93
108
|
})
|
|
94
109
|
.onSet(this.RotationSpeedSet.bind(this));
|
|
95
110
|
} else if (
|
|
96
|
-
this.service.testCharacteristic(
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
this.service.testCharacteristic(
|
|
112
|
+
this.platform.Characteristic.RotationSpeed,
|
|
113
|
+
) &&
|
|
114
|
+
!device.irfan?.swing_mode
|
|
115
|
+
) {
|
|
116
|
+
const characteristic = this.service.getCharacteristic(
|
|
117
|
+
this.platform.Characteristic.RotationSpeed,
|
|
118
|
+
);
|
|
99
119
|
this.service.removeCharacteristic(characteristic);
|
|
100
|
-
this.debugLog(
|
|
120
|
+
this.debugLog(
|
|
121
|
+
`Fan: ${this.accessory.displayName} Rotation Speed Characteristic was removed.`,
|
|
122
|
+
);
|
|
101
123
|
} else {
|
|
102
124
|
// eslint-disable-next-line max-len
|
|
103
|
-
this.debugLog(
|
|
125
|
+
this.debugLog(
|
|
126
|
+
`Fan: ${this.accessory.displayName} Rotation Speed Characteristic was not removed or not added. To Remove Chracteristic, Clear Cache on this Accessory.`,
|
|
127
|
+
);
|
|
104
128
|
}
|
|
105
129
|
|
|
106
130
|
if (device.irfan?.swing_mode) {
|
|
107
131
|
// handle Osolcation events using the SwingMode characteristic
|
|
108
|
-
this.service
|
|
109
|
-
|
|
110
|
-
|
|
132
|
+
this.service
|
|
133
|
+
.getCharacteristic(this.platform.Characteristic.SwingMode)
|
|
134
|
+
.onSet(this.SwingModeSet.bind(this));
|
|
135
|
+
} else if (
|
|
136
|
+
this.service.testCharacteristic(this.platform.Characteristic.SwingMode) &&
|
|
137
|
+
!device.irfan?.swing_mode
|
|
138
|
+
) {
|
|
139
|
+
const characteristic = this.service.getCharacteristic(
|
|
140
|
+
this.platform.Characteristic.SwingMode,
|
|
141
|
+
);
|
|
111
142
|
this.service.removeCharacteristic(characteristic);
|
|
112
|
-
this.debugLog(
|
|
143
|
+
this.debugLog(
|
|
144
|
+
`Fan: ${this.accessory.displayName} Swing Mode Characteristic was removed.`,
|
|
145
|
+
);
|
|
113
146
|
} else {
|
|
114
147
|
// eslint-disable-next-line max-len
|
|
115
|
-
this.debugLog(
|
|
116
|
-
|
|
148
|
+
this.debugLog(
|
|
149
|
+
`Fan: ${this.accessory.displayName} Swing Mode Characteristic was not removed or not added. To Remove Chracteristic, Clear Cache on this Accessory.`,
|
|
150
|
+
);
|
|
117
151
|
}
|
|
118
152
|
}
|
|
119
153
|
|
|
@@ -133,22 +167,43 @@ export class Fan {
|
|
|
133
167
|
|
|
134
168
|
private updateHomeKitCharacteristics() {
|
|
135
169
|
if (this.Active === undefined) {
|
|
136
|
-
this.debugLog(
|
|
170
|
+
this.debugLog(
|
|
171
|
+
`Fan: ${this.accessory.displayName} Active: ${this.Active}`,
|
|
172
|
+
);
|
|
137
173
|
} else {
|
|
138
|
-
this.service?.updateCharacteristic(
|
|
139
|
-
|
|
174
|
+
this.service?.updateCharacteristic(
|
|
175
|
+
this.platform.Characteristic.Active,
|
|
176
|
+
this.Active,
|
|
177
|
+
);
|
|
178
|
+
this.debugLog(
|
|
179
|
+
`Fan: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
|
|
180
|
+
);
|
|
140
181
|
}
|
|
141
182
|
if (this.SwingMode === undefined) {
|
|
142
|
-
this.debugLog(
|
|
183
|
+
this.debugLog(
|
|
184
|
+
`Fan: ${this.accessory.displayName} SwingMode: ${this.SwingMode}`,
|
|
185
|
+
);
|
|
143
186
|
} else {
|
|
144
|
-
this.service?.updateCharacteristic(
|
|
145
|
-
|
|
187
|
+
this.service?.updateCharacteristic(
|
|
188
|
+
this.platform.Characteristic.SwingMode,
|
|
189
|
+
this.SwingMode,
|
|
190
|
+
);
|
|
191
|
+
this.debugLog(
|
|
192
|
+
`Fan: ${this.accessory.displayName} updateCharacteristic SwingMode: ${this.SwingMode}`,
|
|
193
|
+
);
|
|
146
194
|
}
|
|
147
195
|
if (this.RotationSpeed === undefined) {
|
|
148
|
-
this.debugLog(
|
|
196
|
+
this.debugLog(
|
|
197
|
+
`Fan: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`,
|
|
198
|
+
);
|
|
149
199
|
} else {
|
|
150
|
-
this.service?.updateCharacteristic(
|
|
151
|
-
|
|
200
|
+
this.service?.updateCharacteristic(
|
|
201
|
+
this.platform.Characteristic.RotationSpeed,
|
|
202
|
+
this.RotationSpeed,
|
|
203
|
+
);
|
|
204
|
+
this.debugLog(
|
|
205
|
+
`Fan: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`,
|
|
206
|
+
);
|
|
152
207
|
}
|
|
153
208
|
}
|
|
154
209
|
|
|
@@ -189,9 +244,9 @@ export class Fan {
|
|
|
189
244
|
async pushFanOnChanges() {
|
|
190
245
|
if (this.Active !== 1) {
|
|
191
246
|
const payload = {
|
|
192
|
-
commandType:
|
|
193
|
-
parameter:
|
|
194
|
-
command:
|
|
247
|
+
commandType: "command",
|
|
248
|
+
parameter: "default",
|
|
249
|
+
command: "turnOn",
|
|
195
250
|
} as payload;
|
|
196
251
|
await this.pushTVChanges(payload);
|
|
197
252
|
}
|
|
@@ -199,87 +254,112 @@ export class Fan {
|
|
|
199
254
|
|
|
200
255
|
async pushFanOffChanges() {
|
|
201
256
|
const payload = {
|
|
202
|
-
commandType:
|
|
203
|
-
parameter:
|
|
204
|
-
command:
|
|
257
|
+
commandType: "command",
|
|
258
|
+
parameter: "default",
|
|
259
|
+
command: "turnOff",
|
|
205
260
|
} as payload;
|
|
206
261
|
await this.pushTVChanges(payload);
|
|
207
262
|
}
|
|
208
263
|
|
|
209
264
|
async pushFanSpeedUpChanges() {
|
|
210
265
|
const payload = {
|
|
211
|
-
commandType:
|
|
212
|
-
parameter:
|
|
213
|
-
command:
|
|
266
|
+
commandType: "command",
|
|
267
|
+
parameter: "default",
|
|
268
|
+
command: "highSpeed",
|
|
214
269
|
} as payload;
|
|
215
270
|
await this.pushTVChanges(payload);
|
|
216
271
|
}
|
|
217
272
|
|
|
218
273
|
async pushFanSpeedDownChanges() {
|
|
219
274
|
const payload = {
|
|
220
|
-
commandType:
|
|
221
|
-
parameter:
|
|
222
|
-
command:
|
|
275
|
+
commandType: "command",
|
|
276
|
+
parameter: "default",
|
|
277
|
+
command: "lowSpeed",
|
|
223
278
|
} as payload;
|
|
224
279
|
await this.pushTVChanges(payload);
|
|
225
280
|
}
|
|
226
281
|
|
|
227
282
|
async pushFanSwingChanges() {
|
|
228
283
|
const payload = {
|
|
229
|
-
commandType:
|
|
230
|
-
parameter:
|
|
231
|
-
command:
|
|
284
|
+
commandType: "command",
|
|
285
|
+
parameter: "default",
|
|
286
|
+
command: "swing",
|
|
232
287
|
} as payload;
|
|
233
288
|
await this.pushTVChanges(payload);
|
|
234
289
|
}
|
|
235
290
|
|
|
236
291
|
public async pushTVChanges(payload: payload) {
|
|
237
292
|
try {
|
|
238
|
-
this.infoLog(
|
|
239
|
-
|
|
293
|
+
this.infoLog(
|
|
294
|
+
`Fan: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
|
|
295
|
+
` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
|
|
296
|
+
);
|
|
240
297
|
|
|
241
298
|
// Make the API request
|
|
242
|
-
const push = await this.platform.axios.post(
|
|
243
|
-
|
|
299
|
+
const push = await this.platform.axios.post(
|
|
300
|
+
`${DeviceURL}/${this.device.deviceId}/commands`,
|
|
301
|
+
payload,
|
|
302
|
+
);
|
|
303
|
+
this.debugLog(
|
|
304
|
+
`Fan: ${this.accessory.displayName} pushTVChanges: ${push.data}`,
|
|
305
|
+
);
|
|
244
306
|
this.statusCode(push);
|
|
245
307
|
this.updateHomeKitCharacteristics();
|
|
246
308
|
} catch (e: any) {
|
|
247
|
-
this.errorLog(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
309
|
+
this.errorLog(
|
|
310
|
+
`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`,
|
|
311
|
+
);
|
|
312
|
+
if (this.deviceLogging === "debug") {
|
|
313
|
+
this.errorLog(
|
|
314
|
+
`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
|
|
315
|
+
` Error Message: ${JSON.stringify(e.message)}`,
|
|
316
|
+
);
|
|
251
317
|
}
|
|
252
318
|
if (this.platform.debugMode) {
|
|
253
|
-
this.errorLog(
|
|
254
|
-
|
|
319
|
+
this.errorLog(
|
|
320
|
+
`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
|
|
321
|
+
` Error: ${JSON.stringify(e)}`,
|
|
322
|
+
);
|
|
255
323
|
}
|
|
256
324
|
this.apiError(e);
|
|
257
325
|
}
|
|
258
326
|
}
|
|
259
327
|
|
|
260
|
-
private statusCode(push: AxiosResponse<{ statusCode: number
|
|
328
|
+
private statusCode(push: AxiosResponse<{ statusCode: number }>) {
|
|
261
329
|
switch (push.data.statusCode) {
|
|
262
330
|
case 151:
|
|
263
|
-
this.errorLog(
|
|
331
|
+
this.errorLog(
|
|
332
|
+
`Fan: ${this.accessory.displayName} Command not supported by this device type.`,
|
|
333
|
+
);
|
|
264
334
|
break;
|
|
265
335
|
case 152:
|
|
266
336
|
this.errorLog(`Fan: ${this.accessory.displayName} Device not found.`);
|
|
267
337
|
break;
|
|
268
338
|
case 160:
|
|
269
|
-
this.errorLog(
|
|
339
|
+
this.errorLog(
|
|
340
|
+
`Fan: ${this.accessory.displayName} Command is not supported.`,
|
|
341
|
+
);
|
|
270
342
|
break;
|
|
271
343
|
case 161:
|
|
272
344
|
this.errorLog(`Fan: ${this.accessory.displayName} Device is offline.`);
|
|
273
345
|
break;
|
|
274
346
|
case 171:
|
|
275
|
-
this.errorLog(
|
|
347
|
+
this.errorLog(
|
|
348
|
+
`Fan: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
|
|
349
|
+
);
|
|
276
350
|
break;
|
|
277
351
|
case 190:
|
|
278
|
-
this.errorLog(
|
|
279
|
-
|
|
352
|
+
this.errorLog(
|
|
353
|
+
`Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
354
|
+
` with server, Or command: ${JSON.stringify(
|
|
355
|
+
push.data,
|
|
356
|
+
)} format is invalid`,
|
|
357
|
+
);
|
|
280
358
|
break;
|
|
281
359
|
case 100:
|
|
282
|
-
this.debugLog(
|
|
360
|
+
this.debugLog(
|
|
361
|
+
`Fan: ${this.accessory.displayName} Command successfully sent.`,
|
|
362
|
+
);
|
|
283
363
|
break;
|
|
284
364
|
default:
|
|
285
365
|
this.debugLog(`Fan: ${this.accessory.displayName} Unknown statusCode.`);
|
|
@@ -288,8 +368,14 @@ export class Fan {
|
|
|
288
368
|
|
|
289
369
|
public apiError(e: any) {
|
|
290
370
|
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
291
|
-
this.service.updateCharacteristic(
|
|
292
|
-
|
|
371
|
+
this.service.updateCharacteristic(
|
|
372
|
+
this.platform.Characteristic.RotationSpeed,
|
|
373
|
+
e,
|
|
374
|
+
);
|
|
375
|
+
this.service.updateCharacteristic(
|
|
376
|
+
this.platform.Characteristic.SwingMode,
|
|
377
|
+
e,
|
|
378
|
+
);
|
|
293
379
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
294
380
|
}
|
|
295
381
|
|
|
@@ -299,32 +385,43 @@ export class Fan {
|
|
|
299
385
|
config = device.irfan;
|
|
300
386
|
}
|
|
301
387
|
if (device.logging !== undefined) {
|
|
302
|
-
config[
|
|
388
|
+
config["logging"] = device.logging;
|
|
303
389
|
}
|
|
304
390
|
if (Object.entries(config).length !== 0) {
|
|
305
|
-
this.warnLog(
|
|
391
|
+
this.warnLog(
|
|
392
|
+
`Fan: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`,
|
|
393
|
+
);
|
|
306
394
|
}
|
|
307
395
|
}
|
|
308
396
|
|
|
309
397
|
logs(device: irdevice & irDevicesConfig) {
|
|
310
398
|
if (this.platform.debugMode) {
|
|
311
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
312
|
-
this.debugLog(
|
|
399
|
+
this.deviceLogging = this.accessory.context.logging = "debugMode";
|
|
400
|
+
this.debugLog(
|
|
401
|
+
`Fan: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
|
|
402
|
+
);
|
|
313
403
|
} else if (device.logging) {
|
|
314
404
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
315
|
-
this.debugLog(
|
|
405
|
+
this.debugLog(
|
|
406
|
+
`Fan: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
|
|
407
|
+
);
|
|
316
408
|
} else if (this.platform.config.options?.logging) {
|
|
317
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
318
|
-
|
|
409
|
+
this.deviceLogging = this.accessory.context.logging =
|
|
410
|
+
this.platform.config.options?.logging;
|
|
411
|
+
this.debugLog(
|
|
412
|
+
`Fan: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
|
|
413
|
+
);
|
|
319
414
|
} else {
|
|
320
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
321
|
-
this.debugLog(
|
|
415
|
+
this.deviceLogging = this.accessory.context.logging = "standard";
|
|
416
|
+
this.debugLog(
|
|
417
|
+
`Fan: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
|
|
418
|
+
);
|
|
322
419
|
}
|
|
323
420
|
}
|
|
324
421
|
|
|
325
422
|
/**
|
|
326
|
-
|
|
327
|
-
|
|
423
|
+
* Logging for Device
|
|
424
|
+
*/
|
|
328
425
|
infoLog(...log: any[]) {
|
|
329
426
|
if (this.enablingDeviceLogging()) {
|
|
330
427
|
this.platform.log.info(String(...log));
|
|
@@ -345,8 +442,8 @@ export class Fan {
|
|
|
345
442
|
|
|
346
443
|
debugLog(...log: any[]) {
|
|
347
444
|
if (this.enablingDeviceLogging()) {
|
|
348
|
-
if (this.deviceLogging ===
|
|
349
|
-
this.platform.log.info(
|
|
445
|
+
if (this.deviceLogging === "debug") {
|
|
446
|
+
this.platform.log.info("[DEBUG]", String(...log));
|
|
350
447
|
} else {
|
|
351
448
|
this.platform.log.debug(String(...log));
|
|
352
449
|
}
|
|
@@ -354,6 +451,6 @@ export class Fan {
|
|
|
354
451
|
}
|
|
355
452
|
|
|
356
453
|
enablingDeviceLogging(): boolean {
|
|
357
|
-
return this.deviceLogging
|
|
454
|
+
return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
|
|
358
455
|
}
|
|
359
456
|
}
|