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

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 +5 -5
  85. package/dist/platform.d.ts.map +1 -1
  86. package/dist/platform.js +227 -199
  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 +216 -214
  113. package/src/settings.ts +15 -11
@@ -7,6 +7,7 @@ exports.Humidifier = void 0;
7
7
  const https_1 = __importDefault(require("https"));
8
8
  const crypto_1 = __importDefault(require("crypto"));
9
9
  const rxjs_1 = require("rxjs");
10
+ const super_stringify_1 = __importDefault(require("super-stringify"));
10
11
  const operators_1 = require("rxjs/operators");
11
12
  const settings_1 = require("../settings");
12
13
  /**
@@ -19,18 +20,15 @@ class Humidifier {
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.CurrentRelativeHumidity = 0;
28
- this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
29
- this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
30
- this.Active = this.platform.Characteristic.Active.ACTIVE;
31
- this.RelativeHumidityHumidifierThreshold = 0;
32
- this.CurrentTemperature = 0;
33
- this.WaterLevel = 0;
31
+ this.context();
34
32
  // this is subject we use to track when we need to POST changes to the SwitchBot API
35
33
  this.doHumidifierUpdate = new rxjs_1.Subject();
36
34
  this.humidifierUpdateInProgress = false;
@@ -68,8 +66,8 @@ class Humidifier {
68
66
  maxValue: 1,
69
67
  validValues: [0, 1],
70
68
  })
71
- .onSet(this.handleTargetHumidifierDehumidifierStateSet.bind(this));
72
- this.humidifierService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.handleActiveSet.bind(this));
69
+ .onSet(this.TargetHumidifierDehumidifierStateSet.bind(this));
70
+ this.humidifierService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
73
71
  this.humidifierService
74
72
  .getCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold)
75
73
  .setProps({
@@ -78,15 +76,15 @@ class Humidifier {
78
76
  maxValue: 100,
79
77
  minStep: this.minStep(),
80
78
  })
81
- .onSet(this.handleRelativeHumidityHumidifierThresholdSet.bind(this));
79
+ .onSet(this.RelativeHumidityHumidifierThresholdSet.bind(this));
82
80
  // Temperature Sensor Service
83
- if (device.humidifier?.hide_temperature || device.ble) {
84
- this.debugLog(`Humidifier: ${accessory.displayName} Removing Temperature Sensor Service`);
81
+ if (device.humidifier?.hide_temperature || this.BLE) {
82
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
85
83
  this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor);
86
84
  accessory.removeService(this.temperatureservice);
87
85
  }
88
- else if (!this.temperatureservice && !device.ble) {
89
- this.debugLog(`Humidifier: ${accessory.displayName} Add Temperature Sensor Service`);
86
+ else if (!this.temperatureservice && !this.BLE) {
87
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
90
88
  (this.temperatureservice =
91
89
  this.accessory.getService(this.platform.Service.TemperatureSensor) || this.accessory.addService(this.platform.Service.TemperatureSensor)),
92
90
  `${accessory.displayName} Temperature Sensor`;
@@ -104,7 +102,7 @@ class Humidifier {
104
102
  });
105
103
  }
106
104
  else {
107
- this.debugLog(`Humidifier: ${accessory.displayName} Temperature Sensor Service Not Added`);
105
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Temperature Sensor Service Not Added`);
108
106
  }
109
107
  // Retrieve initial values and updateHomekit
110
108
  this.updateHomeKitCharacteristics();
@@ -125,11 +123,9 @@ class Humidifier {
125
123
  await this.pushChanges();
126
124
  }
127
125
  catch (e) {
128
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges`);
129
- if (this.deviceLogging.includes('debug')) {
130
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
131
- }
132
126
  this.apiError(e);
127
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
128
+ + ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
133
129
  }
134
130
  this.humidifierUpdateInProgress = false;
135
131
  });
@@ -138,18 +134,23 @@ class Humidifier {
138
134
  * Parse the device status from the SwitchBot api
139
135
  */
