@switchbot/homebridge-switchbot 2.0.0-beta.2 → 2.0.0-beta.20

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 (113) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/README.md +1 -2
  3. package/config.schema.json +75 -20
  4. package/dist/device/bot.d.ts +32 -28
  5. package/dist/device/bot.d.ts.map +1 -1
  6. package/dist/device/bot.js +646 -648
  7. package/dist/device/bot.js.map +1 -1
  8. package/dist/device/colorbulb.d.ts +34 -19
  9. package/dist/device/colorbulb.d.ts.map +1 -1
  10. package/dist/device/colorbulb.js +429 -304
  11. package/dist/device/colorbulb.js.map +1 -1
  12. package/dist/device/contact.d.ts +16 -7
  13. package/dist/device/contact.d.ts.map +1 -1
  14. package/dist/device/contact.js +288 -230
  15. package/dist/device/contact.js.map +1 -1
  16. package/dist/device/curtain.d.ts +21 -16
  17. package/dist/device/curtain.d.ts.map +1 -1
  18. package/dist/device/curtain.js +519 -489
  19. package/dist/device/curtain.js.map +1 -1
  20. package/dist/device/humidifier.d.ts +22 -18
  21. package/dist/device/humidifier.d.ts.map +1 -1
  22. package/dist/device/humidifier.js +415 -360
  23. package/dist/device/humidifier.js.map +1 -1
  24. package/dist/device/lock.d.ts +22 -8
  25. package/dist/device/lock.d.ts.map +1 -1
  26. package/dist/device/lock.js +253 -147
  27. package/dist/device/lock.js.map +1 -1
  28. package/dist/device/meter.d.ts +21 -16
  29. package/dist/device/meter.d.ts.map +1 -1
  30. package/dist/device/meter.js +325 -255
  31. package/dist/device/meter.js.map +1 -1
  32. package/dist/device/meterplus.d.ts +23 -12
  33. package/dist/device/meterplus.d.ts.map +1 -1
  34. package/dist/device/meterplus.js +346 -208
  35. package/dist/device/meterplus.js.map +1 -1
  36. package/dist/device/motion.d.ts +17 -8
  37. package/dist/device/motion.d.ts.map +1 -1
  38. package/dist/device/motion.js +261 -209
  39. package/dist/device/motion.js.map +1 -1
  40. package/dist/device/plug.d.ts +24 -16
  41. package/dist/device/plug.d.ts.map +1 -1
  42. package/dist/device/plug.js +267 -242
  43. package/dist/device/plug.js.map +1 -1
  44. package/dist/device/striplight.d.ts +51 -16
  45. package/dist/device/striplight.d.ts.map +1 -1
  46. package/dist/device/striplight.js +527 -185
  47. package/dist/device/striplight.js.map +1 -1
  48. package/dist/irdevice/airconditioner.d.ts +7 -12
  49. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  50. package/dist/irdevice/airconditioner.js +261 -230
  51. package/dist/irdevice/airconditioner.js.map +1 -1
  52. package/dist/irdevice/airpurifier.d.ts +3 -3
  53. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  54. package/dist/irdevice/airpurifier.js +137 -104
  55. package/dist/irdevice/airpurifier.js.map +1 -1
  56. package/dist/irdevice/camera.d.ts +9 -8
  57. package/dist/irdevice/camera.d.ts.map +1 -1
  58. package/dist/irdevice/camera.js +116 -86
  59. package/dist/irdevice/camera.js.map +1 -1
  60. package/dist/irdevice/fan.d.ts +8 -7
  61. package/dist/irdevice/fan.d.ts.map +1 -1
  62. package/dist/irdevice/fan.js +143 -109
  63. package/dist/irdevice/fan.js.map +1 -1
  64. package/dist/irdevice/light.d.ts +9 -8
  65. package/dist/irdevice/light.d.ts.map +1 -1
  66. package/dist/irdevice/light.js +120 -103
  67. package/dist/irdevice/light.js.map +1 -1
  68. package/dist/irdevice/other.d.ts +9 -8
  69. package/dist/irdevice/other.d.ts.map +1 -1
  70. package/dist/irdevice/other.js +128 -98
  71. package/dist/irdevice/other.js.map +1 -1
  72. package/dist/irdevice/tv.d.ts +10 -9
  73. package/dist/irdevice/tv.d.ts.map +1 -1
  74. package/dist/irdevice/tv.js +126 -93
  75. package/dist/irdevice/tv.js.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.d.ts +7 -10
  77. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  78. package/dist/irdevice/vacuumcleaner.js +115 -89
  79. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  80. package/dist/irdevice/waterheater.d.ts +6 -9
  81. package/dist/irdevice/waterheater.d.ts.map +1 -1
  82. package/dist/irdevice/waterheater.js +115 -89
  83. package/dist/irdevice/waterheater.js.map +1 -1
  84. package/dist/platform.d.ts +3 -5
  85. package/dist/platform.d.ts.map +1 -1
  86. package/dist/platform.js +203 -200
  87. package/dist/platform.js.map +1 -1
  88. package/dist/settings.d.ts +15 -11
  89. package/dist/settings.d.ts.map +1 -1
  90. package/dist/settings.js.map +1 -1
  91. package/package.json +12 -10
  92. package/src/device/bot.ts +641 -657
  93. package/src/device/colorbulb.ts +440 -339
  94. package/src/device/contact.ts +289 -233
  95. package/src/device/curtain.ts +523 -503
  96. package/src/device/humidifier.ts +421 -396
  97. package/src/device/lock.ts +257 -147
  98. package/src/device/meter.ts +335 -268
  99. package/src/device/meterplus.ts +354 -213
  100. package/src/device/motion.ts +264 -213
  101. package/src/device/plug.ts +270 -251
  102. package/src/device/striplight.ts +552 -207
  103. package/src/irdevice/airconditioner.ts +263 -241
  104. package/src/irdevice/airpurifier.ts +132 -103
  105. package/src/irdevice/camera.ts +112 -85
  106. package/src/irdevice/fan.ts +138 -106
  107. package/src/irdevice/light.ts +116 -103
  108. package/src/irdevice/other.ts +124 -97
  109. package/src/irdevice/tv.ts +123 -93
  110. package/src/irdevice/vacuumcleaner.ts +112 -89
  111. package/src/irdevice/waterheater.ts +111 -89
  112. package/src/platform.ts +195 -216
  113. package/src/settings.ts +15 -11
