@switchbot/homebridge-switchbot 3.5.0-beta.3 → 3.5.0-beta.30
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 +4 -1
- package/config.schema.json +147 -9
- package/dist/device/blindtilt.d.ts +21 -94
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +347 -756
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +25 -71
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +582 -759
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +13 -67
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +209 -587
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +13 -74
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +250 -632
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +14 -65
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +204 -531
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +17 -86
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +335 -786
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +59 -0
- package/dist/device/device.d.ts.map +1 -0
- package/dist/device/device.js +646 -0
- package/dist/device/device.js.map +1 -0
- package/dist/device/fan.d.ts +51 -0
- package/dist/device/fan.d.ts.map +1 -0
- package/dist/device/fan.js +499 -0
- package/dist/device/fan.js.map +1 -0
- package/dist/device/hub.d.ts +15 -59
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +242 -596
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +10 -65
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +207 -571
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +11 -64
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +174 -584
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -68
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +252 -568
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +15 -62
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +210 -542
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +13 -63
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +170 -577
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +13 -64
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +159 -577
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +13 -69
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +136 -518
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -57
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +82 -452
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +11 -62
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +140 -451
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +9 -70
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +121 -664
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/irdevice/airconditioner.d.ts +8 -48
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +309 -419
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +7 -38
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +72 -304
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +6 -35
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +34 -278
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +6 -39
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +67 -311
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +40 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -0
- package/dist/irdevice/irdevice.js +509 -0
- package/dist/irdevice/irdevice.js.map +1 -0
- package/dist/irdevice/light.d.ts +6 -34
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +23 -272
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +18 -47
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +352 -546
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +7 -39
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +82 -321
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +6 -35
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +41 -284
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +6 -35
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +42 -287
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +14 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +237 -94
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +40 -10
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +0 -552
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +77 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +638 -1
- package/dist/utils.js.map +1 -1
- package/package.json +16 -15
- package/src/custom.d.ts +2 -1
- package/src/device/blindtilt.ts +373 -782
- package/src/device/bot.ts +616 -844
- package/src/device/ceilinglight.ts +222 -607
- package/src/device/colorbulb.ts +264 -656
- package/src/device/contact.ts +229 -553
- package/src/device/curtain.ts +355 -810
- package/src/device/device.ts +673 -0
- package/src/device/fan.ts +548 -0
- package/src/device/hub.ts +268 -623
- package/src/device/humidifier.ts +237 -618
- package/src/device/iosensor.ts +200 -610
- package/src/device/lightstrip.ts +273 -596
- package/src/device/lock.ts +247 -582
- package/src/device/meter.ts +196 -601
- package/src/device/meterplus.ts +184 -602
- package/src/device/motion.ts +156 -541
- package/src/device/plug.ts +92 -480
- package/src/device/robotvacuumcleaner.ts +161 -477
- package/src/device/waterdetector.ts +139 -689
- package/src/index.ts +1 -1
- package/src/irdevice/airconditioner.ts +330 -446
- package/src/irdevice/airpurifier.ts +89 -321
- package/src/irdevice/camera.ts +42 -293
- package/src/irdevice/fan.ts +78 -327
- package/src/irdevice/irdevice.ts +526 -0
- package/src/irdevice/light.ts +32 -287
- package/src/irdevice/other.ts +396 -615
- package/src/irdevice/tv.ts +100 -339
- package/src/irdevice/vacuumcleaner.ts +49 -305
- package/src/irdevice/waterheater.ts +50 -310
- package/src/platform.ts +247 -102
- package/src/settings.ts +56 -565
- package/src/utils.ts +642 -1
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
import { hostname } from 'os';
|
|
2
|
+
import asyncmqtt from 'async-mqtt';
|
|
3
|
+
import { BlindTiltMappingMode, SwitchBotModel, SwitchBotBLEModel, sleep } from '../utils.js';
|
|
4
|
+
export class deviceBase {
|
|
5
|
+
platform;
|
|
6
|
+
accessory;
|
|
7
|
+
device;
|
|
8
|
+
api;
|
|
9
|
+
log;
|
|
10
|
+
config;
|
|
11
|
+
hap;
|
|
12
|
+
// Config
|
|
13
|
+
deviceLogging;
|
|
14
|
+
deviceUpdateRate;
|
|
15
|
+
deviceRefreshRate;
|
|
16
|
+
deviceMaxRetries;
|
|
17
|
+
deviceDelayBetweenRetries;
|
|
18
|
+
// Connection
|
|
19
|
+
BLE;
|
|
20
|
+
OpenAPI;
|
|
21
|
+
// Accsrroy Information
|
|
22
|
+
deviceModel;
|
|
23
|
+
deviceBLEModel;
|
|
24
|
+
// BLE
|
|
25
|
+
scanDuration;
|
|
26
|
+
// EVE history service handler
|
|
27
|
+
historyService = null;
|
|
28
|
+
//MQTT stuff
|
|
29
|
+
mqttClient = null;
|
|
30
|
+
constructor(platform, accessory, device) {
|
|
31
|
+
this.platform = platform;
|
|
32
|
+
this.accessory = accessory;
|
|
33
|
+
this.device = device;
|
|
34
|
+
this.api = this.platform.api;
|
|
35
|
+
this.log = this.platform.log;
|
|
36
|
+
this.config = this.platform.config;
|
|
37
|
+
this.hap = this.api.hap;
|
|
38
|
+
// Connection
|
|
39
|
+
this.BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
|
|
40
|
+
this.OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
41
|
+
this.getDeviceLogSettings(device);
|
|
42
|
+
this.getDeviceRefreshRateSettings(device);
|
|
43
|
+
this.getDeviceRetry(device);
|
|
44
|
+
this.getDeviceConfigSettings(device);
|
|
45
|
+
this.getDeviceContext(accessory, device);
|
|
46
|
+
this.setupMqtt(device);
|
|
47
|
+
this.scan(device);
|
|
48
|
+
// Set accessory information
|
|
49
|
+
accessory
|
|
50
|
+
.getService(this.hap.Service.AccessoryInformation)
|
|
51
|
+
.setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
|
|
52
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
53
|
+
.setCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.context.name)
|
|
54
|
+
.setCharacteristic(this.hap.Characteristic.Model, accessory.context.model)
|
|
55
|
+
.setCharacteristic(this.hap.Characteristic.SerialNumber, accessory.context.deviceId)
|
|
56
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
57
|
+
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
58
|
+
.updateValue(accessory.context.FirmwareRevision);
|
|
59
|
+
}
|
|
60
|
+
async getDeviceLogSettings(device) {
|
|
61
|
+
if (this.platform.debugMode) {
|
|
62
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
63
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
64
|
+
}
|
|
65
|
+
else if (device.logging) {
|
|
66
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
67
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
68
|
+
}
|
|
69
|
+
else if (this.config.logging) {
|
|
70
|
+
this.deviceLogging = this.accessory.context.logging = this.config.logging;
|
|
71
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
75
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async getDeviceRefreshRateSettings(device) {
|
|
79
|
+
// refreshRate
|
|
80
|
+
if (device.refreshRate) {
|
|
81
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
82
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
83
|
+
}
|
|
84
|
+
else if (this.platform.config.options.refreshRate) {
|
|
85
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
|
|
86
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
87
|
+
}
|
|
88
|
+
// updateRate
|
|
89
|
+
if (device.updateRate) {
|
|
90
|
+
this.deviceUpdateRate = device.updateRate;
|
|
91
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config updateRate: ${this.deviceUpdateRate}`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.deviceUpdateRate = 5;
|
|
95
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default updateRate: ${this.deviceUpdateRate}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async getDeviceRetry(device) {
|
|
99
|
+
if (device.maxRetries) {
|
|
100
|
+
this.deviceMaxRetries = device.maxRetries;
|
|
101
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Max Retries: ${this.deviceMaxRetries}`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.deviceMaxRetries = 5; // Maximum number of retries
|
|
105
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Max Retries Not Set, Using: ${this.deviceMaxRetries}`);
|
|
106
|
+
}
|
|
107
|
+
if (device.delayBetweenRetries) {
|
|
108
|
+
this.deviceDelayBetweenRetries = device.delayBetweenRetries * 1000;
|
|
109
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Delay Between Retries: ${this.deviceDelayBetweenRetries}`);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.deviceDelayBetweenRetries = 3000; // Delay between retries in milliseconds
|
|
113
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Delay Between Retries Not Set,`
|
|
114
|
+
+ ` Using: ${this.deviceDelayBetweenRetries}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async retryBLE({ max, fn }) {
|
|
118
|
+
return fn().catch(async (e) => {
|
|
119
|
+
if (max === 0) {
|
|
120
|
+
throw e;
|
|
121
|
+
}
|
|
122
|
+
this.infoLog(e);
|
|
123
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Retrying`);
|
|
124
|
+
await sleep(1000);
|
|
125
|
+
return this.retryBLE({ max: max - 1, fn });
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async maxRetryBLE() {
|
|
129
|
+
if (this.device.maxRetry) {
|
|
130
|
+
return this.device.maxRetry;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return 5;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async scan(device) {
|
|
137
|
+
if (device.scanDuration) {
|
|
138
|
+
if (this.deviceUpdateRate > device.scanDuration) {
|
|
139
|
+
this.scanDuration = this.deviceUpdateRate;
|
|
140
|
+
if (this.BLE) {
|
|
141
|
+
this.warnLog(`${this.device.deviceType}: ` +
|
|
142
|
+
`${this.accessory.displayName} scanDuration is less than updateRate, overriding scanDuration with updateRate`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
147
|
+
}
|
|
148
|
+
if (this.BLE) {
|
|
149
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
if (this.deviceUpdateRate > 1) {
|
|
154
|
+
this.scanDuration = this.deviceUpdateRate;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
158
|
+
}
|
|
159
|
+
if (this.BLE) {
|
|
160
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async getDeviceConfigSettings(device) {
|
|
165
|
+
let config = {};
|
|
166
|
+
if (device.logging !== undefined) {
|
|
167
|
+
config['logging'] = device.logging;
|
|
168
|
+
}
|
|
169
|
+
if (device.refreshRate !== undefined) {
|
|
170
|
+
config['refreshRate'] = device.refreshRate;
|
|
171
|
+
}
|
|
172
|
+
if (device.updateRate !== undefined) {
|
|
173
|
+
config['updateRate'] = device.updateRate;
|
|
174
|
+
}
|
|
175
|
+
if (device.scanDuration !== undefined) {
|
|
176
|
+
config['scanDuration'] = device.scanDuration;
|
|
177
|
+
}
|
|
178
|
+
if (device.offline !== undefined) {
|
|
179
|
+
config['offline'] = device.offline;
|
|
180
|
+
}
|
|
181
|
+
if (device.maxRetry !== 0) {
|
|
182
|
+
config['maxRetry'] = device.maxRetry;
|
|
183
|
+
}
|
|
184
|
+
if (device.webhook === true) {
|
|
185
|
+
config['webhook'] = device.webhook;
|
|
186
|
+
}
|
|
187
|
+
if (device.connectionType) {
|
|
188
|
+
config['connectionType'] = device.connectionType;
|
|
189
|
+
}
|
|
190
|
+
if (device.external !== undefined) {
|
|
191
|
+
config['external'] = device.external;
|
|
192
|
+
}
|
|
193
|
+
if (device.mqttURL !== undefined) {
|
|
194
|
+
config['mqttURL'] = device.mqttURL;
|
|
195
|
+
}
|
|
196
|
+
if (device.maxRetries !== undefined) {
|
|
197
|
+
config['maxRetries'] = device.maxRetries;
|
|
198
|
+
}
|
|
199
|
+
if (device.delayBetweenRetries !== undefined) {
|
|
200
|
+
config['delayBetweenRetries'] = device.delayBetweenRetries;
|
|
201
|
+
}
|
|
202
|
+
if (device.bot) {
|
|
203
|
+
config = device.bot;
|
|
204
|
+
}
|
|
205
|
+
if (device.lock) {
|
|
206
|
+
config = device.lock;
|
|
207
|
+
}
|
|
208
|
+
if (device.ceilinglight) {
|
|
209
|
+
config = device.ceilinglight;
|
|
210
|
+
}
|
|
211
|
+
if (device.colorbulb) {
|
|
212
|
+
config = device.colorbulb;
|
|
213
|
+
}
|
|
214
|
+
if (device.contact) {
|
|
215
|
+
config = device.contact;
|
|
216
|
+
}
|
|
217
|
+
if (device.motion) {
|
|
218
|
+
config = device.motion;
|
|
219
|
+
}
|
|
220
|
+
if (device.curtain) {
|
|
221
|
+
config = device.curtain;
|
|
222
|
+
}
|
|
223
|
+
if (device.hub) {
|
|
224
|
+
config = device.hub;
|
|
225
|
+
}
|
|
226
|
+
if (device.waterdetector) {
|
|
227
|
+
config = device.waterdetector;
|
|
228
|
+
}
|
|
229
|
+
if (device.humidifier) {
|
|
230
|
+
config = device.humidifier;
|
|
231
|
+
}
|
|
232
|
+
if (device.meter) {
|
|
233
|
+
config = device.meter;
|
|
234
|
+
}
|
|
235
|
+
if (device.striplight) {
|
|
236
|
+
config = device.striplight;
|
|
237
|
+
}
|
|
238
|
+
if (device.plug) {
|
|
239
|
+
config = device.plug;
|
|
240
|
+
}
|
|
241
|
+
if (device.blindTilt) {
|
|
242
|
+
if (device.blindTilt?.mode === undefined) {
|
|
243
|
+
config['mode'] = BlindTiltMappingMode.OnlyUp;
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
config['mode'] = device.blindTilt?.mode;
|
|
247
|
+
config = device.blindTilt;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (Object.entries(config).length !== 0) {
|
|
251
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/*
|
|
255
|
+
* Publish MQTT message for topics of
|
|
256
|
+
* 'homebridge-switchbot/${this.device.deviceType}/xx:xx:xx:xx:xx:xx'
|
|
257
|
+
*/
|
|
258
|
+
mqttPublish(message, topic) {
|
|
259
|
+
const mac = this.device.deviceId
|
|
260
|
+
?.toLowerCase()
|
|
261
|
+
.match(/[\s\S]{1,2}/g)
|
|
262
|
+
?.join(':');
|
|
263
|
+
const options = this.device.mqttPubOptions || {};
|
|
264
|
+
let mqttTopic;
|
|
265
|
+
let mqttMessageTopic;
|
|
266
|
+
if (topic) {
|
|
267
|
+
mqttTopic = `/${topic}`;
|
|
268
|
+
mqttMessageTopic = `${topic}/`;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
mqttTopic = '';
|
|
272
|
+
mqttMessageTopic = '';
|
|
273
|
+
}
|
|
274
|
+
this.mqttClient?.publish(`homebridge-switchbot/${this.device.deviceType}/${mac}${mqttTopic}`, `${message}`, options);
|
|
275
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
276
|
+
+ ` MQTT message: ${mqttMessageTopic}${message} options:${JSON.stringify(options)}`);
|
|
277
|
+
}
|
|
278
|
+
/*
|
|
279
|
+
* Setup MQTT hadler if URL is specified.
|
|
280
|
+
*/
|
|
281
|
+
async setupMqtt(device) {
|
|
282
|
+
if (device.mqttURL) {
|
|
283
|
+
try {
|
|
284
|
+
const { connectAsync } = asyncmqtt;
|
|
285
|
+
this.mqttClient = await connectAsync(device.mqttURL, device.mqttOptions || {});
|
|
286
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MQTT connection has been established successfully.`);
|
|
287
|
+
this.mqttClient.on('error', (e) => {
|
|
288
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Failed to publish MQTT messages. ${e}`);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
catch (e) {
|
|
292
|
+
this.mqttClient = null;
|
|
293
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Failed to establish MQTT connection. ${e}`);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/*
|
|
298
|
+
* Setup EVE history graph feature if enabled.
|
|
299
|
+
*/
|
|
300
|
+
async setupHistoryService(device) {
|
|
301
|
+
const mac = this.device
|
|
302
|
+
.deviceId.match(/.{1,2}/g)
|
|
303
|
+
.join(':')
|
|
304
|
+
.toLowerCase();
|
|
305
|
+
this.historyService = device.history
|
|
306
|
+
? new this.platform.fakegatoAPI('room', this.accessory, {
|
|
307
|
+
log: this.platform.log,
|
|
308
|
+
storage: 'fs',
|
|
309
|
+
filename: `${hostname().split('.')[0]}_${mac}_persist.json`,
|
|
310
|
+
})
|
|
311
|
+
: null;
|
|
312
|
+
}
|
|
313
|
+
async getCustomBLEAddress(switchbot) {
|
|
314
|
+
if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
|
|
315
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} customBLEaddress: ${this.device.customBLEaddress}`);
|
|
316
|
+
(async () => {
|
|
317
|
+
// Start to monitor advertisement packets
|
|
318
|
+
await switchbot.startScan({ model: this.device.bleModel });
|
|
319
|
+
// Set an event handler
|
|
320
|
+
switchbot.onadvertisement = (ad) => {
|
|
321
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${JSON.stringify(ad, null, ' ')}`);
|
|
322
|
+
};
|
|
323
|
+
await sleep(10000);
|
|
324
|
+
// Stop to monitor
|
|
325
|
+
switchbot.stopScan();
|
|
326
|
+
})();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
async getDeviceContext(accessory, device) {
|
|
330
|
+
// Set the accessory context
|
|
331
|
+
switch (device.deviceType) {
|
|
332
|
+
case 'Humidifier':
|
|
333
|
+
device.model = SwitchBotModel.Humidifier;
|
|
334
|
+
device.bleModel = SwitchBotBLEModel.Humidifier;
|
|
335
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
336
|
+
break;
|
|
337
|
+
case 'Hub Mini':
|
|
338
|
+
device.model = SwitchBotModel.HubMini;
|
|
339
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
340
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
341
|
+
break;
|
|
342
|
+
case 'Hub Plus':
|
|
343
|
+
device.model = SwitchBotModel.HubPlus;
|
|
344
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
345
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
346
|
+
break;
|
|
347
|
+
case 'Hub 2':
|
|
348
|
+
device.model = SwitchBotModel.Hub2;
|
|
349
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
350
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
351
|
+
break;
|
|
352
|
+
case 'Bot':
|
|
353
|
+
device.model = SwitchBotModel.Bot;
|
|
354
|
+
device.bleModel = SwitchBotBLEModel.Bot;
|
|
355
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
356
|
+
break;
|
|
357
|
+
case 'Meter':
|
|
358
|
+
device.model = SwitchBotModel.Meter;
|
|
359
|
+
device.bleModel = SwitchBotBLEModel.Meter;
|
|
360
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
361
|
+
break;
|
|
362
|
+
case 'MeterPlus':
|
|
363
|
+
device.model = SwitchBotModel.MeterPlusUS;
|
|
364
|
+
device.bleModel = SwitchBotBLEModel.MeterPlus;
|
|
365
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
366
|
+
break;
|
|
367
|
+
case 'Meter Plus (JP)':
|
|
368
|
+
device.model = SwitchBotModel.MeterPlusJP;
|
|
369
|
+
device.bleModel = SwitchBotBLEModel.MeterPlus;
|
|
370
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
371
|
+
break;
|
|
372
|
+
case 'WoIOSensor':
|
|
373
|
+
device.model = SwitchBotModel.OutdoorMeter;
|
|
374
|
+
device.bleModel = SwitchBotBLEModel.OutdoorMeter;
|
|
375
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
376
|
+
break;
|
|
377
|
+
case 'Water Detector':
|
|
378
|
+
device.model = SwitchBotModel.WaterDetector;
|
|
379
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
380
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
381
|
+
break;
|
|
382
|
+
case 'Motion Sensor':
|
|
383
|
+
device.model = SwitchBotModel.MotionSensor;
|
|
384
|
+
device.bleModel = SwitchBotBLEModel.MotionSensor;
|
|
385
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
386
|
+
break;
|
|
387
|
+
case 'Contact Sensor':
|
|
388
|
+
device.model = SwitchBotModel.ContactSensor;
|
|
389
|
+
device.bleModel = SwitchBotBLEModel.ContactSensor;
|
|
390
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
391
|
+
break;
|
|
392
|
+
case 'Curtain':
|
|
393
|
+
device.model = SwitchBotModel.Curtain;
|
|
394
|
+
device.bleModel = SwitchBotBLEModel.Curtain;
|
|
395
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
396
|
+
break;
|
|
397
|
+
case 'Curtain3':
|
|
398
|
+
device.model = SwitchBotModel.Curtain3;
|
|
399
|
+
device.bleModel = SwitchBotBLEModel.Curtain3;
|
|
400
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
401
|
+
break;
|
|
402
|
+
case 'Blind Tilt':
|
|
403
|
+
device.model = SwitchBotModel.BlindTilt;
|
|
404
|
+
device.bleModel = SwitchBotBLEModel.BlindTilt;
|
|
405
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
406
|
+
break;
|
|
407
|
+
case 'Plug':
|
|
408
|
+
device.model = SwitchBotModel.Plug;
|
|
409
|
+
device.bleModel = SwitchBotBLEModel.PlugMiniUS;
|
|
410
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
411
|
+
break;
|
|
412
|
+
case 'Plug Mini (US)':
|
|
413
|
+
device.model = SwitchBotModel.PlugMiniUS;
|
|
414
|
+
device.bleModel = SwitchBotBLEModel.PlugMiniUS;
|
|
415
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
416
|
+
break;
|
|
417
|
+
case 'Plug Mini (JP)':
|
|
418
|
+
device.model = SwitchBotModel.PlugMiniJP;
|
|
419
|
+
device.bleModel = SwitchBotBLEModel.PlugMiniJP;
|
|
420
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
421
|
+
break;
|
|
422
|
+
case 'Smart Lock':
|
|
423
|
+
device.model = SwitchBotModel.Lock;
|
|
424
|
+
device.bleModel = SwitchBotBLEModel.Lock;
|
|
425
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
426
|
+
break;
|
|
427
|
+
case 'Smart Lock Pro':
|
|
428
|
+
device.model = SwitchBotModel.LockPro;
|
|
429
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
430
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
431
|
+
break;
|
|
432
|
+
case 'Color Bulb':
|
|
433
|
+
device.model = SwitchBotModel.ColorBulb;
|
|
434
|
+
device.bleModel = SwitchBotBLEModel.ColorBulb;
|
|
435
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
436
|
+
break;
|
|
437
|
+
case 'K10+':
|
|
438
|
+
device.model = SwitchBotModel.K10;
|
|
439
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
440
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
441
|
+
break;
|
|
442
|
+
case 'WoSweeper':
|
|
443
|
+
device.model = SwitchBotModel.WoSweeper;
|
|
444
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
445
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
446
|
+
break;
|
|
447
|
+
case 'WoSweeperMini':
|
|
448
|
+
device.model = SwitchBotModel.WoSweeperMini;
|
|
449
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
450
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
451
|
+
break;
|
|
452
|
+
case 'Robot Vacuum Cleaner S1':
|
|
453
|
+
device.model = SwitchBotModel.RobotVacuumCleanerS1;
|
|
454
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
455
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
456
|
+
break;
|
|
457
|
+
case 'Robot Vacuum Cleaner S1 Plus':
|
|
458
|
+
device.model = SwitchBotModel.RobotVacuumCleanerS1Plus;
|
|
459
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
460
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
461
|
+
break;
|
|
462
|
+
case 'Robot Vacuum Cleaner S10':
|
|
463
|
+
device.model = SwitchBotModel.RobotVacuumCleanerS10;
|
|
464
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
465
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
466
|
+
break;
|
|
467
|
+
case 'Ceiling Light':
|
|
468
|
+
device.model = SwitchBotModel.CeilingLight;
|
|
469
|
+
device.bleModel = SwitchBotBLEModel.CeilingLight;
|
|
470
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
471
|
+
break;
|
|
472
|
+
case 'Ceiling Light Pro':
|
|
473
|
+
device.model = SwitchBotModel.CeilingLightPro;
|
|
474
|
+
device.bleModel = SwitchBotBLEModel.CeilingLightPro;
|
|
475
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
476
|
+
break;
|
|
477
|
+
case 'Strip Light':
|
|
478
|
+
device.model = SwitchBotModel.StripLight;
|
|
479
|
+
device.bleModel = SwitchBotBLEModel.StripLight;
|
|
480
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
481
|
+
break;
|
|
482
|
+
case 'Indoor Cam':
|
|
483
|
+
device.model = SwitchBotModel.IndoorCam;
|
|
484
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
485
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
486
|
+
break;
|
|
487
|
+
case 'Remote':
|
|
488
|
+
device.model = SwitchBotModel.Remote;
|
|
489
|
+
device.bleModel = SwitchBotBLEModel.Remote;
|
|
490
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
491
|
+
break;
|
|
492
|
+
case 'remote with screen+':
|
|
493
|
+
device.model = SwitchBotModel.UniversalRemote;
|
|
494
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
495
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
496
|
+
break;
|
|
497
|
+
case 'Battery Circulator Fan':
|
|
498
|
+
device.model = SwitchBotModel.BatteryCirculatorFan;
|
|
499
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
500
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
501
|
+
break;
|
|
502
|
+
default:
|
|
503
|
+
device.model = SwitchBotModel.Unknown;
|
|
504
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
505
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
506
|
+
}
|
|
507
|
+
accessory.context.name = device.deviceName;
|
|
508
|
+
accessory.context.model = device.model;
|
|
509
|
+
accessory.context.deviceId = device.deviceId;
|
|
510
|
+
accessory.context.deviceType = device.deviceType;
|
|
511
|
+
if (device.firmware === undefined) {
|
|
512
|
+
device.firmware = this.platform.version;
|
|
513
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
async statusCode(statusCode) {
|
|
520
|
+
switch (statusCode) {
|
|
521
|
+
case 151:
|
|
522
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this deviceType, statusCode: ${statusCode}`);
|
|
523
|
+
break;
|
|
524
|
+
case 152:
|
|
525
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found, statusCode: ${statusCode}`);
|
|
526
|
+
break;
|
|
527
|
+
case 160:
|
|
528
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported, statusCode: ${statusCode}`);
|
|
529
|
+
break;
|
|
530
|
+
case 161:
|
|
531
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
532
|
+
break;
|
|
533
|
+
case 171:
|
|
534
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
535
|
+
`Hub: ${this.device.hubDeviceId}`);
|
|
536
|
+
break;
|
|
537
|
+
case 190:
|
|
538
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with` +
|
|
539
|
+
` server, Or command format is invalid, statusCode: ${statusCode}`);
|
|
540
|
+
break;
|
|
541
|
+
case 100:
|
|
542
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent, statusCode: ${statusCode}`);
|
|
543
|
+
break;
|
|
544
|
+
case 200:
|
|
545
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
546
|
+
break;
|
|
547
|
+
case 400:
|
|
548
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Bad Request, The client has issued an invalid request. `
|
|
549
|
+
+ `This is commonly used to specify validation errors in a request payload, statusCode: ${statusCode}`);
|
|
550
|
+
break;
|
|
551
|
+
case 401:
|
|
552
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Unauthorized, Authorization for the API is required, `
|
|
553
|
+
+ `but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
554
|
+
break;
|
|
555
|
+
case 403:
|
|
556
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Forbidden, The request has been authenticated but does not `
|
|
557
|
+
+ `have appropriate permissions, or a requested resource is not found, statusCode: ${statusCode}`);
|
|
558
|
+
break;
|
|
559
|
+
case 404:
|
|
560
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Not Found, Specifies the requested path does not exist, `
|
|
561
|
+
+ `statusCode: ${statusCode}`);
|
|
562
|
+
break;
|
|
563
|
+
case 406:
|
|
564
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Not Acceptable, The client has requested a MIME type via `
|
|
565
|
+
+ `the Accept header for a value not supported by the server, statusCode: ${statusCode}`);
|
|
566
|
+
break;
|
|
567
|
+
case 415:
|
|
568
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Unsupported Media Type, The client has defined a contentType `
|
|
569
|
+
+ `header that is not supported by the server, statusCode: ${statusCode}`);
|
|
570
|
+
break;
|
|
571
|
+
case 422:
|
|
572
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Unprocessable Entity, The client has made a valid request, `
|
|
573
|
+
+ `but the server cannot process it. This is often used for APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
574
|
+
break;
|
|
575
|
+
case 429:
|
|
576
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Too Many Requests, The client has exceeded the number of `
|
|
577
|
+
+ `requests allowed for a given time window, statusCode: ${statusCode}`);
|
|
578
|
+
break;
|
|
579
|
+
case 500:
|
|
580
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Internal Server Error, An unexpected error on the SmartThings `
|
|
581
|
+
+ `servers has occurred. These errors should be rare, statusCode: ${statusCode}`);
|
|
582
|
+
break;
|
|
583
|
+
default:
|
|
584
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: `
|
|
585
|
+
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Logging for Device
|
|
590
|
+
*/
|
|
591
|
+
infoLog(...log) {
|
|
592
|
+
if (this.enablingDeviceLogging()) {
|
|
593
|
+
this.log.info(String(...log));
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
successLog(...log) {
|
|
597
|
+
if (this.enablingDeviceLogging()) {
|
|
598
|
+
this.log.success(String(...log));
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
debugSuccessLog(...log) {
|
|
602
|
+
if (this.enablingDeviceLogging()) {
|
|
603
|
+
if (this.deviceLogging?.includes('debug')) {
|
|
604
|
+
this.log.success('[DEBUG]', String(...log));
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
warnLog(...log) {
|
|
609
|
+
if (this.enablingDeviceLogging()) {
|
|
610
|
+
this.log.warn(String(...log));
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
debugWarnLog(...log) {
|
|
614
|
+
if (this.enablingDeviceLogging()) {
|
|
615
|
+
if (this.deviceLogging?.includes('debug')) {
|
|
616
|
+
this.log.warn('[DEBUG]', String(...log));
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
errorLog(...log) {
|
|
621
|
+
if (this.enablingDeviceLogging()) {
|
|
622
|
+
this.log.error(String(...log));
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
debugErrorLog(...log) {
|
|
626
|
+
if (this.enablingDeviceLogging()) {
|
|
627
|
+
if (this.deviceLogging?.includes('debug')) {
|
|
628
|
+
this.log.error('[DEBUG]', String(...log));
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
debugLog(...log) {
|
|
633
|
+
if (this.enablingDeviceLogging()) {
|
|
634
|
+
if (this.deviceLogging === 'debug') {
|
|
635
|
+
this.log.info('[DEBUG]', String(...log));
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
this.log.debug(String(...log));
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
enablingDeviceLogging() {
|
|
643
|
+
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
//# sourceMappingURL=device.js.map
|