140
136
  async parseStatus() {
141
- if (this.device.ble) {
137
+ if (this.BLE && !this.SwitchToOpenAPI) {
142
138
  await this.BLEparseStatus();
143
139
  }
144
- else {
140
+ else if (this.OpenAPI && this.platform.config.credentials?.token) {
141
+ this.SwitchToOpenAPI = false;
145
142
  await this.openAPIparseStatus();
146
143
  }
144
+ else {
145
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
146
+ + ` ${this.device.connectionType}, parseStatus will not happen.`);
147
+ }
147
148
  }
148
149
  async BLEparseStatus() {
149
- this.debugLog(`Humidifier: ${this.accessory.displayName} BLE parseStatus`);
150
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
150
151
  // Current Relative Humidity
151
152
  this.CurrentRelativeHumidity = this.percentage;
152
- this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
153
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
153
154
  // Active
154
155
  if (this.onState) {
155
156
  this.Active = this.platform.Characteristic.Active.ACTIVE;
@@ -157,86 +158,91 @@ class Humidifier {
157
158
  else {
158
159
  this.Active = this.platform.Characteristic.Active.INACTIVE;
159
160
  }
160
- this.debugLog(`Humidifier: ${this.accessory.displayName} Active: ${this.Active}`);
161
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
161
162
  }
162
163
  async openAPIparseStatus() {
163
- if (this.platform.config.credentials?.token) {
164
- this.debugLog(`Humidifier: ${this.accessory.displayName} OpenAPI parseStatus`);
165
- // Current Relative Humidity
166
- this.CurrentRelativeHumidity = this.humidity;
167
- this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
168
- // Current Temperature
169
- if (!this.device.humidifier?.hide_temperature) {
170
- this.CurrentTemperature = this.temperature;
171
- this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
172
- }
173
- // Target Humidifier Dehumidifier State
174
- switch (this.auto) {
175
- case true:
176
- this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
164
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
165
+ // Current Relative Humidity
166
+ this.CurrentRelativeHumidity = this.humidity;
167
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
168
+ // Current Temperature
169
+ if (!this.device.humidifier?.hide_temperature) {
170
+ this.CurrentTemperature = this.temperature;
171
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
172
+ }
173
+ // Target Humidifier Dehumidifier State
174
+ switch (this.auto) {
175
+ case true:
176
+ this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
177
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
178
+ this.RelativeHumidityHumidifierThreshold = this.CurrentRelativeHumidity;
179
+ break;
180
+ default:
181
+ this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
182
+ if (this.nebulizationEfficiency > 100) {
183
+ this.RelativeHumidityHumidifierThreshold = 100;
184
+ }
185
+ else {
186
+ this.RelativeHumidityHumidifierThreshold = this.nebulizationEfficiency;
187
+ }
188
+ if (this.CurrentRelativeHumidity > this.RelativeHumidityHumidifierThreshold) {
189
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
190
+ }
191
+ else if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
192
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
193
+ }
194
+ else {
177
195
  this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
178
- this.RelativeHumidityHumidifierThreshold = this.CurrentRelativeHumidity;
179
- break;
180
- default:
181
- this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
182
- if (this.nebulizationEfficiency > 100) {
183
- this.RelativeHumidityHumidifierThreshold = 100;
184
- }
185
- else {
186
- this.RelativeHumidityHumidifierThreshold = this.nebulizationEfficiency;
187
- }
188
- if (this.CurrentRelativeHumidity > this.RelativeHumidityHumidifierThreshold) {
189
- this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
190
- }
191
- else if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
192
- this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
193
- }
194
- else {
195
- this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
196
- }
197
- }
198
- this.debugLog(`Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
199
- this.debugLog(`Humidifier: ${this.accessory.displayName}` + ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
200
- this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
201
- // Active
202
- switch (this.power) {
203
- case 'on':
204
- this.Active = this.platform.Characteristic.Active.ACTIVE;
205
- break;
206
- default:
207
- this.Active = this.platform.Characteristic.Active.INACTIVE;
208
- }
209
- this.debugLog(`Humidifier: ${this.accessory.displayName} Active: ${this.Active}`);
210
- // Water Level
211
- if (this.lackWater) {
212
- this.WaterLevel = 0;
213
- }
214
- else {
215
- this.WaterLevel = 100;
216
- }
217
- this.debugLog(`Humidifier: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
196
+ }
197
+ }
198
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
199
+ + ` TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
200
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
201
+ + ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
202
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
203
+ + ` CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
204
+ // Active
205
+ switch (this.power) {
206
+ case 'on':
207
+ this.Active = this.platform.Characteristic.Active.ACTIVE;
208
+ break;
209
+ default:
210
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
218
211
  }
212
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
213
+ // Water Level
214
+ if (this.lackWater) {
215
+ this.WaterLevel = 0;
216
+ }
217
+ else {
218
+ this.WaterLevel = 100;
219
+ }
220
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
219
221
  }
220
222
  /**
221
223
  * Asks the SwitchBot API for the latest device information
222
224
  */
223
225
  async refreshStatus() {
224
- if (this.device.ble) {
226
+ if (this.BLE) {
225
227
  await this.BLERefreshStatus();
226
228
  }
227
- else {
229
+ else if (this.OpenAPI && this.platform.config.credentials?.token) {
228
230
  await this.openAPIRefreshStatus();
229
231
  }
232
+ else {
233
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
234
+ + ` ${this.device.connectionType}, refreshStatus will not happen.`);
235
+ }
230
236
  }
231
237
  async BLERefreshStatus() {
232
- this.debugLog(`Humidifier: ${this.accessory.displayName} BLE refreshStatus`);
238
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLERefreshStatus`);
233
239
  const switchbot = await this.platform.connectBLE();
234
240
  // Convert to BLE Address
235
241
  this.device.bleMac = this.device
236
242
  .deviceId.match(/.{1,2}/g)
237
243
  .join(':')
238
244
  .toLowerCase();
239
- this.debugLog(`Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
245
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
240
246
  this.getCustomBLEAddress(switchbot);
241
247
  // Start to monitor advertisement packets
242
248
  if (switchbot !== false) {
@@ -252,23 +258,23 @@ class Humidifier {
252
258
  if (this.deviceLogging.includes('debug')) {
253
259
  this.infoLog(this.address);
254
260
  this.infoLog(this.device.bleMac);
255
- this.infoLog(`Humidifier: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
256
- this.infoLog(`Humidifier: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
261
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
262
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
257
263
  }
258
264
  this.serviceData = ad.serviceData;
259
265
  this.autoMode = ad.serviceData.autoMode;
260
266
  this.onState = ad.serviceData.onState;
261
267
  this.percentage = ad.serviceData.percentage;
262
- this.debugLog(`Humidifier: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
263
- this.debugLog(`Humidifier: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
268
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${(0, super_stringify_1.default)(ad.serviceData)}`);
269
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
264
270
  `autoMode: ${ad.serviceData.autoMode}, onState: ${ad.serviceData.onState}, percentage: ${ad.serviceData.percentage}`);
265
271
  if (this.serviceData) {
266
272
  this.connected = true;
267
- this.debugLog(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
273
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
268
274
  }
269
275
  else {
270
276
  this.connected = false;
271
- this.debugLog(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
277
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
272
278
  }
273
279
  };
274
280
  // Wait 2 seconds
@@ -286,117 +292,87 @@ class Humidifier {
286
292
  }
287
293
  })
288
294
  .catch(async (e) => {
289
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
290
- if (this.deviceLogging.includes('debug')) {
291
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`);
292
- }
293
- if (this.platform.config.credentials?.token) {
294
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
295
- await this.openAPIRefreshStatus();
296
- }
297
295
  this.apiError(e);
296
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}`
297
+ + ` Connection, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
298
+ await this.BLEconnection(switchbot);
298
299
  });
299
300
  }
300
301
  else {
301
302
  await this.BLEconnection(switchbot);
302
303
  }
303
304
  }
304
- async getCustomBLEAddress(switchbot) {
305
- if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
306
- (async () => {
307
- // Start to monitor advertisement packets
308
- await switchbot.startScan({
309
- model: 'e',
310
- });
311
- // Set an event handler
312
- switchbot.onadvertisement = (ad) => {
313
- this.warnLog(`Humidifier: ${this.accessory.displayName} ad: ${JSON.stringify(ad, null, ' ')}`);
314
- };
315
- await switchbot.wait(10000);
316
- // Stop to monitor
317
- switchbot.stopScan();
318
- })();
319
- }
320
- }
321
- async BLEconnection(switchbot) {
322
- this.errorLog(`Humidifier: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
323
- if (this.platform.config.credentials?.token) {
324
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
325
- await this.openAPIRefreshStatus();
326
- }
327
- }
328
305
  async openAPIRefreshStatus() {
329
- if (this.platform.config.credentials?.token) {
330
- this.debugLog(`Humidifier: ${this.accessory.displayName} OpenAPI refreshStatus`);
331
- try {
332
- const t = Date.now();
333
- const nonce = 'requestID';
334
- const data = this.platform.config.credentials?.token + t + nonce;
335
- const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
336
- const sign = signTerm.toString('base64');
337
- this.debugLog(`Humidifier: ${this.accessory.displayName} sign: ${sign}`);
338
- const options = {
339
- hostname: settings_1.HostDomain,
340
- port: 443,
341
- path: `${settings_1.DevicePath}/${this.device.deviceId}/status`,
342
- method: 'GET',
343
- headers: {
344
- Authorization: this.platform.config.credentials?.token,
345
- sign: sign,
346
- nonce: nonce,
347
- t: t,
348
- 'Content-Type': 'application/json',
349
- },
350
- };
351
- const req = https_1.default.request(options, (res) => {
352
- this.debugLog(`Humidifier: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
353
- let rawData = '';
354
- res.on('data', (d) => {
355
- rawData += d;
356
- this.debugLog(`Humidifier: ${this.accessory.displayName} d: ${d}`);
357
- });
358
- res.on('end', () => {
359
- try {
360
- this.deviceStatus = JSON.parse(rawData);
361
- this.debugLog(`Humidifier: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
362
- this.auto = this.deviceStatus.body.auto;
363
- this.power = this.deviceStatus.body.power;
364
- this.lackWater = this.deviceStatus.body.lackWater;
365
- this.humidity = this.deviceStatus.body.humidity;
366
- this.temperature = this.deviceStatus.body.temperature;
367
- this.nebulizationEfficiency = this.deviceStatus.body.nebulizationEfficiency;
368
- this.parseStatus();
369
- this.updateHomeKitCharacteristics();
370
- }
371
- catch (e) {
372
- this.errorLog(`Humidifier: ${this.accessory.displayName} error message: ${e.message}`);
373
- }
374
- });
306
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
307
+ try {
308
+ const t = Date.now();
309
+ const nonce = 'requestID';
310
+ const data = this.platform.config.credentials?.token + t + nonce;
311
+ const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
312
+ const sign = signTerm.toString('base64');
313
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
314
+ const options = {
315
+ hostname: settings_1.HostDomain,
316
+ port: 443,
317
+ path: `${settings_1.DevicePath}/${this.device.deviceId}/status`,
318
+ method: 'GET',
319
+ headers: {
320
+ Authorization: this.platform.config.credentials?.token,
321
+ sign: sign,
322
+ nonce: nonce,
323
+ t: t,
324
+ 'Content-Type': 'application/json',
325
+ },
326
+ };
327
+ const req = https_1.default.request(options, (res) => {
328
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus statusCode: ${res.statusCode}`);
329
+ let rawData = '';
330
+ res.on('data', (d) => {
331
+ rawData += d;
332
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
375
333
  });
376
- req.on('error', (e) => {
377
- this.errorLog(`Humidifier: ${this.accessory.displayName} error message: ${e.message}`);
334
+ res.on('end', () => {
335
+ try {
336
+ this.deviceStatus = JSON.parse(rawData);
337
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus: ${(0, super_stringify_1.default)(this.deviceStatus)}`);
338
+ this.auto = this.deviceStatus.body.auto;
339
+ this.power = this.deviceStatus.body.power;
340
+ this.lackWater = this.deviceStatus.body.lackWater;
341
+ this.humidity = this.deviceStatus.body.humidity;
342
+ this.temperature = this.deviceStatus.body.temperature;
343
+ this.nebulizationEfficiency = this.deviceStatus.body.nebulizationEfficiency;
344
+ this.parseStatus();
345
+ this.updateHomeKitCharacteristics();
346
+ }
347
+ catch (e) {
348
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
349
+ }
378
350
  });
379
- req.end();
380
- }
381
- catch (e) {
382
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
383
- if (this.deviceLogging.includes('debug')) {
384
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
385
- ` Error Message: ${JSON.stringify(e.message)}`);
386
- }
387
- this.apiError(e);
388
- }
351
+ });
352
+ req.on('error', (e) => {
353
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
354
+ });
355
+ req.end();
356
+ }
357
+ catch (e) {
358
+ this.apiError(e);
359
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
360
+ + ` Connection, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
389
361
  }
390
362
  }
391
363
  /**
392
364
  * Pushes the requested changes to the SwitchBot API
393
365
  */
394
366
  async pushChanges() {
395
- //if (this.device.ble) {
396
- // await this.BLEpushChanges();
397
- //} else {
398
- await this.openAPIpushChanges();
399
- //}
367
+ /*if (this.BLE) {
368
+ await this.BLERefreshStatus();
369
+ } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
370
+ await this.openAPIpushChanges();
371
+ }
372
+ else {
373
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
374
+ + ` ${this.device.connectionType}, pushChanges will not happen.`);
375
+ }
400
376
  (0, rxjs_1.interval)(5000)
401
377
  .pipe((0, operators_1.take)(1))
402
378
  .subscribe(async () => {
@@ -404,47 +380,40 @@ class Humidifier {
404
380
  });
405
381
  }
406
382
  async BLEpushChanges() {
407
- this.debugLog(`Humidifier: ${this.accessory.displayName} BLE pushChanges`);
383
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEpushChanges`);
408
384
  const switchbot = await this.platform.connectBLE();
409
385
  // Convert to BLE Address
410
386
  this.device.bleMac = this.device
411
387
  .deviceId.match(/.{1,2}/g)
412
388
  .join(':')
413
389
  .toLowerCase();
414
- this.debugLog(`Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
415
- if (switchbot !== false) {
416
- switchbot
417
- .discover({ model: 'e', quick: true, id: this.device.bleMac })
418
- .then((device_list) => {
419
- this.infoLog(`${this.accessory.displayName} Target Position: ${this.Active}`);
420
- return device_list[0].percentage(this.RelativeHumidityHumidifierThreshold);
421
- })
422
- .then(() => {
423
- this.debugLog(`Humidifier: ${this.accessory.displayName} Done.`);
424
- })
425
- .catch(async (e) => {
426
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
427
- if (this.deviceLogging.includes('debug')) {
428
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`);
429
- }
430
- if (this.platform.config.credentials?.token) {
431
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
432
- await this.openAPIpushChanges();
433
- }
434
- this.apiError(e);
435
- });
436
- }
437
- else {
438
- this.errorLog(`Humidifier: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
439
- if (this.platform.config.credentials?.token) {
440
- this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
390
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
391
+ switchbot
392
+ .discover({
393
+ model: 'e',
394
+ quick: true,
395
+ id: this.device.bleMac,
396
+ })
397
+ .then((device_list) => {
398
+ this.infoLog(`${this.accessory.displayName} Target Position: ${this.Active}`);
399
+ return device_list[0].percentage(this.RelativeHumidityHumidifierThreshold);
400
+ })
401
+ .then(() => {
402
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
403
+ })
404
+ .catch(async (e) => {
405
+ this.apiError(e);
406
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
407
+ + ` Connection, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
408
+ if (this.platform.config.credentials?.token && this.device.connectionType !== 'Both') {
409
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
441
410
  await this.openAPIpushChanges();
442
411
  }
443
- }
412
+ });
444
413
  }
445
414
  async openAPIpushChanges() {
446
- if (this.platform.config.credentials?.token) {
447
- this.debugLog(`Humidifier: ${this.accessory.displayName} OpenAPI pushChanges`);
415
+ try {
416
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
448
417
  if (this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER &&
449
418
  this.Active === this.platform.Characteristic.Active.ACTIVE) {
450
419
  // Make Push On request to the API
@@ -455,14 +424,14 @@ class Humidifier {
455
424
  .update(Buffer.from(data, 'utf-8'))
456
425
  .digest();
457
426
  const sign = signTerm.toString('base64');
458
- this.debugLog(`Humidifier: ${this.accessory.displayName} sign: ${sign}`);
427
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
459
428
  this.debugLog(`Pushing Manual: ${this.RelativeHumidityHumidifierThreshold}!`);
460
- const body = JSON.stringify({
429
+ const body = (0, super_stringify_1.default)({
461
430
  'command': 'setMode',
462
431
  'parameter': `${this.RelativeHumidityHumidifierThreshold}`,
463
432
  'commandType': 'command',
464
433
  });
465
- this.infoLog(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
434
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
466
435
  const options = {
467
436
  hostname: settings_1.HostDomain,
468
437
  port: 443,
@@ -478,18 +447,18 @@ class Humidifier {
478
447
  },
479
448
  };
480
449
  const req = https_1.default.request(options, res => {
481
- this.debugLog(`Humidifier: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
450
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges statusCode: ${res.statusCode}`);
482
451
  res.on('data', d => {
483
- this.debugLog(`Humidifier: ${this.accessory.displayName} d: ${d}`);
452
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
484
453
  });
485
454
  });
486
455
  req.on('error', (e) => {
487
- this.errorLog(`Humidifier: ${this.accessory.displayName} error message: ${e.message}`);
456
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
488
457
  this.apiError(e);
489
458
  });
490
459
  req.write(body);
491
460
  req.end();
492
- this.debugLog(`Humidifier: ${this.accessory.displayName} openAPIpushChanges: ${JSON.stringify(req)}`);
461
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges: ${(0, super_stringify_1.default)(req)}`);
493
462
  }
494
463
  else if (this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
495
464
  this.Active === this.platform.Characteristic.Active.ACTIVE) {
@@ -499,12 +468,18 @@ class Humidifier {
499
468
  await this.pushActiveChanges();
500
469
  }
501
470
  }
471
+ catch (e) {
472
+ this.apiError(e);
473
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
474
+ + ` Connection, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
475
+ }
502
476
  }
503
477
  /**
504
478
  * Pushes the requested changes to the SwitchBot API
505
479
  */
506
480
  async pushAutoChanges() {
507
481
  try {
482
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushAutoChanges`);
508
483
  if (this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
509
484
  this.Active === this.platform.Characteristic.Active.ACTIVE) {
510
485
  // Make Push On request to the API
@@ -515,14 +490,14 @@ class Humidifier {
515
490
  .update(Buffer.from(data, 'utf-8'))
516
491
  .digest();
517
492
  const sign = signTerm.toString('base64');
518
- this.debugLog(`Humidifier: ${this.accessory.displayName} sign: ${sign}`);
493
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
519
494
  this.debugLog('Pushing Auto!');
520
- const body = JSON.stringify({
495
+ const body = (0, super_stringify_1.default)({
521
496
  'command': 'setMode',
522
497
  'parameter': 'auto',
523
498
  'commandType': 'command',
524
499
  });
525
- this.infoLog(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
500
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
526
501
  const options = {
527
502
  hostname: settings_1.HostDomain,
528
503
  port: 443,
@@ -538,27 +513,28 @@ class Humidifier {
538
513
  },
539
514
  };
540
515
  const req = https_1.default.request(options, res => {
541
- this.debugLog(`Humidifier: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
516
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
542
517
  this.statusCode({ res });
543
518
  res.on('data', d => {
544
- this.debugLog(`Humidifier: ${this.accessory.displayName} d: ${d}`);
519
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
545
520
  });
546
521
  });
547
522
  req.on('error', (e) => {
548
- this.errorLog(`Humidifier: ${this.accessory.displayName} error message: ${e.message}`);
523
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
549
524
  });
550
525
  req.write(body);
551
526
  req.end();
552
- this.debugLog(`Humidifier: ${this.accessory.displayName} pushAutoChanges: ${JSON.stringify(req)}`);
527
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushAutoChanges: ${(0, super_stringify_1.default)(req)}`);
528
+ }
529
+ else {
530
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No pushAutoChanges.` +
531
+ `TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}, Active: ${this.Active}`);
553
532
  }
554
533
  }
555
534
  catch (e) {
556
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection`);
557
- if (this.deviceLogging.includes('debug')) {
558
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,` +
559
- ` Error Message: ${JSON.stringify(e.message)}`);
560
- }
561
535
  this.apiError(e);
536
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushAutoChanges with ${this.device.connectionType}`
537
+ + ` Connection, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
562
538
  }
563
539
  }
564
540
  /**
@@ -566,6 +542,7 @@ class Humidifier {
566
542
  */
567
543
  async pushActiveChanges() {
568
544
  try {
545
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushActiveChanges`);
569
546
  if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
570
547
  // Make Push On request to the API
571
548
  const t = Date.now();
@@ -575,14 +552,14 @@ class Humidifier {
575
552
  .update(Buffer.from(data, 'utf-8'))
576
553
  .digest();
577
554
  const sign = signTerm.toString('base64');
578
- this.debugLog(`Humidifier: ${this.accessory.displayName} sign: ${sign}`);
555
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
579
556
  this.debugLog('Pushing Off!');
580
- const body = JSON.stringify({
557
+ const body = (0, super_stringify_1.default)({
581
558
  'command': 'turnOff',
582
559
  'parameter': 'default',
583
560
  'commandType': 'command',
584
561
  });
585
- this.infoLog(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
562
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
586
563
  const options = {
587
564
  hostname: settings_1.HostDomain,
588
565
  port: 443,
@@ -598,175 +575,302 @@ class Humidifier {
598
575
  },
599
576
  };
600
577
  const req = https_1.default.request(options, res => {
601
- this.debugLog(`Humidifier: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
578
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushActiveChanges statusCode: ${res.statusCode}`);
602
579
  this.statusCode({ res });
603
580
  res.on('data', d => {
604
- this.debugLog(`Humidifier: ${this.accessory.displayName} d: ${d}`);
581
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
605
582
  });
606
583
  });
607
584
  req.on('error', (e) => {
608
- this.errorLog(`Humidifier: ${this.accessory.displayName} error message: ${e.message}`);
585
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
609
586
  });
610
587
  req.write(body);
611
588
  req.end();
612
- this.debugLog(`Humidifier: ${this.accessory.displayName} pushActiveChanges: ${JSON.stringify(req)}`);
589
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushActiveChanges: ${(0, super_stringify_1.default)(req)}`);
613
590
  }
614
591
  }
615
592
  catch (e) {
616
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection`);
617
- if (this.deviceLogging.includes('debug')) {
618
- this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,` +
619
- ` Error Message: ${JSON.stringify(e.message)}`);
620
- }
621
593
  this.apiError(e);
594
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushActiveChanges with ${this.device.connectionType}`
595
+ + ` Connection, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
622
596
  }
623
597
  }
