@switchbot/homebridge-switchbot 3.5.0-beta.7 → 3.5.0-beta.70

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