@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
|
+
import { CharacteristicValue, HAPStatus, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -14,16 +14,24 @@ export class VacuumCleaner {
|
|
|
14
14
|
|
|
15
15
|
// Characteristic Values
|
|
16
16
|
On!: CharacteristicValue;
|
|
17
|
+
OnCached!: CharacteristicValue;
|
|
17
18
|
|
|
18
19
|
// Config
|
|
19
|
-
|
|
20
|
-
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
20
|
+
deviceLogging!: string;
|
|
21
21
|
|
|
22
22
|
constructor(
|
|
23
23
|
private readonly platform: SwitchBotPlatform,
|
|
24
24
|
private accessory: PlatformAccessory,
|
|
25
25
|
public device: irdevice & irDevicesConfig,
|
|
26
26
|
) {
|
|
27
|
+
// default placeholders
|
|
28
|
+
this.logs();
|
|
29
|
+
if (this.On === undefined) {
|
|
30
|
+
this.On = false;
|
|
31
|
+
} else {
|
|
32
|
+
this.On = this.accessory.context.On;
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
// set accessory information
|
|
28
36
|
accessory
|
|
29
37
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
@@ -49,8 +57,18 @@ export class VacuumCleaner {
|
|
|
49
57
|
this.service.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
50
58
|
}
|
|
51
59
|
|
|
60
|
+
logs() {
|
|
61
|
+
if (this.device.logging) {
|
|
62
|
+
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
63
|
+
} else if (this.platform.config.options?.logging) {
|
|
64
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
65
|
+
} else {
|
|
66
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
52
70
|
private OnSet(value: CharacteristicValue) {
|
|
53
|
-
this.
|
|
71
|
+
this.debugLog(`Vacuum Cleaner: ${this.accessory.displayName} On: ${value}`);
|
|
54
72
|
this.On = value;
|
|
55
73
|
if (this.On) {
|
|
56
74
|
this.pushOnChanges();
|
|
@@ -61,10 +79,10 @@ export class VacuumCleaner {
|
|
|
61
79
|
|
|
62
80
|
private updateHomeKitCharacteristics() {
|
|
63
81
|
if (this.On === undefined) {
|
|
64
|
-
this.
|
|
82
|
+
this.debugLog(`Vacuum Cleaner: ${this.accessory.displayName} On: ${this.On}`);
|
|
65
83
|
} else {
|
|
66
84
|
this.service?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
67
|
-
this.
|
|
85
|
+
this.debugLog(`Vacuum Cleaner: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
68
86
|
}
|
|
69
87
|
}
|
|
70
88
|
|
|
@@ -102,58 +120,95 @@ export class VacuumCleaner {
|
|
|
102
120
|
|
|
103
121
|
public async pushChanges(payload: payload) {
|
|
104
122
|
try {
|
|
105
|
-
this.
|
|
123
|
+
this.infoLog(`Vacuum Cleaner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
106
124
|
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
107
125
|
|
|
108
126
|
// Make the API request
|
|
109
127
|
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
110
|
-
this.
|
|
128
|
+
this.debugLog(`Vacuum Cleaner: ${this.accessory.displayName} pushChanges: ${push.data}`);
|
|
111
129
|
this.statusCode(push);
|
|
130
|
+
this.OnCached = this.On;
|
|
131
|
+
this.accessory.context.On = this.OnCached;
|
|
112
132
|
this.updateHomeKitCharacteristics();
|
|
113
133
|
} catch (e: any) {
|
|
114
|
-
this.
|
|
115
|
-
if (this.
|
|
116
|
-
this.
|
|
134
|
+
this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
135
|
+
if (this.deviceLogging === 'debug') {
|
|
136
|
+
this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
117
137
|
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
118
138
|
}
|
|
119
|
-
if (this.
|
|
120
|
-
this.
|
|
139
|
+
if (this.platform.debugMode) {
|
|
140
|
+
this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
121
141
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
122
142
|
}
|
|
123
|
-
this.apiError(
|
|
143
|
+
this.apiError();
|
|
124
144
|
}
|
|
125
145
|
}
|
|
126
146
|
|
|
127
147
|
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
|
128
148
|
switch (push.data.statusCode) {
|
|
129
149
|
case 151:
|
|
130
|
-
this.
|
|
150
|
+
this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
131
151
|
break;
|
|
132
152
|
case 152:
|
|
133
|
-
this.
|
|
153
|
+
this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} Device not found.`);
|
|
134
154
|
break;
|
|
135
155
|
case 160:
|
|
136
|
-
this.
|
|
156
|
+
this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} Command is not supported.`);
|
|
137
157
|
break;
|
|
138
158
|
case 161:
|
|
139
|
-
this.
|
|
159
|
+
this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} Device is offline.`);
|
|
140
160
|
break;
|
|
141
161
|
case 171:
|
|
142
|
-
this.
|
|
162
|
+
this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
143
163
|
break;
|
|
144
164
|
case 190:
|
|
145
|
-
this.
|
|
165
|
+
this.errorLog(`Vacuum Cleaner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
|
146
166
|
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
147
167
|
break;
|
|
148
168
|
case 100:
|
|
149
|
-
this.
|
|
169
|
+
this.debugLog(`Vacuum Cleaner: ${this.accessory.displayName} Command successfully sent.`);
|
|
150
170
|
break;
|
|
151
171
|
default:
|
|
152
|
-
this.
|
|
172
|
+
this.debugLog(`Vacuum Cleaner: ${this.accessory.displayName} Unknown statusCode.`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public apiError() {
|
|
177
|
+
throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Logging for Device
|
|
182
|
+
*/
|
|
183
|
+
infoLog(...log: any[]) {
|
|
184
|
+
if (this.enablingDeviceLogging()) {
|
|
185
|
+
this.platform.log.info(String(...log));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
warnLog(...log: any[]) {
|
|
190
|
+
if (this.enablingDeviceLogging()) {
|
|
191
|
+
this.platform.log.warn(String(...log));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
errorLog(...log: any[]) {
|
|
196
|
+
if (this.enablingDeviceLogging()) {
|
|
197
|
+
this.platform.log.error(String(...log));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
debugLog(...log: any[]) {
|
|
202
|
+
if (this.enablingDeviceLogging()) {
|
|
203
|
+
if (this.deviceLogging === 'debug') {
|
|
204
|
+
this.platform.log.info('[DEBUG]', String(...log));
|
|
205
|
+
} else {
|
|
206
|
+
this.platform.log.debug(String(...log));
|
|
207
|
+
}
|
|
153
208
|
}
|
|
154
209
|
}
|
|
155
210
|
|
|
156
|
-
|
|
157
|
-
this.
|
|
211
|
+
enablingDeviceLogging(): boolean {
|
|
212
|
+
return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
|
|
158
213
|
}
|
|
159
214
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
|
+
import { CharacteristicValue, HAPStatus, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -14,16 +14,24 @@ export class WaterHeater {
|
|
|
14
14
|
|
|
15
15
|
// Characteristic Values
|
|
16
16
|
Active!: CharacteristicValue;
|
|
17
|
+
ActiveCached!: CharacteristicValue;
|
|
17
18
|
|
|
18
19
|
// Config
|
|
19
|
-
|
|
20
|
-
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
20
|
+
deviceLogging!: string;
|
|
21
21
|
|
|
22
22
|
constructor(
|
|
23
23
|
private readonly platform: SwitchBotPlatform,
|
|
24
24
|
private accessory: PlatformAccessory,
|
|
25
25
|
public device: irdevice & irDevicesConfig,
|
|
26
26
|
) {
|
|
27
|
+
// default placeholders
|
|
28
|
+
this.logs();
|
|
29
|
+
if (this.Active === undefined) {
|
|
30
|
+
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
31
|
+
} else {
|
|
32
|
+
this.Active = this.accessory.context.Active;
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
// set accessory information
|
|
28
36
|
accessory
|
|
29
37
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
@@ -58,8 +66,18 @@ export class WaterHeater {
|
|
|
58
66
|
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
59
67
|
}
|
|
60
68
|
|
|
69
|
+
logs() {
|
|
70
|
+
if (this.device.logging) {
|
|
71
|
+
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
72
|
+
} else if (this.platform.config.options?.logging) {
|
|
73
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
74
|
+
} else {
|
|
75
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
61
79
|
private ActiveSet(value: CharacteristicValue) {
|
|
62
|
-
this.
|
|
80
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} Active: ${value}`);
|
|
63
81
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
64
82
|
this.pushWaterHeaterOffChanges();
|
|
65
83
|
this.service.setCharacteristic(
|
|
@@ -71,14 +89,16 @@ export class WaterHeater {
|
|
|
71
89
|
this.service.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.IN_USE);
|
|
72
90
|
}
|
|
73
91
|
this.Active = value;
|
|
92
|
+
this.ActiveCached = this.Active;
|
|
93
|
+
this.accessory.context.Active = this.ActiveCached;
|
|
74
94
|
}
|
|
75
95
|
|
|
76
96
|
private updateHomeKitCharacteristics() {
|
|
77
97
|
if (this.Active === undefined) {
|
|
78
|
-
this.
|
|
98
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
79
99
|
} else {
|
|
80
100
|
this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
81
|
-
this.
|
|
101
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
82
102
|
}
|
|
83
103
|
}
|
|
84
104
|
|
|
@@ -116,58 +136,93 @@ export class WaterHeater {
|
|
|
116
136
|
|
|
117
137
|
public async pushChanges(payload: payload) {
|
|
118
138
|
try {
|
|
119
|
-
this.
|
|
139
|
+
this.infoLog(`Water Heater: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
120
140
|
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
121
141
|
|
|
122
142
|
// Make the API request
|
|
123
143
|
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
124
|
-
this.
|
|
144
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} pushChanges: ${push.data}`);
|
|
125
145
|
this.statusCode(push);
|
|
126
146
|
this.updateHomeKitCharacteristics();
|
|
127
147
|
} catch (e: any) {
|
|
128
|
-
this.
|
|
129
|
-
if (this.
|
|
130
|
-
this.
|
|
148
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
149
|
+
if (this.deviceLogging === 'debug') {
|
|
150
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
131
151
|
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
132
152
|
}
|
|
133
|
-
if (this.
|
|
134
|
-
this.
|
|
153
|
+
if (this.platform.debugMode) {
|
|
154
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
135
155
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
136
156
|
}
|
|
137
|
-
this.apiError(
|
|
157
|
+
this.apiError();
|
|
138
158
|
}
|
|
139
159
|
}
|
|
140
160
|
|
|
141
161
|
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
|
142
162
|
switch (push.data.statusCode) {
|
|
143
163
|
case 151:
|
|
144
|
-
this.
|
|
164
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
145
165
|
break;
|
|
146
166
|
case 152:
|
|
147
|
-
this.
|
|
167
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Device not found.`);
|
|
148
168
|
break;
|
|
149
169
|
case 160:
|
|
150
|
-
this.
|
|
170
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Command is not supported.`);
|
|
151
171
|
break;
|
|
152
172
|
case 161:
|
|
153
|
-
this.
|
|
173
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Device is offline.`);
|
|
154
174
|
break;
|
|
155
175
|
case 171:
|
|
156
|
-
this.
|
|
176
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
157
177
|
break;
|
|
158
178
|
case 190:
|
|
159
|
-
this.
|
|
179
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
|
160
180
|
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
161
181
|
break;
|
|
162
182
|
case 100:
|
|
163
|
-
this.
|
|
183
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} Command successfully sent.`);
|
|
164
184
|
break;
|
|
165
185
|
default:
|
|
166
|
-
this.
|
|
186
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} Unknown statusCode.`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public apiError() {
|
|
191
|
+
throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Logging for Device
|
|
196
|
+
*/
|
|
197
|
+
infoLog(...log: any[]) {
|
|
198
|
+
if (this.enablingDeviceLogging()) {
|
|
199
|
+
this.platform.log.info(String(...log));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
warnLog(...log: any[]) {
|
|
204
|
+
if (this.enablingDeviceLogging()) {
|
|
205
|
+
this.platform.log.warn(String(...log));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
errorLog(...log: any[]) {
|
|
210
|
+
if (this.enablingDeviceLogging()) {
|
|
211
|
+
this.platform.log.error(String(...log));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
debugLog(...log: any[]) {
|
|
216
|
+
if (this.enablingDeviceLogging()) {
|
|
217
|
+
if (this.deviceLogging === 'debug') {
|
|
218
|
+
this.platform.log.info('[DEBUG]', String(...log));
|
|
219
|
+
} else {
|
|
220
|
+
this.platform.log.debug(String(...log));
|
|
221
|
+
}
|
|
167
222
|
}
|
|
168
223
|
}
|
|
169
224
|
|
|
170
|
-
|
|
171
|
-
this.
|
|
225
|
+
enablingDeviceLogging(): boolean {
|
|
226
|
+
return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
|
|
172
227
|
}
|
|
173
228
|
}
|