598
+ /**
599
+ * Handle requests to set the "Target Humidifier Dehumidifier State" characteristic
600
+ */
601
+ async TargetHumidifierDehumidifierStateSet(value) {
602
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetHumidifierDehumidifierState: ${value}`);
603
+ this.TargetHumidifierDehumidifierState = value;
604
+ this.doHumidifierUpdate.next();
605
+ }
606
+ /**
607
+ * Handle requests to set the "Active" characteristic
608
+ */
609
+ async ActiveSet(value) {
610
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Active: ${value}`);
611
+ this.Active = value;
612
+ this.doHumidifierUpdate.next();
613
+ }
614
+ /**
615
+ * Handle requests to set the "Relative Humidity Humidifier Threshold" characteristic
616
+ */
617
+ async RelativeHumidityHumidifierThresholdSet(value) {
618
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set RelativeHumidityHumidifierThreshold: ${value}`);
619
+ this.RelativeHumidityHumidifierThreshold = value;
620
+ if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
621
+ this.Active = this.platform.Characteristic.Active.ACTIVE;
622
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
623
+ }
624
+ this.doHumidifierUpdate.next();
625
+ }
624
626
  /**
625
627
  * Updates the status for each of the HomeKit Characteristics
626
628
  */
627
629
  async updateHomeKitCharacteristics() {
628
630
  if (this.CurrentRelativeHumidity === undefined) {
629
- this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
631
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
630
632
  }
631
633
  else {
634
+ this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
632
635
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
633
- this.debugLog(`Humidifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
636
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
637
+ + ` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
634
638
  }
635
- if (!this.device.ble) {
639
+ if (this.OpenAPI) {
636
640
  if (this.WaterLevel === undefined) {
637
- this.debugLog(`Humidifier: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
641
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
638
642
  }