@@ -8,6 +8,7 @@ const https_1 = __importDefault(require("https"));
8
8
  const crypto_1 = __importDefault(require("crypto"));
9
9
  const rxjs_1 = require("rxjs");
10
10
  const operators_1 = require("rxjs/operators");
11
+ const super_stringify_1 = __importDefault(require("super-stringify"));
11
12
  const settings_1 = require("../settings");
12
13
  /**
13
14
  * Platform Accessory
@@ -19,12 +20,15 @@ class Contact {
19
20
  this.platform = platform;
20
21
  this.accessory = accessory;
21
22
  this.device = device;
23
+ // Connection
24
+ this.BLE = (this.device.connectionType === 'BLE' || this.device.connectionType === 'Both');
25
+ this.OpenAPI = (this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'Both');
22
26
  // default placeholders
23
27
  this.logs(device);
24
28
  this.scan(device);
25
29
  this.refreshRate(device);
26
30
  this.config(device);
27
- this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
31
+ this.context();
28
32
  // this is subject we use to track when we need to POST changes to the SwitchBot API
29
33
  this.doContactUpdate = new rxjs_1.Subject();
30
34
  this.contactUbpdateInProgress = false;
@@ -54,50 +58,50 @@ class Contact {
54
58
  // see https://developers.homebridge.io/#/service/ContactSensor
55
59
  // Motion Sensor Service
56
60
  if (device.contact?.hide_motionsensor) {
57
- this.debugLog(`Contact Sensor: ${accessory.displayName} Removing Motion Sensor Service`);
61
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Motion Sensor Service`);
58
62
  this.motionService = this.accessory.getService(this.platform.Service.MotionSensor);
59
63
  accessory.removeService(this.motionService);
60
64
  }
61
65
  else if (!this.motionService) {
62
- this.debugLog(`Contact Sensor: ${accessory.displayName} Add Motion Sensor Service`);
66
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Motion Sensor Service`);
63
67
  (this.motionService =
64
68
  this.accessory.getService(this.platform.Service.MotionSensor) || this.accessory.addService(this.platform.Service.MotionSensor)),
65
69
  `${accessory.displayName} Motion Sensor`;
66
70
  this.motionService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Motion Sensor`);
67
71
  }
68
72
  else {
69
- this.debugLog(`Contact Sensor: ${accessory.displayName} Motion Sensor Service Not Added`);
73
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Motion Sensor Service Not Added`);
70
74
  }
71
75
  // Light Sensor Service
72
76
  if (device.contact?.hide_lightsensor) {
73
- this.debugLog(`Contact Sensor: ${accessory.displayName} Removing Light Sensor Service`);
77
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Light Sensor Service`);
74
78
  this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor);
75
79
  accessory.removeService(this.lightSensorService);
76
80
  }
77
81
  else if (!this.lightSensorService) {
78
- this.debugLog(`Contact Sensor: ${accessory.displayName} Add Light Sensor Service`);
82
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Light Sensor Service`);
79
83
  (this.lightSensorService =
80
84
  this.accessory.getService(this.platform.Service.LightSensor) || this.accessory.addService(this.platform.Service.LightSensor)),
81
85
  `${accessory.displayName} Light Sensor`;
82
86
  this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
83
87
  }
84
88
  else {
85
- this.debugLog(`Contact Sensor: ${accessory.displayName} Light Sensor Service Not Added`);
89
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Light Sensor Service Not Added`);
86
90
  }
87
91
  // Battery Service
88
- if (!device.ble) {
89
- this.debugLog(`Contact Sensor: ${accessory.displayName} Removing Battery Service`);
92
+ if (!this.BLE) {
93
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
90
94
  this.batteryService = this.accessory.getService(this.platform.Service.Battery);
91
95
  accessory.removeService(this.batteryService);
92
96
  }
93
- else if (device.ble && !this.batteryService) {
94
- this.debugLog(`Contact Sensor: ${accessory.displayName} Add Battery Service`);
97
+ else if (this.BLE && !this.batteryService) {
98
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
95
99
  (this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
96
100
  `${accessory.displayName} Battery`;
97
101
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
98
102
  }
99
103
  else {
100
- this.debugLog(`Contact Sensor: ${accessory.displayName} Battery Service Not Added`);
104
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
101
105
  }
102
106
  // Retrieve initial values and updateHomekit
103
107
  this.updateHomeKitCharacteristics();
@@ -112,15 +116,20 @@ class Contact {
112
116
  * Parse the device status from the SwitchBot api
113
117
  */
