@switchbot/homebridge-switchbot 3.5.0-beta.22 → 3.5.0-beta.24
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/config.schema.json +23 -2
- package/dist/device/blindtilt.d.ts +21 -98
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +332 -785
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +25 -75
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +566 -778
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +13 -71
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +168 -606
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +13 -78
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +218 -655
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +14 -69
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +196 -553
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +17 -90
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +324 -810
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +58 -0
- package/dist/device/device.d.ts.map +1 -0
- package/dist/device/device.js +629 -0
- package/dist/device/device.js.map +1 -0
- package/dist/device/hub.d.ts +15 -63
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +223 -610
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +10 -69
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +192 -595
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +11 -68
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +156 -599
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -72
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +204 -591
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +15 -66
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +199 -566
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +13 -67
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +152 -592
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +13 -68
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +151 -599
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +13 -73
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +129 -540
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -61
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +71 -476
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +11 -66
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +122 -471
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +9 -66
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +105 -478
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +5 -36
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +228 -337
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +5 -34
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +19 -267
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +5 -34
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +13 -261
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +5 -34
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +13 -260
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +39 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -0
- package/dist/irdevice/irdevice.js +502 -0
- package/dist/irdevice/irdevice.js.map +1 -0
- package/dist/irdevice/light.d.ts +5 -34
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +13 -267
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +18 -48
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +349 -551
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +7 -40
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +79 -325
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +6 -36
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +38 -288
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +6 -36
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +39 -291
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +15 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/utils.d.ts +68 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +71 -0
- package/dist/utils.js.map +1 -1
- package/package.json +8 -8
- package/src/device/blindtilt.ts +356 -809
- package/src/device/bot.ts +601 -865
- package/src/device/ceilinglight.ts +182 -628
- package/src/device/colorbulb.ts +235 -683
- package/src/device/contact.ts +220 -575
- package/src/device/curtain.ts +344 -836
- package/src/device/device.ts +655 -0
- package/src/device/hub.ts +246 -636
- package/src/device/humidifier.ts +224 -645
- package/src/device/iosensor.ts +181 -625
- package/src/device/lightstrip.ts +230 -622
- package/src/device/lock.ts +236 -607
- package/src/device/meter.ts +177 -616
- package/src/device/meterplus.ts +175 -624
- package/src/device/motion.ts +147 -563
- package/src/device/plug.ts +81 -505
- package/src/device/robotvacuumcleaner.ts +139 -494
- package/src/device/waterdetector.ts +126 -506
- package/src/irdevice/airconditioner.ts +228 -353
- package/src/irdevice/airpurifier.ts +23 -282
- package/src/irdevice/camera.ts +18 -277
- package/src/irdevice/fan.ts +18 -275
- package/src/irdevice/irdevice.ts +518 -0
- package/src/irdevice/light.ts +18 -283
- package/src/irdevice/other.ts +394 -621
- package/src/irdevice/tv.ts +97 -344
- package/src/irdevice/vacuumcleaner.ts +46 -310
- package/src/irdevice/waterheater.ts +47 -315
- package/src/settings.ts +20 -3
- package/src/utils.ts +71 -0
package/src/irdevice/light.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* light.ts: @switchbot/homebridge-switchbot.
|
|
4
|
+
*/
|
|
2
5
|
import { request } from 'undici';
|
|
6
|
+
import { irdeviceBase } from './irdevice.js';
|
|
3
7
|
import { SwitchBotPlatform } from '../platform.js';
|
|
4
|
-
import { Devices, irDevicesConfig, irdevice
|
|
8
|
+
import { Devices, irDevicesConfig, irdevice } from '../settings.js';
|
|
9
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Platform Accessory
|
|
8
13
|
* An instance of this class is created for each accessory your platform registers
|
|
9
14
|
* Each accessory may expose multiple services of different service types.
|
|
10
15
|
*/
|
|
11
|
-
export class Light {
|
|
12
|
-
public readonly api: API;
|
|
13
|
-
public readonly log: Logging;
|
|
14
|
-
public readonly config!: SwitchBotPlatformConfig;
|
|
15
|
-
protected readonly hap: HAP;
|
|
16
|
+
export class Light extends irdeviceBase {
|
|
16
17
|
// Services
|
|
17
18
|
lightBulbService?: Service;
|
|
18
19
|
ProgrammableSwitchServiceOn?: Service;
|
|
@@ -24,36 +25,20 @@ export class Light {
|
|
|
24
25
|
ProgrammableSwitchOutputStateOn?: CharacteristicValue;
|
|
25
26
|
ProgrammableSwitchEventOff?: CharacteristicValue;
|
|
26
27
|
ProgrammableSwitchOutputStateOff?: CharacteristicValue;
|
|
27
|
-
FirmwareRevision!: CharacteristicValue;
|
|
28
|
-
|
|
29
|
-
// Config
|
|
30
|
-
deviceLogging!: string;
|
|
31
|
-
disablePushOn?: boolean;
|
|
32
|
-
disablePushOff?: boolean;
|
|
33
28
|
|
|
34
29
|
constructor(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
readonly platform: SwitchBotPlatform,
|
|
31
|
+
accessory: PlatformAccessory,
|
|
32
|
+
device: irdevice & irDevicesConfig,
|
|
38
33
|
) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.config = this.platform.config;
|
|
42
|
-
this.hap = this.api.hap;
|
|
34
|
+
super(platform, accessory, device);
|
|
35
|
+
|
|
43
36
|
// default placeholders
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// set accessory information
|
|
51
|
-
accessory
|
|
52
|
-
.getService(this.hap.Service.AccessoryInformation)!
|
|
53
|
-
.setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
|
|
54
|
-
.setCharacteristic(this.hap.Characteristic.Model, device.remoteType)
|
|
55
|
-
.setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId)
|
|
56
|
-
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
37
|
+
if (this.On === undefined) {
|
|
38
|
+
this.On = false;
|
|
39
|
+
} else {
|
|
40
|
+
this.On = accessory.context.On;
|
|
41
|
+
}
|
|
57
42
|
|
|
58
43
|
if (!device.irlight?.stateless) {
|
|
59
44
|
// get the Light service if it exists, otherwise create a new Light service
|
|
@@ -64,9 +49,6 @@ export class Light {
|
|
|
64
49
|
|
|
65
50
|
|
|
66
51
|
this.lightBulbService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
67
|
-
if (!this.lightBulbService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
68
|
-
this.lightBulbService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
69
|
-
}
|
|
70
52
|
|
|
71
53
|
// handle on / off events using the On characteristic
|
|
72
54
|
this.lightBulbService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
@@ -79,9 +61,6 @@ export class Light {
|
|
|
79
61
|
|
|
80
62
|
|
|
81
63
|
this.ProgrammableSwitchServiceOn.setCharacteristic(this.hap.Characteristic.Name, `${accessory.displayName} On`);
|
|
82
|
-
if (!this.ProgrammableSwitchServiceOn.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
83
|
-
this.ProgrammableSwitchServiceOn.addCharacteristic(this.hap.Characteristic.ConfiguredName, `${accessory.displayName} On`);
|
|
84
|
-
}
|
|
85
64
|
|
|
86
65
|
this.ProgrammableSwitchServiceOn.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
87
66
|
validValueRanges: [0, 0],
|
|
@@ -105,9 +84,6 @@ export class Light {
|
|
|
105
84
|
|
|
106
85
|
|
|
107
86
|
this.ProgrammableSwitchServiceOff.setCharacteristic(this.hap.Characteristic.Name, `${accessory.displayName} Off`);
|
|
108
|
-
if (!this.ProgrammableSwitchServiceOff.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
109
|
-
this.ProgrammableSwitchServiceOff.addCharacteristic(this.hap.Characteristic.ConfiguredName, `${accessory.displayName} Off`);
|
|
110
|
-
}
|
|
111
87
|
|
|
112
88
|
this.ProgrammableSwitchServiceOff.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
113
89
|
validValueRanges: [0, 0],
|
|
@@ -305,128 +281,6 @@ export class Light {
|
|
|
305
281
|
}
|
|
306
282
|
}
|
|
307
283
|
|
|
308
|
-
async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
309
|
-
if (device.disablePushOn === undefined) {
|
|
310
|
-
this.disablePushOn = false;
|
|
311
|
-
} else {
|
|
312
|
-
this.disablePushOn = device.disablePushOn;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
async disablePushOffChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
317
|
-
if (device.disablePushOff === undefined) {
|
|
318
|
-
this.disablePushOff = false;
|
|
319
|
-
} else {
|
|
320
|
-
this.disablePushOff = device.disablePushOff;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
async commandType(): Promise<string> {
|
|
325
|
-
let commandType: string;
|
|
326
|
-
if (this.device.customize) {
|
|
327
|
-
commandType = 'customize';
|
|
328
|
-
} else {
|
|
329
|
-
commandType = 'command';
|
|
330
|
-
}
|
|
331
|
-
return commandType;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
async commandOn(): Promise<string> {
|
|
335
|
-
let command: string;
|
|
336
|
-
if (this.device.customize && this.device.customOn) {
|
|
337
|
-
command = this.device.customOn;
|
|
338
|
-
} else {
|
|
339
|
-
command = 'turnOn';
|
|
340
|
-
}
|
|
341
|
-
return command;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
async commandOff(): Promise<string> {
|
|
345
|
-
let command: string;
|
|
346
|
-
if (this.device.customize && this.device.customOff) {
|
|
347
|
-
command = this.device.customOff;
|
|
348
|
-
} else {
|
|
349
|
-
command = 'turnOff';
|
|
350
|
-
}
|
|
351
|
-
return command;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
async statusCode(statusCode: number): Promise<void> {
|
|
355
|
-
switch (statusCode) {
|
|
356
|
-
case 151:
|
|
357
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this deviceType, statusCode: ${statusCode}`);
|
|
358
|
-
break;
|
|
359
|
-
case 152:
|
|
360
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found, statusCode: ${statusCode}`);
|
|
361
|
-
break;
|
|
362
|
-
case 160:
|
|
363
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported, statusCode: ${statusCode}`);
|
|
364
|
-
break;
|
|
365
|
-
case 161:
|
|
366
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
367
|
-
break;
|
|
368
|
-
case 171:
|
|
369
|
-
this.errorLog(
|
|
370
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
371
|
-
`Hub: ${this.device.hubDeviceId}`,
|
|
372
|
-
);
|
|
373
|
-
break;
|
|
374
|
-
case 190:
|
|
375
|
-
this.errorLog(
|
|
376
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
|
|
377
|
-
` Or command format is invalid, statusCode: ${statusCode}`,
|
|
378
|
-
);
|
|
379
|
-
break;
|
|
380
|
-
case 100:
|
|
381
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent, statusCode: ${statusCode}`);
|
|
382
|
-
break;
|
|
383
|
-
case 200:
|
|
384
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
385
|
-
break;
|
|
386
|
-
case 400:
|
|
387
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Bad Request, The client has issued an invalid request. `
|
|
388
|
-
+ `This is commonly used to specify validation errors in a request payload, statusCode: ${statusCode}`);
|
|
389
|
-
break;
|
|
390
|
-
case 401:
|
|
391
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unauthorized, Authorization for the API is required, `
|
|
392
|
-
+ `but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
393
|
-
break;
|
|
394
|
-
case 403:
|
|
395
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Forbidden, The request has been authenticated but does not `
|
|
396
|
-
+ `have appropriate permissions, or a requested resource is not found, statusCode: ${statusCode}`);
|
|
397
|
-
break;
|
|
398
|
-
case 404:
|
|
399
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Found, Specifies the requested path does not exist, `
|
|
400
|
-
+ `statusCode: ${statusCode}`);
|
|
401
|
-
break;
|
|
402
|
-
case 406:
|
|
403
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Acceptable, The client has requested a MIME type via `
|
|
404
|
-
+ `the Accept header for a value not supported by the server, statusCode: ${statusCode}`);
|
|
405
|
-
break;
|
|
406
|
-
case 415:
|
|
407
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unsupported Media Type, The client has defined a contentType `
|
|
408
|
-
+ `header that is not supported by the server, statusCode: ${statusCode}`);
|
|
409
|
-
break;
|
|
410
|
-
case 422:
|
|
411
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unprocessable Entity, The client has made a valid request, but `
|
|
412
|
-
+ `the server cannot process it. This is often used for APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
413
|
-
break;
|
|
414
|
-
case 429:
|
|
415
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Too Many Requests, The client has exceeded the number of `
|
|
416
|
-
+ `requests allowed for a given time window, statusCode: ${statusCode}`);
|
|
417
|
-
break;
|
|
418
|
-
case 500:
|
|
419
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Internal Server Error, An unexpected error on the SmartThings `
|
|
420
|
-
+ `servers has occurred. These errors should be rare, statusCode: ${statusCode}`);
|
|
421
|
-
break;
|
|
422
|
-
default:
|
|
423
|
-
this.infoLog(
|
|
424
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
425
|
-
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
284
|
async apiError(e: any): Promise<void> {
|
|
431
285
|
if (this.device.irlight?.stateless) {
|
|
432
286
|
this.lightBulbService?.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
@@ -437,123 +291,4 @@ export class Light {
|
|
|
437
291
|
this.ProgrammableSwitchServiceOff?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
438
292
|
}
|
|
439
293
|
}
|
|
440
|
-
|
|
441
|
-
async deviceContext() {
|
|
442
|
-
if (this.On === undefined) {
|
|
443
|
-
this.On = false;
|
|
444
|
-
} else {
|
|
445
|
-
this.On = this.accessory.context.On;
|
|
446
|
-
}
|
|
447
|
-
if (this.FirmwareRevision === undefined) {
|
|
448
|
-
this.FirmwareRevision = this.platform.version;
|
|
449
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
async deviceConfig(device: irdevice & irDevicesConfig): Promise<void> {
|
|
454
|
-
let config = {};
|
|
455
|
-
if (device.irlight) {
|
|
456
|
-
config = device.irlight;
|
|
457
|
-
}
|
|
458
|
-
if (device.logging !== undefined) {
|
|
459
|
-
config['logging'] = device.logging;
|
|
460
|
-
}
|
|
461
|
-
if (device.connectionType !== undefined) {
|
|
462
|
-
config['connectionType'] = device.connectionType;
|
|
463
|
-
}
|
|
464
|
-
if (device.external !== undefined) {
|
|
465
|
-
config['external'] = device.external;
|
|
466
|
-
}
|
|
467
|
-
if (device.customOn !== undefined) {
|
|
468
|
-
config['customOn'] = device.customOn;
|
|
469
|
-
}
|
|
470
|
-
if (device.customOff !== undefined) {
|
|
471
|
-
config['customOff'] = device.customOff;
|
|
472
|
-
}
|
|
473
|
-
if (device.customize !== undefined) {
|
|
474
|
-
config['customize'] = device.customize;
|
|
475
|
-
}
|
|
476
|
-
if (device.disablePushOn !== undefined) {
|
|
477
|
-
config['disablePushOn'] = device.disablePushOn;
|
|
478
|
-
}
|
|
479
|
-
if (device.disablePushOff !== undefined) {
|
|
480
|
-
config['disablePushOff'] = device.disablePushOff;
|
|
481
|
-
}
|
|
482
|
-
if (Object.entries(config).length !== 0) {
|
|
483
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
async deviceLogs(device: irdevice & irDevicesConfig): Promise<void> {
|
|
488
|
-
if (this.platform.debugMode) {
|
|
489
|
-
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
490
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
491
|
-
} else if (device.logging) {
|
|
492
|
-
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
493
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
494
|
-
} else if (this.platform.config.options?.logging) {
|
|
495
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
496
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
497
|
-
} else {
|
|
498
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
499
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Logging for Device
|
|
505
|
-
*/
|
|
506
|
-
successLog(...log: any[]): void {
|
|
507
|
-
if (this.enablingDeviceLogging()) {
|
|
508
|
-
this.platform.log.success(String(...log));
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
infoLog(...log: any[]): void {
|
|
513
|
-
if (this.enablingDeviceLogging()) {
|
|
514
|
-
this.platform.log.info(String(...log));
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
warnLog(...log: any[]): void {
|
|
519
|
-
if (this.enablingDeviceLogging()) {
|
|
520
|
-
this.platform.log.warn(String(...log));
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
debugWarnLog(...log: any[]): void {
|
|
525
|
-
if (this.enablingDeviceLogging()) {
|
|
526
|
-
if (this.deviceLogging?.includes('debug')) {
|
|
527
|
-
this.platform.log.warn('[DEBUG]', String(...log));
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
errorLog(...log: any[]): void {
|
|
533
|
-
if (this.enablingDeviceLogging()) {
|
|
534
|
-
this.platform.log.error(String(...log));
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
debugErrorLog(...log: any[]): void {
|
|
539
|
-
if (this.enablingDeviceLogging()) {
|
|
540
|
-
if (this.deviceLogging?.includes('debug')) {
|
|
541
|
-
this.platform.log.error('[DEBUG]', String(...log));
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
debugLog(...log: any[]): void {
|
|
547
|
-
if (this.enablingDeviceLogging()) {
|
|
548
|
-
if (this.deviceLogging === 'debug') {
|
|
549
|
-
this.platform.log.info('[DEBUG]', String(...log));
|
|
550
|
-
} else {
|
|
551
|
-
this.platform.log.debug(String(...log));
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
enablingDeviceLogging(): boolean {
|
|
557
|
-
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
558
|
-
}
|
|
559
294
|
}
|