639
643
  else {
644
+ this.accessory.context.WaterLevel = this.WaterLevel;
640
645
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.WaterLevel, this.WaterLevel);
641
- this.debugLog(`Humidifier: ${this.accessory.displayName} updateCharacteristic WaterLevel: ${this.WaterLevel}`);
646
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic WaterLevel: ${this.WaterLevel}`);
642
647
  }
643
648
  }
644
649
  if (this.CurrentHumidifierDehumidifierState === undefined) {
645
- this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
650
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
651
+ + ` CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
646
652
  }
647
653
  else {
654
+ this.accessory.context.CurrentHumidifierDehumidifierState = this.CurrentHumidifierDehumidifierState;
648
655
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, this.CurrentHumidifierDehumidifierState);
649
- this.debugLog(`Humidifier: ${this.accessory.displayName}` +
656
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` +
650
657
  ` updateCharacteristic CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
651
658
  }
652
659
  if (this.TargetHumidifierDehumidifierState === undefined) {
653
- this.debugLog(`Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
660
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
661
+ + ` TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
654
662
  }
655
663
  else {
664
+ this.accessory.context.TargetHumidifierDehumidifierState = this.TargetHumidifierDehumidifierState;
656
665
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.TargetHumidifierDehumidifierState);
657
- this.debugLog(`Humidifier: ${this.accessory.displayName}` +
666
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` +
658
667
  ` updateCharacteristic TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
659
668
  }
660
669
  if (this.Active === undefined) {
661
- this.debugLog(`Humidifier: ${this.accessory.displayName} Active: ${this.Active}`);
670
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
662
671
  }
663
672
  else {
673
+ this.accessory.context.Active = this.Active;
664
674
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
665
- this.debugLog(`Humidifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
675
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
666
676
  }
667
677
  if (this.RelativeHumidityHumidifierThreshold === undefined) {
668
- this.debugLog(`Humidifier: ${this.accessory.displayName}` + ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
678
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
679
+ + ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
669
680
  }
670
681
  else {
682
+ this.accessory.context.RelativeHumidityHumidifierThreshold = this.RelativeHumidityHumidifierThreshold;
671
683
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, this.RelativeHumidityHumidifierThreshold);
672
- this.debugLog(`Humidifier: ${this.accessory.displayName}` +
684
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` +
673
685
  ` updateCharacteristic RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
674
686
  }
675
- if (!this.device.humidifier?.hide_temperature && !this.device.ble) {
687
+ if (!this.device.humidifier?.hide_temperature && !this.BLE) {
676
688
  if (this.CurrentTemperature === undefined) {
677
- this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
689
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
678
690
  }
679
691
  else {
692
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
680
693
  this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
681
- this.debugLog(`Humidifier: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
694
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
682
695
  }
683
696
  }
684
697
  }