114
118
  async parseStatus() {
115
- if (this.SwitchToOpenAPI || !this.device.ble) {
119
+ if (this.BLE && !this.SwitchToOpenAPI) {
120
+ await this.BLEparseStatus();
121
+ }
122
+ else if (this.OpenAPI && this.platform.config.credentials?.token) {
123
+ this.SwitchToOpenAPI = false;
116
124
  await this.openAPIparseStatus();
117
125
  }
118
126
  else {
119
- await this.BLEparseStatus();
127
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
128
+ + ` ${this.device.connectionType}, parseStatus will not happen.`);
120
129
  }
121
130
  }
122
131
  async BLEparseStatus() {
123
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} BLE parseStatus`);
132
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
124
133
  // Door State
125
134
  switch (this.doorState) {
126
135
  case 'open':
@@ -132,12 +141,12 @@ class Contact {
132
141
  this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
133
142
  break;
134
143
  default:
135
- this.errorLog(`Contact Sensor: ${this.accessory.displayName} timeout no closed, doorstate: ${this.doorState}`);
144
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} timeout no closed, doorstate: ${this.doorState}`);
136
145
  }
137
146
  // Movement
138
147
  if (!this.device.contact?.hide_motionsensor) {
139
148
  this.MotionDetected = Boolean(this.movement);
140
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
149
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
141
150
  }
142
151
  // Light Level