685
- async apiError(e) {
686
- this.humidifierService.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
687
- if (!this.device.ble) {
688
- this.humidifierService.updateCharacteristic(this.platform.Characteristic.WaterLevel, e);
698
+ async getCustomBLEAddress(switchbot) {
699
+ if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
700
+ (async () => {
701
+ // Start to monitor advertisement packets
702
+ await switchbot.startScan({
703
+ model: 'e',
704
+ });
705
+ // Set an event handler
706
+ switchbot.onadvertisement = (ad) => {
707
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${(0, super_stringify_1.default)(ad, null, ' ')}`);
708
+ };
709
+ await switchbot.wait(10000);
710
+ // Stop to monitor
711
+ switchbot.stopScan();
712
+ })();
689
713
  }
690
- this.humidifierService.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, e);
691
- this.humidifierService.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, e);
692
- this.humidifierService.updateCharacteristic(this.platform.Characteristic.Active, e);
693
- this.humidifierService.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, e);
694
- if (!this.device.humidifier?.hide_temperature && !this.device.ble) {
695
- this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
714
+ }
715
+ async BLEconnection(switchbot) {
716
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
717
+ if (this.platform.config.credentials?.token && this.device.connectionType !== 'Both') {
718
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
719
+ this.SwitchToOpenAPI = true;
720
+ await this.openAPIRefreshStatus();
721
+ }
722
+ }
723
+ minStep() {
724
+ if (this.device.humidifier?.set_minStep) {
725
+ this.set_minStep = this.device.humidifier?.set_minStep;
726
+ }
727
+ else {
728
+ this.set_minStep = 1;
729
+ }
730
+ return this.set_minStep;
731
+ }
732
+ async scan(device) {
733
+ if (device.scanDuration) {
734
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
735
+ if (this.BLE) {
736
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
737
+ }
738
+ }
739
+ else {
740
+ this.scanDuration = this.accessory.context.scanDuration = 1;
741
+ if (this.BLE) {
742
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
743
+ }
696
744
  }
697
- //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
698
745
  }
699
746
  async statusCode({ res }) {
700
747
  switch (res.statusCode) {
701
748
  case 151:
702
- this.errorLog(`Humidifier: ${this.accessory.displayName} Command not supported by this device type.`);
749
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this device type.`);
703
750
  break;
704
751
  case 152:
705
- this.errorLog(`Humidifier: ${this.accessory.displayName} Device not found.`);
752
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found.`);
706
753
  break;
707
754
  case 160:
708
- this.errorLog(`Humidifier: ${this.accessory.displayName} Command is not supported.`);
755
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported.`);
709
756
  break;
710
757
  case 161:
711
- this.errorLog(`Humidifier: ${this.accessory.displayName} Device is offline.`);
758
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
712
759
  this.offlineOff();
713
760
  break;
714
761
  case 171:
715
- this.errorLog(`Humidifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
762
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
716
763
  this.offlineOff();
717
764
  break;
718
765
  case 190:
719
- this.errorLog(`Humidifier: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
720
- ` Or command: ${JSON.stringify(res)} format is invalid`);
766
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
767
+ ` Or command: ${(0, super_stringify_1.default)(res)} format is invalid`);
721
768
  break;
722
769
  case 100:
723
- this.debugLog(`Humidifier: ${this.accessory.displayName} Command successfully sent.`);
770
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent.`);
724
771
  break;
725
772
  default:
726
- this.debugLog(`Humidifier: ${this.accessory.displayName} Unknown statusCode.`);
773
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode.`);
727
774
  }
728
775
  }