143
152
  if (!this.device.contact?.hide_lightsensor) {
@@ -151,7 +160,7 @@ class Contact {
151
160
  default:
152
161
  this.CurrentAmbientLightLevel = this.set_maxLux;
153
162
  }
154
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} LightLevel: ${this.lightLevel},` +
163
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel},` +
155
164
  ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
156
165
  }
157
166
  // Battery
@@ -165,60 +174,60 @@ class Contact {
165
174
  else {
166
175
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
167
176
  }
168
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
177
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, `
178
+ + `StatusLowBattery: ${this.StatusLowBattery}`);
169
179
  }
170
180
  async openAPIparseStatus() {
171
- if (this.device.ble) {
172
- this.SwitchToOpenAPI = false;
181
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
182
+ // Contact State
183
+ if (this.openState === 'open') {
184
+ this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
185
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
173
186
  }
174
- if (this.platform.config.credentials?.token) {
175
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} OpenAPI parseStatus`);
176
- // Contact State
177
- if (this.openState === 'open') {
178
- this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
179
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
180
- }
181
- else if (this.openState === 'close') {
182
- this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
183
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
184
- }
185
- else {
186
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} openState: ${this.openState}`);
187
- }
188
- // Motion State
189
- if (!this.device.contact?.hide_motionsensor) {
190
- this.MotionDetected = this.moveDetected;
191
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
192
- }
193
- // Light Level
194
- if (!this.device.contact?.hide_lightsensor) {
195
- this.set_minLux = this.minLux();
196
- this.set_maxLux = this.maxLux();
197
- switch (this.brightness) {
198
- case 'dim':
199
- this.CurrentAmbientLightLevel = this.set_minLux;
200
- break;
201
- case 'bright':
202
- default:
203
- this.CurrentAmbientLightLevel = this.set_maxLux;
204
- }
205
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
187
+ else if (this.openState === 'close') {
188
+ this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
189
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
190
+ }
191
+ else {
192
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openState: ${this.openState}`);
193
+ }
194
+ // Motion State
195
+ if (!this.device.contact?.hide_motionsensor) {
196
+ this.MotionDetected = this.moveDetected;
197
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
198
+ }
199
+ // Light Level
200
+ if (!this.device.contact?.hide_lightsensor) {
201
+ this.set_minLux = this.minLux();
202
+ this.set_maxLux = this.maxLux();
203
+ switch (this.brightness) {
204
+ case 'dim':
205
+ this.CurrentAmbientLightLevel = this.set_minLux;
206
+ break;
207
+ case 'bright':
208
+ default:
209
+ this.CurrentAmbientLightLevel = this.set_maxLux;
206
210
  }
211
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
207
212
  }
208
213
  }
209
214
  /**
210
215
  * Asks the SwitchBot API for the latest device information
211
216
  */
212
217
  async refreshStatus() {
213
- if (this.device.ble) {
218
+ if (this.BLE) {
214
219
  await this.BLERefreshStatus();
215
220
  }
216
- else {
221
+ else if (this.OpenAPI) {
217
222
  await this.openAPIRefreshStatus();
218
223
  }
224
+ else {
225
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
226
+ + ` ${this.device.connectionType}, refreshStatus will not happen.`);
227
+ }
219
228
  }
220
229
  async BLERefreshStatus() {
221
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} BLE refreshStatus`);
230
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLERefreshStatus`);
222
231
  const switchbot = await this.platform.connectBLE();
223
232
  // Convert to BLE Address
224
233
  this.device.bleMac =
@@ -227,7 +236,7 @@ class Contact {
227
236
  .deviceId.match(/.{1,2}/g)
228
237
  .join(':')
229
238
  .toLowerCase();
230
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
239
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
231
240
  this.getCustomBLEAddress(switchbot);
232
241
  // Start to monitor advertisement packets
233
242
  if (switchbot !== false) {
@@ -243,24 +252,24 @@ class Contact {
243
252
  if (this.deviceLogging.includes('debug')) {
244
253
  this.infoLog(this.address);
245
254
  this.infoLog(this.device.bleMac);
246
- this.infoLog(`Contact Sensor: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
247
- this.infoLog(`Contact Sensor: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
255
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
256
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
248
257
  }
249
258
  this.serviceData = ad.serviceData;
250
259
  this.movement = ad.serviceData.movement;
251
260
  this.doorState = ad.serviceData.doorState;
252
261
  this.lightLevel = ad.serviceData.lightLevel;
253
262
  this.battery = ad.serviceData.battery;
254
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
255
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} movement: ${ad.serviceData.movement}, doorState: ` +
263
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${(0, super_stringify_1.default)(ad.serviceData)}`);
264
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} movement: ${ad.serviceData.movement}, doorState: ` +
256
265
  `${ad.serviceData.doorState}, lightLevel: ${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}`);
257
266
  if (this.serviceData) {
258
267
  this.connected = true;
259
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} connected: ${this.connected}`);
268
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
260
269
  }
261
270
  else {
262
271
  this.connected = false;
263
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} connected: ${this.connected}`);
272
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
264
273
  }
265
274
  };
266
275
  // Wait 2 seconds
@@ -278,106 +287,69 @@ class Contact {
278
287
  }
279
288
  })
280
289
  .catch(async (e) => {
281
- this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
282
- if (this.deviceLogging.includes('debug')) {
283
- this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` +
284
- ` Error Message: ${JSON.stringify(e.message)}`);
285
- }
286
- if (this.platform.config.credentials?.token) {
287
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
288
- this.SwitchToOpenAPI = true;
289
- await this.openAPIRefreshStatus();
290
- }
291
290
  this.apiError(e);
291
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}`
292
+ + ` Connection, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
293
+ await this.BLEconnection(switchbot);
292
294
  });
293
295
  }
294
296
  else {
295
297
  await this.BLEconnection(switchbot);
296
298
  }
297
299
  }