729
776
  async offlineOff() {
730
777
  if (this.device.offline) {
731
778
  this.Active = this.platform.Characteristic.Active.INACTIVE;
732
779
  this.humidifierService.getCharacteristic(this.platform.Characteristic.Active).updateValue(this.Active);
780
+ await this.updateHomeKitCharacteristics();
733
781
  }
734
782
  }
735
- /**
736
- * Handle requests to set the "Target Humidifier Dehumidifier State" characteristic
737
- */
738
- async handleTargetHumidifierDehumidifierStateSet(value) {
739
- this.debugLog(`Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${value}`);
740
- this.TargetHumidifierDehumidifierState = value;
741
- this.doHumidifierUpdate.next();
783
+ async apiError(e) {
784
+ this.humidifierService.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
785
+ if (!this.BLE) {
786
+ this.humidifierService.updateCharacteristic(this.platform.Characteristic.WaterLevel, e);
787
+ }
788
+ this.humidifierService.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, e);
789
+ this.humidifierService.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, e);
790
+ this.humidifierService.updateCharacteristic(this.platform.Characteristic.Active, e);
791
+ this.humidifierService.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, e);
792
+ if (!this.device.humidifier?.hide_temperature && !this.BLE) {
793
+ this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
794
+ }
742
795
  }
743
- /**
744
- * Handle requests to set the "Active" characteristic
745
- */
746
- async handleActiveSet(value) {
747
- this.debugLog(`Humidifier: ${this.accessory.displayName} Active: ${value}`);
748
- this.Active = value;
749
- this.doHumidifierUpdate.next();
796
+ FirmwareRevision(accessory, device) {
797
+ let FirmwareRevision;
798
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
799
+ + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
800
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
801
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
802
+ if (accessory.context.FirmwareRevision) {
803
+ FirmwareRevision = accessory.context.FirmwareRevision;
804
+ }
805
+ else if (device.firmware) {
806
+ FirmwareRevision = device.firmware;
807
+ }
808
+ else {
809
+ FirmwareRevision = this.platform.version;
810
+ }
811
+ return FirmwareRevision;
750
812
  }
751
- /**
752
- * Handle requests to set the "Relative Humidity Humidifier Threshold" characteristic
753
- */
754
- async handleRelativeHumidityHumidifierThresholdSet(value) {
755
- this.debugLog(`Humidifier: ${this.accessory.displayName} RelativeHumidityHumidifierThreshold: ${value}`);
756
- this.RelativeHumidityHumidifierThreshold = value;
757
- if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
813
+ async context() {
814
+ if (this.Active === undefined) {
758
815
  this.Active = this.platform.Characteristic.Active.ACTIVE;
759
- this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
760
816
  }
761
- this.doHumidifierUpdate.next();
817
+ else {
818
+ this.Active = this.accessory.context.Active;
819
+ }
820
+ if (this.CurrentTemperature === undefined) {
821
+ this.CurrentTemperature = 0;
822
+ }
823
+ else {
824
+ this.CurrentTemperature = this.accessory.context.CurrentTemperature;
825
+ }
826
+ if (this.CurrentRelativeHumidity === undefined) {
827
+ this.CurrentRelativeHumidity = 0;
828
+ }
829
+ else {
830
+ this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
831
+ }
832
+ if (this.TargetHumidifierDehumidifierState === undefined) {
833
+ this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
834
+ }
835
+ else {
836
+ this.TargetHumidifierDehumidifierState = this.accessory.context.TargetHumidifierDehumidifierState;
837
+ }
838
+ if (this.CurrentHumidifierDehumidifierState === undefined) {
839
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
840
+ }
841
+ else {
842
+ this.CurrentHumidifierDehumidifierState = this.accessory.context.CurrentHumidifierDehumidifierState;
843
+ }
844
+ if (this.RelativeHumidityHumidifierThreshold === undefined) {
845
+ this.RelativeHumidityHumidifierThreshold = 0;
846
+ }
847
+ else {
848
+ this.RelativeHumidityHumidifierThreshold = this.accessory.context.RelativeHumidityHumidifierThreshold;
849
+ }
850
+ if (this.WaterLevel === undefined) {
851
+ this.WaterLevel = 0;
852
+ }
853
+ else {
854
+ this.WaterLevel = this.accessory.context.WaterLevel;
855
+ }
856
+ }
857
+ async refreshRate(device) {
858
+ if (device.refreshRate) {
859
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
860
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
861
+ }
862
+ else if (this.platform.config.options.refreshRate) {
863
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
864
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
865
+ }
762
866
  }
763
867
  async config(device) {
764
868
  let config = {};
765
869
  if (device.humidifier) {
766
870
  config = device.humidifier;
767
871
  }
768
- if (device.ble !== undefined) {
769
- config['ble'] = device.ble;
872
+ if (device.connectionType !== undefined) {
873
+ config['connectionType'] = device.connectionType;
770
874
  }
771
875
  if (device.logging !== undefined) {
772
876
  config['logging'] = device.logging;
@@ -781,75 +885,26 @@ class Humidifier {
781
885
  config['offline'] = device.offline;
782
886
  }
783
887
  if (Object.entries(config).length !== 0) {
784
- this.infoLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
785
- }
786
- }
787
- async refreshRate(device) {
788
- if (device.refreshRate) {
789
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
790
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
791
- }
792
- else if (this.platform.config.options.refreshRate) {
793
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
794
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
795
- }
796
- }
797
- async scan(device) {
798
- if (device.scanDuration) {
799
- this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
800
- if (device.ble) {
801
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
802
- }
803
- }
804
- else {
805
- this.scanDuration = this.accessory.context.scanDuration = 1;
806
- if (this.device.ble) {
807
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
808
- }
888
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${(0, super_stringify_1.default)(config)}`);
809
889
  }
810
890
  }
811
891
  async logs(device) {
812
892
  if (this.platform.debugMode) {
813
893
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
814
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
894
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
815
895
  }
816
896
  else if (device.logging) {
817
897
  this.deviceLogging = this.accessory.context.logging = device.logging;
818
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
898
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
819
899
  }
820
900
  else if (this.platform.config.options?.logging) {
821
901
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
822
- this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
902
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
823
903
  }
824
904
  else {
825
905
  this.deviceLogging = this.accessory.context.logging = 'standard';
826
- this.debugLog(`Humidifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
827
- }
828
- }
829
- FirmwareRevision(accessory, device) {
830
- let FirmwareRevision;
831
- this.debugLog(`Humidifier: ${this.accessory.displayName} accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
832
- this.debugLog(`Humidifier: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
833
- this.debugLog(`Humidifier: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
834
- if (accessory.context.FirmwareRevision) {
835
- FirmwareRevision = accessory.context.FirmwareRevision;
836
- }
837
- else if (device.firmware) {
838
- FirmwareRevision = device.firmware;
839
- }
840
- else {
841
- FirmwareRevision = this.platform.version;
842
- }
843
- return FirmwareRevision;
844
- }
845
- minStep() {
846
- if (this.device.humidifier?.set_minStep) {
847
- this.set_minStep = this.device.humidifier?.set_minStep;
906
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
848
907
  }
849
- else {
850
- this.set_minStep = 1;
851
- }
852
- return this.set_minStep;
853
908
  }
854
909
  /**
855
910
  * Logging for Device