298
- async getCustomBLEAddress(switchbot) {
299
- if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
300
- (async () => {
301
- // Start to monitor advertisement packets
302
- await switchbot.startScan({
303
- model: 'd',
304
- });
305
- // Set an event handler
306
- switchbot.onadvertisement = (ad) => {
307
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} ad: ${JSON.stringify(ad, null, ' ')}`);
308
- };
309
- await switchbot.wait(10000);
310
- // Stop to monitor
311
- switchbot.stopScan();
312
- })();
313
- }
314
- }
315
- async BLEconnection(switchbot) {
316
- this.errorLog(`Contact Sensor: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
317
- if (this.platform.config.credentials?.token) {
318
- this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
319
- this.SwitchToOpenAPI = true;
320
- await this.openAPIRefreshStatus();
321
- }
322
- }
323
300
  async openAPIRefreshStatus() {
324
- if (this.platform.config.credentials?.token) {
325
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} OpenAPI refreshStatus`);
326
- try {
327
- const t = Date.now();
328
- const nonce = 'requestID';
329
- const data = this.platform.config.credentials?.token + t + nonce;
330
- const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
331
- const sign = signTerm.toString('base64');
332
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} sign: ${sign}`);
333
- const options = {
334
- hostname: settings_1.HostDomain,
335
- port: 443,
336
- path: `${settings_1.DevicePath}/${this.device.deviceId}/status`,
337
- method: 'GET',
338
- headers: {
339
- Authorization: this.platform.config.credentials?.token,
340
- sign: sign,
341
- nonce: nonce,
342
- t: t,
343
- 'Content-Type': 'application/json',
344
- },
345
- };
346
- const req = https_1.default.request(options, (res) => {
347
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
348
- let rawData = '';
349
- res.on('data', (d) => {
350
- rawData += d;
351
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} d: ${d}`);
352
- });
353
- res.on('end', () => {
354
- try {
355
- this.deviceStatus = JSON.parse(rawData);
356
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
357
- this.openState = this.deviceStatus.body.openState;
358
- this.moveDetected = this.deviceStatus.body.moveDetected;
359
- this.brightness = this.deviceStatus.body.brightness;
360
- this.parseStatus();
361
- this.updateHomeKitCharacteristics();
362
- }
363
- catch (e) {
364
- this.errorLog(`Contact Sensor: ${this.accessory.displayName} error message: ${e.message}`);
365
- }
366
- });
301
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
302
+ try {
303
+ const t = Date.now();
304
+ const nonce = 'requestID';
305
+ const data = this.platform.config.credentials?.token + t + nonce;
306
+ const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
307
+ const sign = signTerm.toString('base64');
308
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
309
+ const options = {
310
+ hostname: settings_1.HostDomain,
311
+ port: 443,
312
+ path: `${settings_1.DevicePath}/${this.device.deviceId}/status`,
313
+ method: 'GET',
314
+ headers: {
315
+ Authorization: this.platform.config.credentials?.token,
316
+ sign: sign,
317
+ nonce: nonce,
318
+ t: t,
319
+ 'Content-Type': 'application/json',
320
+ },
321
+ };
322
+ const req = https_1.default.request(options, (res) => {
323
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus statusCode: ${res.statusCode}`);
324
+ let rawData = '';
325
+ res.on('data', (d) => {
326
+ rawData += d;
327
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
367
328
  });
368
- req.on('error', (e) => {
369
- this.errorLog(`Contact Sensor: ${this.accessory.displayName} error message: ${e.message}`);
329
+ res.on('end', () => {
330
+ try {
331
+ this.deviceStatus = JSON.parse(rawData);
332
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${(0, super_stringify_1.default)(this.deviceStatus)}`);
333
+ this.openState = this.deviceStatus.body.openState;
334
+ this.moveDetected = this.deviceStatus.body.moveDetected;
335
+ this.brightness = this.deviceStatus.body.brightness;
336
+ this.parseStatus();
337
+ this.updateHomeKitCharacteristics();
338
+ }
339
+ catch (e) {
340
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
341
+ }
370
342
  });
371
- req.end();
372
- }
373
- catch (e) {
374
- this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
375
- if (this.deviceLogging.includes('debug')) {
376
- this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
377
- ` Error Message: ${JSON.stringify(e.message)}`);
378
- }
379
- this.apiError(e);
380
- }
343
+ });
344
+ req.on('error', (e) => {
345
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
346
+ });
347
+ req.end();
348
+ }
349
+ catch (e) {
350
+ this.apiError(e);
351
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
352
+ + ` Connection, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
381
353
  }
382
354
  }
383
355
  /**
@@ -385,129 +357,170 @@ class Contact {
385
357
  */
386
358
  async updateHomeKitCharacteristics() {
387
359
  if (this.ContactSensorState === undefined) {
388
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
360
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
389
361
  }
390
362
  else {
363
+ this.accessory.context.ContactSensorState = this.ContactSensorState;
391
364
  this.contactSensorservice.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.ContactSensorState);
392
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} updateCharacteristic ContactSensorState: ${this.ContactSensorState}`);
365
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic ContactSensorState: ${this.ContactSensorState}`);
393
366
  }
394
367
  if (!this.device.contact?.hide_motionsensor) {
395
368
  if (this.MotionDetected === undefined) {
396
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
369
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
397
370
  }
398
371
  else {
372
+ this.accessory.context.MotionDetected = this.MotionDetected;
399
373
  this.motionService?.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected);
400
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} updateCharacteristic MotionDetected: ${this.MotionDetected}`);
374
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic MotionDetected: ${this.MotionDetected}`);
401
375
  }
402
376
  }
403
377
  if (!this.device.contact?.hide_lightsensor) {
404
378
  if (this.CurrentAmbientLightLevel === undefined) {
405
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
379
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
406
380
  }
407
381
  else {
382
+ this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
408
383
  this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
409
- this.debugLog(`Contact Sensor: ${this.accessory.displayName}` + ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
384
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
385
+ + ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
410
386
  }
411
387
  }
412
- if (this.device.ble) {
388
+ if (this.BLE) {
413
389
  if (this.BatteryLevel === undefined) {
414
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
390
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
415
391
  }
416
392
  else {
393
+ this.accessory.context.BatteryLevel = this.BatteryLevel;
417
394
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
418
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
395
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
419
396
  }
420
397
  if (this.StatusLowBattery === undefined) {
421
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
398
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
422
399
  }
423
400
  else {
401
+ this.accessory.context.StatusLowBattery = this.StatusLowBattery;
424
402
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
425
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
403
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
426
404
  }
427
405
  }
428
406
  }
429
- async apiError(e) {
430
- this.contactSensorservice.updateCharacteristic(this.platform.Characteristic.ContactSensorState, e);
431
- if (!this.device.contact?.hide_motionsensor) {
432
- this.motionService?.updateCharacteristic(this.platform.Characteristic.MotionDetected, e);
433
- }
434
- if (!this.device.contact?.hide_lightsensor) {
435
- this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
436
- }
437
- if (this.device.ble) {
438
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
439
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
407
+ async getCustomBLEAddress(switchbot) {
408
+ if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
409
+ (async () => {
410
+ // Start to monitor advertisement packets
411
+ await switchbot.startScan({
412
+ model: 'd',
413
+ });
414
+ // Set an event handler
415
+ switchbot.onadvertisement = (ad) => {
416
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${(0, super_stringify_1.default)(ad, null, ' ')}`);
417
+ };
418
+ await switchbot.wait(10000);
419
+ // Stop to monitor
420
+ switchbot.stopScan();
421
+ })();
440
422
  }
441
- //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
442
423
  }
443
- async config(device) {
444
- let config = {};
445
- if (device.contact) {
446
- config = device.contact;
447
- }
448
- if (device.ble) {
449
- config['ble'] = device.ble;
450
- }
451
- if (device.logging !== undefined) {
452
- config['logging'] = device.logging;
453
- }
454
- if (device.refreshRate !== undefined) {
455
- config['refreshRate'] = device.refreshRate;
424
+ async BLEconnection(switchbot) {
425
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
426
+ if (this.platform.config.credentials?.token && this.device.connectionType !== 'Both') {
427
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
428
+ this.SwitchToOpenAPI = true;
429
+ await this.openAPIRefreshStatus();
456
430
  }
457
- if (device.scanDuration !== undefined) {
458
- config['scanDuration'] = device.scanDuration;
431
+ }
432
+ minLux() {
433
+ if (this.device.contact?.set_minLux) {
434
+ this.set_minLux = this.device.contact.set_minLux;
459
435
  }
460
- if (Object.entries(config).length !== 0) {
461
- this.infoLog(`Contact Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
436
+ else {
437
+ this.set_minLux = 1;
462
438
  }
439
+ return this.set_minLux;
463
440
  }
464
- async refreshRate(device) {
465
- if (device.refreshRate) {
466
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
467
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
441
+ maxLux() {
442
+ if (this.device.contact?.set_maxLux) {
443
+ this.set_maxLux = this.device.contact.set_maxLux;
468
444
  }
469
- else if (this.platform.config.options.refreshRate) {
470
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
471
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
445
+ else {
446
+ this.set_maxLux = 6001;
472
447
  }
448
+ return this.set_maxLux;
473
449
  }
474
450
  async scan(device) {
475
451
  if (device.scanDuration) {
476
452
  this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
477
- if (device.ble) {
478
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
453
+ if (this.BLE) {
454
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
479
455
  }
480
456
  }
481
457
  else {
482
458
  this.scanDuration = this.accessory.context.scanDuration = 1;
483
- if (this.device.ble) {
484
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
459
+ if (this.BLE) {
460
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
485
461
  }
486
462
  }
487
463
  }
488
- async logs(device) {
489
- if (this.platform.debugMode) {
490
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
491
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
464
+ async statusCode({ res }) {
465
+ switch (res.statusCode) {
466
+ case 151:
467
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this device type.`);
468
+ break;
469
+ case 152:
470
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found.`);
471
+ break;
472
+ case 160:
473
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported.`);
474
+ break;
475
+ case 161:
476
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
477
+ this.offlineOff();
478
+ break;
479
+ case 171:
480
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
481
+ this.offlineOff();
482
+ break;
483
+ case 190:
484
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
485
+ ` Or command: ${(0, super_stringify_1.default)(res)} format is invalid`);
486
+ break;
487
+ case 100:
488
+ if (this.platform.debugMode) {
489
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent.`);
490
+ }
491
+ break;
492
+ default:
493
+ if (this.platform.debugMode) {
494
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode.`);
495
+ }
492
496
  }
493
- else if (device.logging) {
494
- this.deviceLogging = this.accessory.context.logging = device.logging;
495
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
497
+ }
498
+ async offlineOff() {
499
+ if (this.device.offline) {
500
+ this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
501
+ this.contactSensorservice.getCharacteristic(this.platform.Characteristic.ContactSensorState).updateValue(this.ContactSensorState);
502
+ await this.updateHomeKitCharacteristics();
496
503
  }
497
- else if (this.platform.config.options?.logging) {
498
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
499
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
504
+ }
505
+ async apiError(e) {
506
+ this.contactSensorservice.updateCharacteristic(this.platform.Characteristic.ContactSensorState, e);
507
+ if (!this.device.contact?.hide_motionsensor) {
508
+ this.motionService?.updateCharacteristic(this.platform.Characteristic.MotionDetected, e);
500
509
  }
501
- else {
502
- this.deviceLogging = this.accessory.context.logging = 'standard';
503
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
510
+ if (!this.device.contact?.hide_lightsensor) {
511
+ this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
512
+ }
513
+ if (this.BLE) {
514
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
515
+ this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
504
516
  }
505
517
  }
506
518
  FirmwareRevision(accessory, device) {
507
519
  let FirmwareRevision;
508
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
509
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
510
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
520
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
521
+ + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
522
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
523
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
511
524
  if (accessory.context.FirmwareRevision) {
512
525
  FirmwareRevision = accessory.context.FirmwareRevision;
513
526
  }
@@ -519,23 +532,68 @@ class Contact {
519
532
  }
520
533
  return FirmwareRevision;
521
534
  }
522
- minLux() {
523
- if (this.device.contact?.set_minLux) {
524
- this.set_minLux = this.device.contact.set_minLux;
535
+ async context() {
536
+ if (this.MotionDetected === undefined) {
537
+ this.MotionDetected = false;
525
538
  }
526
539
  else {
527
- this.set_minLux = 1;
540
+ this.MotionDetected = this.accessory.context.MotionDetected;
541
+ }
542
+ if (this.ContactSensorState === undefined) {
543
+ this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
544
+ }
545
+ else {
546
+ this.ContactSensorState = this.accessory.context.ContactSensorState;
528
547
  }
529
- return this.set_minLux;
530
548
  }
531
- maxLux() {
532
- if (this.device.contact?.set_maxLux) {
533
- this.set_maxLux = this.device.contact.set_maxLux;
549
+ async refreshRate(device) {
550
+ if (device.refreshRate) {
551
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
552
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
553
+ }
554
+ else if (this.platform.config.options.refreshRate) {
555
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
556
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
557
+ }
558
+ }
559
+ async config(device) {
560
+ let config = {};
561
+ if (device.contact) {
562
+ config = device.contact;
563
+ }
564
+ if (device.connectionType !== undefined) {
565
+ config['connectionType'] = device.connectionType;
566
+ }
567
+ if (device.logging !== undefined) {
568
+ config['logging'] = device.logging;
569
+ }
570
+ if (device.refreshRate !== undefined) {
571
+ config['refreshRate'] = device.refreshRate;
572
+ }
573
+ if (device.scanDuration !== undefined) {
574
+ config['scanDuration'] = device.scanDuration;
575
+ }
576
+ if (Object.entries(config).length !== 0) {
577
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${(0, super_stringify_1.default)(config)}`);
578
+ }
579
+ }
580
+ async logs(device) {
581
+ if (this.platform.debugMode) {
582
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
583
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
584
+ }
585
+ else if (device.logging) {
586
+ this.deviceLogging = this.accessory.context.logging = device.logging;
587
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
588
+ }
589
+ else if (this.platform.config.options?.logging) {
590
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
591
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
534
592
  }
535
593
  else {
536
- this.set_maxLux = 6001;
594
+ this.deviceLogging = this.accessory.context.logging = 'standard';
595
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
537
596
  }
538
- return this.set_maxLux;
539
597
  }
540
598
  /**
541
599
  * Logging for Device