@switchbot/homebridge-switchbot 1.8.3-beta.0 → 1.10.1-beta.0

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 (122) hide show
  1. package/.eslintrc +14 -45
  2. package/.github/ISSUE_TEMPLATE/bug-report.yml +3 -3
  3. package/.github/ISSUE_TEMPLATE/feature-request.yml +2 -2
  4. package/.github/ISSUE_TEMPLATE/support-request.yml +3 -3
  5. package/.github/labeler.yml +1 -1
  6. package/.github/workflows/codeql-analysis.yml +29 -29
  7. package/.github/workflows/nodejs-beta.yml +1 -1
  8. package/.github/workflows/prerelease-beta.js +1 -1
  9. package/.github/workflows/stale.yml +1 -1
  10. package/.prettierrc +9 -0
  11. package/.vscode/extensions.json +2 -4
  12. package/.vscode/settings.json +14 -2
  13. package/CHANGELOG.md +16 -0
  14. package/README.md +100 -99
  15. package/SECURITY.md +2 -2
  16. package/config.schema.json +17 -0
  17. package/dist/devices/bots.d.ts +35 -32
  18. package/dist/devices/bots.d.ts.map +1 -1
  19. package/dist/devices/bots.js +168 -210
  20. package/dist/devices/bots.js.map +1 -1
  21. package/dist/devices/colorbulb.d.ts +35 -35
  22. package/dist/devices/colorbulb.d.ts.map +1 -1
  23. package/dist/devices/colorbulb.js +83 -108
  24. package/dist/devices/colorbulb.js.map +1 -1
  25. package/dist/devices/contact.d.ts +27 -25
  26. package/dist/devices/contact.d.ts.map +1 -1
  27. package/dist/devices/contact.js +110 -131
  28. package/dist/devices/contact.js.map +1 -1
  29. package/dist/devices/curtains.d.ts +29 -27
  30. package/dist/devices/curtains.d.ts.map +1 -1
  31. package/dist/devices/curtains.js +147 -182
  32. package/dist/devices/curtains.js.map +1 -1
  33. package/dist/devices/humidifiers.d.ts +31 -31
  34. package/dist/devices/humidifiers.d.ts.map +1 -1
  35. package/dist/devices/humidifiers.js +154 -181
  36. package/dist/devices/humidifiers.js.map +1 -1
  37. package/dist/devices/meters.d.ts +29 -28
  38. package/dist/devices/meters.d.ts.map +1 -1
  39. package/dist/devices/meters.js +98 -120
  40. package/dist/devices/meters.js.map +1 -1
  41. package/dist/devices/motion.d.ts +24 -23
  42. package/dist/devices/motion.d.ts.map +1 -1
  43. package/dist/devices/motion.js +97 -113
  44. package/dist/devices/motion.js.map +1 -1
  45. package/dist/devices/plugs.d.ts +16 -16
  46. package/dist/devices/plugs.d.ts.map +1 -1
  47. package/dist/devices/plugs.js +48 -71
  48. package/dist/devices/plugs.js.map +1 -1
  49. package/dist/index.d.ts +2 -2
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +3 -22
  52. package/dist/index.js.map +1 -1
  53. package/dist/irdevices/airconditioners.d.ts +7 -4
  54. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  55. package/dist/irdevices/airconditioners.js +72 -93
  56. package/dist/irdevices/airconditioners.js.map +1 -1
  57. package/dist/irdevices/airpurifiers.d.ts +3 -3
  58. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  59. package/dist/irdevices/airpurifiers.js +32 -51
  60. package/dist/irdevices/airpurifiers.js.map +1 -1
  61. package/dist/irdevices/cameras.d.ts +3 -3
  62. package/dist/irdevices/cameras.d.ts.map +1 -1
  63. package/dist/irdevices/cameras.js +19 -26
  64. package/dist/irdevices/cameras.js.map +1 -1
  65. package/dist/irdevices/fans.d.ts +3 -3
  66. package/dist/irdevices/fans.d.ts.map +1 -1
  67. package/dist/irdevices/fans.js +35 -44
  68. package/dist/irdevices/fans.js.map +1 -1
  69. package/dist/irdevices/lights.d.ts +3 -3
  70. package/dist/irdevices/lights.d.ts.map +1 -1
  71. package/dist/irdevices/lights.js +25 -32
  72. package/dist/irdevices/lights.js.map +1 -1
  73. package/dist/irdevices/others.d.ts +3 -3
  74. package/dist/irdevices/others.d.ts.map +1 -1
  75. package/dist/irdevices/others.js +21 -29
  76. package/dist/irdevices/others.js.map +1 -1
  77. package/dist/irdevices/tvs.d.ts +3 -3
  78. package/dist/irdevices/tvs.d.ts.map +1 -1
  79. package/dist/irdevices/tvs.js +66 -89
  80. package/dist/irdevices/tvs.js.map +1 -1
  81. package/dist/irdevices/vacuumcleaners.d.ts +3 -3
  82. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  83. package/dist/irdevices/vacuumcleaners.js +18 -24
  84. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  85. package/dist/irdevices/waterheaters.d.ts +3 -3
  86. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  87. package/dist/irdevices/waterheaters.js +19 -26
  88. package/dist/irdevices/waterheaters.js.map +1 -1
  89. package/dist/platform.d.ts +10 -10
  90. package/dist/platform.d.ts.map +1 -1
  91. package/dist/platform.js +163 -233
  92. package/dist/platform.js.map +1 -1
  93. package/dist/settings.d.ts +3 -1
  94. package/dist/settings.d.ts.map +1 -1
  95. package/dist/settings.js +4 -4
  96. package/dist/settings.js.map +1 -1
  97. package/homebridge-ui/public/index.html +231 -245
  98. package/homebridge-ui/server.js +2 -4
  99. package/nodemon.json +2 -4
  100. package/package.json +17 -12
  101. package/src/devices/bots.ts +411 -854
  102. package/src/devices/colorbulb.ts +187 -408
  103. package/src/devices/contact.ts +210 -376
  104. package/src/devices/curtains.ts +288 -563
  105. package/src/devices/humidifiers.ts +291 -537
  106. package/src/devices/meters.ts +189 -331
  107. package/src/devices/motion.ts +188 -322
  108. package/src/devices/plugs.ts +88 -160
  109. package/src/index.ts +5 -5
  110. package/src/irdevices/airconditioners.ts +139 -318
  111. package/src/irdevices/airpurifiers.ts +71 -170
  112. package/src/irdevices/cameras.ts +44 -103
  113. package/src/irdevices/fans.ts +70 -165
  114. package/src/irdevices/lights.ts +49 -104
  115. package/src/irdevices/others.ts +55 -131
  116. package/src/irdevices/tvs.ts +114 -247
  117. package/src/irdevices/vacuumcleaners.ts +44 -104
  118. package/src/irdevices/waterheaters.ts +49 -121
  119. package/src/platform.ts +341 -753
  120. package/src/settings.ts +8 -11
  121. package/tsconfig.json +5 -14
  122. package/.github/PULL_REQUEST_TEMPLATE/pull_requests.md +0 -27
@@ -1,9 +1,9 @@
1
- import * as axios from "axios";
2
- import * as rxjs from "rxjs";
3
- import * as platform_1 from "../platform";
4
- import * as operators from "rxjs/operators";
5
- import * as homebridge from "homebridge";
6
- import * as settings from "../settings";
1
+ import { AxiosResponse } from 'axios';
2
+ import { interval, Subject } from 'rxjs';
3
+ import { SwitchBotPlatform } from '../platform';
4
+ import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
5
+ import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
6
+ import { DeviceURL, device, devicesConfig, serviceData, ad, deviceStatusResponse, payload, deviceStatus } from '../settings';
7
7
 
8
8
  /**
9
9
  * Platform Accessory
@@ -12,34 +12,33 @@ import * as settings from "../settings";
12
12
  */
13
13
  export class Humidifier {
14
14
  // Services
15
- private service: homebridge.Service;
16
- temperatureservice?: homebridge.Service;
15
+ private service: Service;
16
+ temperatureservice?: Service;
17
17
 
18
18
  // Characteristic Values
19
- CurrentRelativeHumidity!: homebridge.CharacteristicValue;
20
- CurrentTemperature!: homebridge.CharacteristicValue;
21
- TargetHumidifierDehumidifierState!: homebridge.CharacteristicValue;
22
- CurrentHumidifierDehumidifierState!: homebridge.CharacteristicValue;
23
- RelativeHumidityHumidifierThreshold!: homebridge.CharacteristicValue;
24
- Active!: homebridge.CharacteristicValue;
25
- WaterLevel!: homebridge.CharacteristicValue;
19
+ CurrentRelativeHumidity!: CharacteristicValue;
20
+ CurrentTemperature!: CharacteristicValue;
21
+ TargetHumidifierDehumidifierState!: CharacteristicValue;
22
+ CurrentHumidifierDehumidifierState!: CharacteristicValue;
23
+ RelativeHumidityHumidifierThreshold!: CharacteristicValue;
24
+ Active!: CharacteristicValue;
25
+ WaterLevel!: CharacteristicValue;
26
26
 
27
27
  // OpenAPI
28
- auto: settings.deviceStatus["auto"];
29
- power: settings.deviceStatus["power"];
30
- humidity: settings.deviceStatus["humidity"];
31
- lackWater: settings.deviceStatus["lackWater"];
32
- temperature: settings.deviceStatus["temperature"];
33
- nebulizationEfficiency: settings.deviceStatus["nebulizationEfficiency"];
34
- deviceStatus!: settings.deviceStatusResponse;
28
+ auto: deviceStatus['auto'];
29
+ power: deviceStatus['power'];
30
+ humidity: deviceStatus['humidity'];
31
+ lackWater: deviceStatus['lackWater'];
32
+ temperature: deviceStatus['temperature'];
33
+ nebulizationEfficiency: deviceStatus['nebulizationEfficiency'];
34
+ deviceStatus!: deviceStatusResponse;
35
35
 
36
36
  // BLE Others
37
37
  connected?: boolean;
38
- SwitchToOpenAPI?: boolean;
39
- serviceData!: settings.serviceData;
40
- onState!: settings.serviceData["onState"];
41
- autoMode!: settings.serviceData["autoMode"];
42
- percentage!: settings.serviceData["percentage"];
38
+ serviceData!: serviceData;
39
+ onState!: serviceData['onState'];
40
+ autoMode!: serviceData['autoMode'];
41
+ percentage!: serviceData['percentage'];
43
42
 
44
43
  // Config
45
44
  set_minStep?: number;
@@ -49,30 +48,30 @@ export class Humidifier {
49
48
 
50
49
  // Updates
51
50
  humidifierUpdateInProgress!: boolean;
52
- doHumidifierUpdate!: rxjs.Subject<void>;
51
+ doHumidifierUpdate!: Subject<void>;
53
52
 
54
- constructor(
55
- private readonly platform: platform_1.SwitchBotPlatform,
56
- private accessory: homebridge.PlatformAccessory,
57
- public device: settings.device & settings.devicesConfig,
58
- ) {
53
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
59
54
  // default placeholders
60
55
  this.logs(device);
61
56
  this.scan(device);
62
57
  this.refreshRate(device);
63
58
  this.config(device);
64
59
  this.CurrentRelativeHumidity = 0;
65
- this.TargetHumidifierDehumidifierState =
66
- this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
67
- this.CurrentHumidifierDehumidifierState =
68
- this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
60
+ this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
61
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
69
62
  this.Active = this.platform.Characteristic.Active.ACTIVE;
70
63
  this.RelativeHumidityHumidifierThreshold = 0;
71
64
  this.CurrentTemperature = 0;
72
65
  this.WaterLevel = 0;
73
66
 
67
+ // Humidifiers Config
68
+ this.debugLog(
69
+ `Humidifier: ${this.accessory.displayName} Config: (ble: ${device.ble}, offline: ${device.offline}, hide_temperature: ` +
70
+ `${device.humidifier?.hide_temperature}, set_minStep: ${device.humidifier?.set_minStep})`,
71
+ );
72
+
74
73
  // this is subject we use to track when we need to POST changes to the SwitchBot API
75
- this.doHumidifierUpdate = new rxjs.Subject();
74
+ this.doHumidifierUpdate = new Subject();
76
75
  this.humidifierUpdateInProgress = false;
77
76
 
78
77
  // Retrieve initial values and updateHomekit
@@ -81,21 +80,14 @@ export class Humidifier {
81
80
  // set accessory information
82
81
  accessory
83
82
  .getService(this.platform.Service.AccessoryInformation)!
84
- .setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
85
- .setCharacteristic(
86
- this.platform.Characteristic.Model,
87
- "SWITCHBOT-HUMIDIFIER-W0801800",
88
- )
89
- .setCharacteristic(
90
- this.platform.Characteristic.SerialNumber,
91
- device.deviceId!,
92
- );
83
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
84
+ .setCharacteristic(this.platform.Characteristic.Model, 'SWITCHBOT-HUMIDIFIER-W0801800')
85
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
93
86
 
94
87
  // get the LightBulb service if it exists, otherwise create a new LightBulb service
95
88
  // you can create multiple services for each accessory
96
89
  (this.service =
97
- accessory.getService(this.platform.Service.HumidifierDehumidifier) ||
98
- accessory.addService(this.platform.Service.HumidifierDehumidifier)),
90
+ accessory.getService(this.platform.Service.HumidifierDehumidifier) || accessory.addService(this.platform.Service.HumidifierDehumidifier)),
99
91
  `${accessory.displayName} Humidifier`;
100
92
 
101
93
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
@@ -104,24 +96,16 @@ export class Humidifier {
104
96
 
105
97
  // set the service name, this is what is displayed as the default name on the Home app
106
98
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
107
- this.service.setCharacteristic(
108
- this.platform.Characteristic.Name,
109
- accessory.displayName,
110
- );
99
+ this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
111
100
 
112
101
  // each service must implement at-minimum the "required characteristics" for the given service type
113
102
  // see https://developers.homebridge.io/#/service/HumidifierDehumidifier
114
103
 
115
104
  // create handlers for required characteristics
116
- this.service.setCharacteristic(
117
- this.platform.Characteristic.CurrentHumidifierDehumidifierState,
118
- this.CurrentHumidifierDehumidifierState,
119
- );
105
+ this.service.setCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, this.CurrentHumidifierDehumidifierState);
120
106
 
121
107
  this.service
122
- .getCharacteristic(
123
- this.platform.Characteristic.TargetHumidifierDehumidifierState,
124
- )
108
+ .getCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState)
125
109
  .setProps({
126
110
  validValueRanges: [0, 1],
127
111
  minValue: 0,
@@ -130,14 +114,10 @@ export class Humidifier {
130
114
  })
131
115
  .onSet(this.handleTargetHumidifierDehumidifierStateSet.bind(this));
132
116
 
133
- this.service
134
- .getCharacteristic(this.platform.Characteristic.Active)
135
- .onSet(this.handleActiveSet.bind(this));
117
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.handleActiveSet.bind(this));
136
118
 
137
119
  this.service
138
- .getCharacteristic(
139
- this.platform.Characteristic.RelativeHumidityHumidifierThreshold,
140
- )
120
+ .getCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold)
141
121
  .setProps({
142
122
  validValueRanges: [0, 100],
143
123
  minValue: 0,
@@ -149,26 +129,16 @@ export class Humidifier {
149
129
  // create a new Temperature Sensor service
150
130
  // Temperature Sensor Service
151
131
  if (device.humidifier?.hide_temperature || device.ble) {
152
- this.debugLog(
153
- `Humidifier: ${accessory.displayName} Removing Temperature Sensor Service`,
154
- );
155
- this.temperatureservice = this.accessory.getService(
156
- this.platform.Service.TemperatureSensor,
157
- );
132
+ this.debugLog(`Humidifier: ${accessory.displayName} Removing Temperature Sensor Service`);
133
+ this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor);
158
134
  accessory.removeService(this.temperatureservice!);
159
135
  } else if (!this.temperatureservice && !device.ble) {
160
- this.debugLog(
161
- `Humidifier: ${accessory.displayName} Add Temperature Sensor Service`,
162
- );
136
+ this.debugLog(`Humidifier: ${accessory.displayName} Add Temperature Sensor Service`);
163
137
  (this.temperatureservice =
164
- this.accessory.getService(this.platform.Service.TemperatureSensor) ||
165
- this.accessory.addService(this.platform.Service.TemperatureSensor)),
138
+ this.accessory.getService(this.platform.Service.TemperatureSensor) || this.accessory.addService(this.platform.Service.TemperatureSensor)),
166
139
  `${accessory.displayName} Temperature Sensor`;
167
140
 
168
- this.temperatureservice.setCharacteristic(
169
- this.platform.Characteristic.Name,
170
- `${accessory.displayName} Temperature Sensor`,
171
- );
141
+ this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
172
142
 
173
143
  this.temperatureservice
174
144
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
@@ -182,18 +152,15 @@ export class Humidifier {
182
152
  return this.CurrentTemperature;
183
153
  });
184
154
  } else {
185
- this.debugLog(
186
- `Humidifier: ${accessory.displayName} Temperature Sensor Service Not Added`,
187
- );
155
+ this.debugLog(`Humidifier: ${accessory.displayName} Temperature Sensor Service Not Added`);
188
156
  }
189
157
 
190
158
  // Retrieve initial values and updateHomekit
191
159
  this.updateHomeKitCharacteristics();
192
160
 
193
161
  // Start an update interval
194
- rxjs
195
- .interval(this.deviceRefreshRate * 1000)
196
- .pipe(operators.skipWhile(() => this.humidifierUpdateInProgress))
162
+ interval(this.deviceRefreshRate * 1000)
163
+ .pipe(skipWhile(() => this.humidifierUpdateInProgress))
197
164
  .subscribe(() => {
198
165
  this.refreshStatus();
199
166
  });
@@ -202,23 +169,21 @@ export class Humidifier {
202
169
  // We put in a debounce of 100ms so we don't make duplicate calls
203
170
  this.doHumidifierUpdate
204
171
  .pipe(
205
- operators.tap(() => {
172
+ tap(() => {
206
173
  this.humidifierUpdateInProgress = true;
207
174
  }),
208
- operators.debounceTime(this.platform.config.options!.pushRate! * 1000),
175
+ debounceTime(this.platform.config.options!.pushRate! * 1000),
209
176
  )
210
177
  .subscribe(async () => {
211
178
  try {
212
179
  await this.pushChanges();
213
180
  } catch (e: any) {
214
- this.errorLog(
215
- `Humidifier: ${this.accessory.displayName} failed pushChanges`,
216
- );
217
- if (this.deviceLogging.includes("debug")) {
218
- this.errorLog(
219
- `Humidifier: ${this.accessory.displayName} failed pushChanges,` +
220
- ` Error Message: ${JSON.stringify(e.message)}`,
221
- );
181
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges`);
182
+ if (this.deviceLogging === 'debug') {
183
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
184
+ }
185
+ if (this.platform.debugMode) {
186
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
222
187
  }
223
188
  this.apiError(e);
224
189
  }
@@ -229,7 +194,7 @@ export class Humidifier {
229
194
  /**
230
195
  * Parse the device status from the SwitchBot api
231
196
  */
232
- parseStatus(): void {
197
+ parseStatus() {
233
198
  if (this.device.ble) {
234
199
  this.BLEparseStatus();
235
200
  } else {
@@ -237,106 +202,74 @@ export class Humidifier {
237
202
  }
238
203
  }
239
204
 
240
- private BLEparseStatus(): void {
205
+ private BLEparseStatus() {
241
206
  this.debugLog(`Humidifier: ${this.accessory.displayName} BLE parseStatus`);
242
207
  // Current Relative Humidity
243
208
  this.CurrentRelativeHumidity = this.percentage!;
244
- this.debugLog(
245
- `Humidifier: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
246
- );
209
+ this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
247
210
  // Active
248
211
  if (this.onState) {
249
212
  this.Active = this.platform.Characteristic.Active.ACTIVE;
250
213
  } else {
251
214
  this.Active = this.platform.Characteristic.Active.INACTIVE;
252
215
  }
253
- this.debugLog(
254
- `Humidifier: ${this.accessory.displayName} Active: ${this.Active}`,
255
- );
216
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Active: ${this.Active}`);
256
217
  }
257
218
 
258
219
  private openAPIparseStatus() {
259
220
  if (this.platform.config.credentials?.openToken) {
260
- this.debugLog(
261
- `Humidifier: ${this.accessory.displayName} OpenAPI parseStatus`,
262
- );
221
+ this.debugLog(`Humidifier: ${this.accessory.displayName} OpenAPI parseStatus`);
263
222
  // Current Relative Humidity
264
223
  this.CurrentRelativeHumidity = this.humidity!;
265
- this.debugLog(
266
- `Humidifier: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
267
- );
224
+ this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
268
225
  // Current Temperature
269
226
  if (!this.device.humidifier?.hide_temperature) {
270
227
  this.CurrentTemperature = this.temperature!;
271
- this.debugLog(
272
- `Humidifier: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`,
273
- );
228
+ this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
274
229
  }
275
230
  // Target Humidifier Dehumidifier State
276
231
  switch (this.auto) {
277
232
  case true:
278
- this.TargetHumidifierDehumidifierState =
279
- this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
280
- this.CurrentHumidifierDehumidifierState =
281
- this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
282
- this.RelativeHumidityHumidifierThreshold =
283
- this.CurrentRelativeHumidity;
233
+ this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
234
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
235
+ this.RelativeHumidityHumidifierThreshold = this.CurrentRelativeHumidity;
284
236
  break;
285
237
  default:
286
- this.TargetHumidifierDehumidifierState =
287
- this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
238
+ this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
288
239
  if (this.nebulizationEfficiency! > 100) {
289
240
  this.RelativeHumidityHumidifierThreshold = 100;
290
241
  } else {
291
- this.RelativeHumidityHumidifierThreshold =
292
- this.nebulizationEfficiency!;
242
+ this.RelativeHumidityHumidifierThreshold = this.nebulizationEfficiency!;
293
243
  }
294
- if (
295
- this.CurrentRelativeHumidity >
296
- this.RelativeHumidityHumidifierThreshold
297
- ) {
298
- this.CurrentHumidifierDehumidifierState =
299
- this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
300
- } else if (
301
- this.Active === this.platform.Characteristic.Active.INACTIVE
302
- ) {
303
- this.CurrentHumidifierDehumidifierState =
304
- this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
244
+ if (this.CurrentRelativeHumidity > this.RelativeHumidityHumidifierThreshold) {
245
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
246
+ } else if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
247
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
305
248
  } else {
306
- this.CurrentHumidifierDehumidifierState =
307
- this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
249
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
308
250
  }
309
251
  }
252
+ this.debugLog(`Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
310
253
  this.debugLog(
311
- `Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`,
312
- );
313
- this.debugLog(
314
- `Humidifier: ${this.accessory.displayName}` +
315
- ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`,
316
- );
317
- this.debugLog(
318
- `Humidifier: ${this.accessory.displayName} CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`,
254
+ `Humidifier: ${this.accessory.displayName}` + ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`,
319
255
  );
256
+ this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
320
257
  // Active
321
258
  switch (this.power) {
322
- case "on":
259
+ case 'on':
323
260
  this.Active = this.platform.Characteristic.Active.ACTIVE;
324
261
  break;
325
262
  default:
326
263
  this.Active = this.platform.Characteristic.Active.INACTIVE;
327
264
  }
328
- this.debugLog(
329
- `Humidifier: ${this.accessory.displayName} Active: ${this.Active}`,
330
- );
265
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Active: ${this.Active}`);
331
266
  // Water Level
332
267
  if (this.lackWater) {
333
268
  this.WaterLevel = 0;
334
269
  } else {
335
270
  this.WaterLevel = 100;
336
271
  }
337
- this.debugLog(
338
- `Humidifier: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`,
339
- );
272
+ this.debugLog(`Humidifier: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
340
273
  }
341
274
  }
342
275
 
@@ -352,139 +285,113 @@ export class Humidifier {
352
285
  }
353
286
 
354
287
  private async BLERefreshStatus() {
355
- this.debugLog(
356
- `Humidifier: ${this.accessory.displayName} BLE refreshStatus`,
357
- );
288
+ this.debugLog(`Humidifier: ${this.accessory.displayName} BLE refreshStatus`);
358
289
  const switchbot = await this.platform.connectBLE();
359
290
  // Convert to BLE Address
360
291
  this.device.bleMac = this.device
361
292
  .deviceId!.match(/.{1,2}/g)!
362
- .join(":")
293
+ .join(':')
363
294
  .toLowerCase();
364
- this.debugLog(
365
- `Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`,
366
- );
367
- try {
368
- await switchbot.discover({
369
- model: "e",
370
- quick: false,
371
- });
372
- // Start to monitor advertisement packets
373
- await switchbot.startScan({
374
- model: "e",
375
- id: this.device.bleMac,
376
- });
377
- // Set an event hander
378
- switchbot.onadvertisement = (ad: settings.ad) => {
379
- this.serviceData = ad.serviceData;
380
- this.autoMode = ad.serviceData.autoMode;
381
- this.onState = ad.serviceData.onState;
382
- this.percentage = ad.serviceData.percentage;
383
- this.debugLog(
384
- `Humidifier: ${
385
- this.accessory.displayName
386
- } serviceData: ${JSON.stringify(ad.serviceData)}`,
387
- );
388
- this.debugLog(
389
- `Humidifier: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
390
- `autoMode: ${ad.serviceData.autoMode}, onState: ${ad.serviceData.onState}, percentage: ${ad.serviceData.percentage}`,
391
- );
295
+ this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
296
+ // Start to monitor advertisement packets
297
+ if (switchbot !== false) {
298
+ switchbot
299
+ .startScan({
300
+ model: 'e',
301
+ id: this.device.bleMac,
302
+ })
303
+ .then(() => {
304
+ // Set an event hander
305
+ switchbot.onadvertisement = (ad: ad) => {
306
+ this.serviceData = ad.serviceData;
307
+ this.autoMode = ad.serviceData.autoMode;
308
+ this.onState = ad.serviceData.onState;
309
+ this.percentage = ad.serviceData.percentage;
310
+ this.debugLog(`Humidifier: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
311
+ this.debugLog(
312
+ `Humidifier: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
313
+ `autoMode: ${ad.serviceData.autoMode}, onState: ${ad.serviceData.onState}, percentage: ${ad.serviceData.percentage}`,
314
+ );
392
315
 
393
- if (this.serviceData) {
394
- this.connected = true;
395
- this.debugLog(
396
- `Humidifier: ${this.accessory.displayName} connected: ${this.connected}`,
397
- );
398
- } else {
399
- this.connected = false;
400
- this.debugLog(
401
- `Humidifier: ${this.accessory.displayName} connected: ${this.connected}`,
402
- );
403
- }
404
- };
405
- // Wait 2 seconds
406
- await switchbot.wait(this.scanDuration * 1000);
407
- // Stop to monitor
408
- switchbot.stopScan();
409
- if (this.connected) {
410
- this.parseStatus();
411
- this.updateHomeKitCharacteristics();
412
- } else {
413
- this.errorLog(
414
- `Humidifier: ${this.accessory.displayName} wasn't able to establish BLE Connection`,
415
- );
416
- if (this.platform.config.credentials?.openToken) {
417
- this.warnLog(
418
- `Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`,
419
- );
420
- this.SwitchToOpenAPI = true;
421
- await this.openAPIRefreshStatus();
422
- }
423
- }
424
- } catch (e: any) {
425
- this.errorLog(
426
- `Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection`,
427
- );
428
- if (this.deviceLogging.includes("debug")) {
429
- this.errorLog(
430
- `Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` +
431
- ` Error Message: ${JSON.stringify(e.message)}`,
432
- );
433
- }
434
- if (this.platform.config.credentials?.openToken) {
435
- this.warnLog(
436
- `Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`,
437
- );
438
- this.SwitchToOpenAPI = true;
439
- await this.openAPIRefreshStatus();
440
- }
441
- this.apiError(e);
316
+ if (this.serviceData) {
317
+ this.connected = true;
318
+ this.debugLog(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
319
+ } else {
320
+ this.connected = false;
321
+ this.debugLog(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
322
+ }
323
+ };
324
+ // Wait 2 seconds
325
+ return switchbot.wait(this.scanDuration * 1000);
326
+ })
327
+ .then(async () => {
328
+ // Stop to monitor
329
+ switchbot.stopScan();
330
+ if (this.connected) {
331
+ this.parseStatus();
332
+ this.updateHomeKitCharacteristics();
333
+ } else {
334
+ await this.BLEconnection(switchbot);
335
+ }
336
+ })
337
+ .catch(async (e: any) => {
338
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
339
+ if (this.deviceLogging === 'debug') {
340
+ this.errorLog(
341
+ `Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
342
+ );
343
+ }
344
+ if (this.platform.debugMode) {
345
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
346
+ }
347
+ if (this.platform.config.credentials?.openToken) {
348
+ this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
349
+ await this.openAPIRefreshStatus();
350
+ }
351
+ this.apiError(e);
352
+ });
353
+ } else {
354
+ await this.BLEconnection(switchbot);
355
+ }
356
+ }
357
+
358
+ public async BLEconnection(switchbot: any) {
359
+ this.errorLog(`Humidifier: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
360
+ if (this.platform.config.credentials?.openToken) {
361
+ this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
362
+ await this.openAPIRefreshStatus();
442
363
  }
443
364
  }
444
365
 
445
366
  private async openAPIRefreshStatus() {
446
367
  if (this.platform.config.credentials?.openToken) {
447
- this.debugLog(
448
- `Humidifier: ${this.accessory.displayName} OpenAPI refreshStatus`,
449
- );
368
+ this.debugLog(`Humidifier: ${this.accessory.displayName} OpenAPI refreshStatus`);
450
369
  try {
451
- this.deviceStatus = (
452
- await this.platform.axios.get(
453
- `${settings.DeviceURL}/${this.device.deviceId}/status`,
454
- )
455
- ).data;
456
- if (this.deviceStatus.message === "success") {
457
- this.debugLog(
458
- `Humidifier: ${
459
- this.accessory.displayName
460
- } refreshStatus: ${JSON.stringify(this.deviceStatus)}`,
461
- );
370
+ this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
371
+ if (this.deviceStatus.message === 'success') {
372
+ this.debugLog(`Humidifier: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
462
373
  this.auto = this.deviceStatus.body.auto;
463
374
  this.power = this.deviceStatus.body.power;
464
375
  this.lackWater = this.deviceStatus.body.lackWater;
465
376
  this.humidity = this.deviceStatus.body.humidity;
466
377
  this.temperature = this.deviceStatus.body.temperature;
467
- this.nebulizationEfficiency =
468
- this.deviceStatus.body.nebulizationEfficiency;
378
+ this.nebulizationEfficiency = this.deviceStatus.body.nebulizationEfficiency;
469
379
  this.parseStatus();
470
380
  this.updateHomeKitCharacteristics();
471
381
  } else {
472
- this.errorLog(
473
- `Humidifier: ${
474
- this.accessory.displayName
475
- } message: ${JSON.stringify(this.deviceStatus.message)}`,
476
- );
382
+ this.errorLog(`Humidifier: ${this.accessory.displayName} message: ${JSON.stringify(this.deviceStatus.message)}`);
477
383
  }
478
384
  } catch (e: any) {
479
- this.errorLog(
480
- `Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`,
481
- );
482
- if (this.deviceLogging.includes("debug")) {
385
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
386
+ if (this.deviceLogging === 'debug') {
483
387
  this.errorLog(
484
388
  `Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
485
389
  ` Error Message: ${JSON.stringify(e.message)}`,
486
390
  );
487
391
  }
392
+ if (this.platform.debugMode) {
393
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
394
+ }
488
395
  this.apiError(e);
489
396
  }
490
397
  }
@@ -499,10 +406,9 @@ export class Humidifier {
499
406
  //} else {
500
407
  await this.openAPIpushChanges();
501
408
  //}
502
- rxjs
503
- .interval(5000)
504
- .pipe(operators.skipWhile(() => this.humidifierUpdateInProgress))
505
- .pipe(operators.take(1))
409
+ interval(5000)
410
+ .pipe(skipWhile(() => this.humidifierUpdateInProgress))
411
+ .pipe(take(1))
506
412
  .subscribe(() => {
507
413
  this.refreshStatus();
508
414
  });
@@ -514,51 +420,39 @@ export class Humidifier {
514
420
  // Convert to BLE Address
515
421
  this.device.bleMac = this.device
516
422
  .deviceId!.match(/.{1,2}/g)!
517
- .join(":")
423
+ .join(':')
518
424
  .toLowerCase();
519
- this.debugLog(
520
- `Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`,
521
- );
425
+ this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
522
426
  if (switchbot !== false) {
523
427
  switchbot
524
- .discover({ model: "e", quick: true, id: this.device.bleMac })
428
+ .discover({ model: 'e', quick: true, id: this.device.bleMac })
525
429
  .then((device_list) => {
526
- this.infoLog(
527
- `${this.accessory.displayName} Target Position: ${this.Active}`,
528
- );
529
- return device_list[0].percentage(
530
- this.RelativeHumidityHumidifierThreshold,
531
- );
430
+ this.infoLog(`${this.accessory.displayName} Target Position: ${this.Active}`);
431
+ return device_list[0].percentage(this.RelativeHumidityHumidifierThreshold);
532
432
  })
533
433
  .then(() => {
534
434
  this.debugLog(`Humidifier: ${this.accessory.displayName} Done.`);
535
435
  })
536
436
  .catch(async (e: any) => {
537
- this.errorLog(
538
- `Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection`,
539
- );
540
- if (this.deviceLogging.includes("debug")) {
437
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
438
+ if (this.deviceLogging === 'debug') {
541
439
  this.errorLog(
542
- `Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,` +
543
- ` Error Message: ${JSON.stringify(e.message)}`,
440
+ `Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
544
441
  );
545
442
  }
443
+ if (this.platform.debugMode) {
444
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
445
+ }
546
446
  if (this.platform.config.credentials?.openToken) {
547
- this.warnLog(
548
- `Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`,
549
- );
447
+ this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
550
448
  await this.openAPIpushChanges();
551
449
  }
552
450
  this.apiError(e);
553
451
  });
554
452
  } else {
555
- this.errorLog(
556
- `Humidifier: ${this.accessory.displayName} wasn't able to establish BLE Connection`,
557
- );
453
+ this.errorLog(`Humidifier: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
558
454
  if (this.platform.config.credentials?.openToken) {
559
- this.warnLog(
560
- `Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`,
561
- );
455
+ this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
562
456
  await this.openAPIpushChanges();
563
457
  }
564
458
  }
@@ -566,24 +460,18 @@ export class Humidifier {
566
460
 
567
461
  private async openAPIpushChanges() {
568
462
  if (this.platform.config.credentials?.openToken) {
569
- this.debugLog(
570
- `Humidifier: ${this.accessory.displayName} OpenAPI pushChanges`,
571
- );
463
+ this.debugLog(`Humidifier: ${this.accessory.displayName} OpenAPI pushChanges`);
572
464
  if (
573
- this.TargetHumidifierDehumidifierState ===
574
- this.platform.Characteristic.TargetHumidifierDehumidifierState
575
- .HUMIDIFIER &&
465
+ this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER &&
576
466
  this.Active === this.platform.Characteristic.Active.ACTIVE
577
467
  ) {
578
468
  try {
579
- this.debugLog(
580
- `Pushing Manual: ${this.RelativeHumidityHumidifierThreshold}!`,
581
- );
469
+ this.debugLog(`Pushing Manual: ${this.RelativeHumidityHumidifierThreshold}!`);
582
470
  const payload = {
583
- commandType: "command",
584
- command: "setMode",
471
+ commandType: 'command',
472
+ command: 'setMode',
585
473
  parameter: `${this.RelativeHumidityHumidifierThreshold}`,
586
- } as settings.payload;
474
+ } as payload;
587
475
 
588
476
  this.infoLog(
589
477
  `Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -591,32 +479,24 @@ export class Humidifier {
591
479
  );
592
480
 
593
481
  // Make the API request
594
- const push: any = await this.platform.axios.post(
595
- `${settings.DeviceURL}/${this.device.deviceId}/commands`,
596
- payload,
597
- );
598
- this.debugLog(
599
- `Humidifier: ${
600
- this.accessory.displayName
601
- } pushChanges: ${JSON.stringify(push.data)}`,
602
- );
482
+ const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
483
+ this.debugLog(`Humidifier: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
603
484
  this.statusCode(push);
604
485
  } catch (e: any) {
605
- this.errorLog(
606
- `Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`,
607
- );
608
- if (this.deviceLogging.includes("debug")) {
486
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
487
+ if (this.deviceLogging === 'debug') {
609
488
  this.errorLog(
610
489
  `Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
611
490
  ` Error Message: ${JSON.stringify(e.message)}`,
612
491
  );
613
492
  }
493
+ if (this.platform.debugMode) {
494
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
495
+ }
614
496
  this.apiError(e);
615
497
  }
616
498
  } else if (
617
- this.TargetHumidifierDehumidifierState ===
618
- this.platform.Characteristic.TargetHumidifierDehumidifierState
619
- .HUMIDIFIER_OR_DEHUMIDIFIER &&
499
+ this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
620
500
  this.Active === this.platform.Characteristic.Active.ACTIVE
621
501
  ) {
622
502
  await this.pushAutoChanges();
@@ -632,17 +512,15 @@ export class Humidifier {
632
512
  async pushAutoChanges() {
633
513
  try {
634
514
  if (
635
- this.TargetHumidifierDehumidifierState ===
636
- this.platform.Characteristic.TargetHumidifierDehumidifierState
637
- .HUMIDIFIER_OR_DEHUMIDIFIER &&
515
+ this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
638
516
  this.Active === this.platform.Characteristic.Active.ACTIVE
639
517
  ) {
640
- this.debugLog("Pushing Auto!");
518
+ this.debugLog('Pushing Auto!');
641
519
  const payload = {
642
- commandType: "command",
643
- command: "setMode",
644
- parameter: "auto",
645
- } as settings.payload;
520
+ commandType: 'command',
521
+ command: 'setMode',
522
+ parameter: 'auto',
523
+ } as payload;
646
524
 
647
525
  this.infoLog(
648
526
  `Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -650,27 +528,21 @@ export class Humidifier {
650
528
  );
651
529
 
652
530
  // Make the API request
653
- const push: any = await this.platform.axios.post(
654
- `${settings.DeviceURL}/${this.device.deviceId}/commands`,
655
- payload,
656
- );
657
- this.debugLog(
658
- `Humidifier: ${
659
- this.accessory.displayName
660
- } pushAutoChanges: ${JSON.stringify(push.data)}`,
661
- );
531
+ const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
532
+ this.debugLog(`Humidifier: ${this.accessory.displayName} pushAutoChanges: ${JSON.stringify(push.data)}`);
662
533
  this.statusCode(push);
663
534
  }
664
535
  } catch (e: any) {
665
- this.errorLog(
666
- `Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection`,
667
- );
668
- if (this.deviceLogging.includes("debug")) {
536
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection`);
537
+ if (this.deviceLogging === 'debug') {
669
538
  this.errorLog(
670
539
  `Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,` +
671
540
  ` Error Message: ${JSON.stringify(e.message)}`,
672
541
  );
673
542
  }
543
+ if (this.platform.debugMode) {
544
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
545
+ }
674
546
  this.apiError(e);
675
547
  }
676
548
  }
@@ -681,12 +553,12 @@ export class Humidifier {
681
553
  async pushActiveChanges() {
682
554
  try {
683
555
  if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
684
- this.debugLog("Pushing Off!");
556
+ this.debugLog('Pushing Off!');
685
557
  const payload = {
686
- commandType: "command",
687
- command: "turnOff",
688
- parameter: "default",
689
- } as settings.payload;
558
+ commandType: 'command',
559
+ command: 'turnOff',
560
+ parameter: 'default',
561
+ } as payload;
690
562
 
691
563
  this.infoLog(
692
564
  `Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -694,27 +566,21 @@ export class Humidifier {
694
566
  );
695
567
 
696
568
  // Make the API request
697
- const push: any = await this.platform.axios.post(
698
- `${settings.DeviceURL}/${this.device.deviceId}/commands`,
699
- payload,
700
- );
701
- this.debugLog(
702
- `Humidifier: ${
703
- this.accessory.displayName
704
- } pushActiveChanges: ${JSON.stringify(push.data)}`,
705
- );
569
+ const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
570
+ this.debugLog(`Humidifier: ${this.accessory.displayName} pushActiveChanges: ${JSON.stringify(push.data)}`);
706
571
  this.statusCode(push);
707
572
  }
708
573
  } catch (e: any) {
709
- this.errorLog(
710
- `Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection`,
711
- );
712
- if (this.deviceLogging.includes("debug")) {
574
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection`);
575
+ if (this.deviceLogging === 'debug') {
713
576
  this.errorLog(
714
577
  `Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,` +
715
578
  ` Error Message: ${JSON.stringify(e.message)}`,
716
579
  );
717
580
  }
581
+ if (this.platform.debugMode) {
582
+ this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
583
+ }
718
584
  this.apiError(e);
719
585
  }
720
586
  }
@@ -724,85 +590,49 @@ export class Humidifier {
724
590
  */
725
591
  updateHomeKitCharacteristics() {
726
592
  if (this.CurrentRelativeHumidity === undefined) {
727
- this.debugLog(
728
- `Humidifier: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
729
- );
593
+ this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
730
594
  } else {
731
- this.service.updateCharacteristic(
732
- this.platform.Characteristic.CurrentRelativeHumidity,
733
- this.CurrentRelativeHumidity,
734
- );
735
- this.debugLog(
736
- `Humidifier: ${this.accessory.displayName}` +
737
- ` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
738
- );
595
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
596
+ this.debugLog(`Humidifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
739
597
  }
740
598
  if (!this.device.ble) {
741
599
  if (this.WaterLevel === undefined) {
742
- this.debugLog(
743
- `Humidifier: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`,
744
- );
600
+ this.debugLog(`Humidifier: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
745
601
  } else {
746
- this.service.updateCharacteristic(
747
- this.platform.Characteristic.WaterLevel,
748
- this.WaterLevel,
749
- );
750
- this.debugLog(
751
- `Humidifier: ${this.accessory.displayName} updateCharacteristic WaterLevel: ${this.WaterLevel}`,
752
- );
602
+ this.service.updateCharacteristic(this.platform.Characteristic.WaterLevel, this.WaterLevel);
603
+ this.debugLog(`Humidifier: ${this.accessory.displayName} updateCharacteristic WaterLevel: ${this.WaterLevel}`);
753
604
  }
754
605
  }
755
606
  if (this.CurrentHumidifierDehumidifierState === undefined) {
756
- this.debugLog(
757
- `Humidifier: ${this.accessory.displayName} CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`,
758
- );
607
+ this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
759
608
  } else {
760
- this.service.updateCharacteristic(
761
- this.platform.Characteristic.CurrentHumidifierDehumidifierState,
762
- this.CurrentHumidifierDehumidifierState,
763
- );
609
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, this.CurrentHumidifierDehumidifierState);
764
610
  this.debugLog(
765
611
  `Humidifier: ${this.accessory.displayName}` +
766
612
  ` updateCharacteristic CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`,
767
613
  );
768
614
  }
769
615
  if (this.TargetHumidifierDehumidifierState === undefined) {
770
- this.debugLog(
771
- `Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`,
772
- );
616
+ this.debugLog(`Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
773
617
  } else {
774
- this.service.updateCharacteristic(
775
- this.platform.Characteristic.TargetHumidifierDehumidifierState,
776
- this.TargetHumidifierDehumidifierState,
777
- );
618
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.TargetHumidifierDehumidifierState);
778
619
  this.debugLog(
779
620
  `Humidifier: ${this.accessory.displayName}` +
780
621
  ` updateCharacteristic TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`,
781
622
  );
782
623
  }
783
624
  if (this.Active === undefined) {
784
- this.debugLog(
785
- `Humidifier: ${this.accessory.displayName} Active: ${this.Active}`,
786
- );
625
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Active: ${this.Active}`);
787
626
  } else {
788
- this.service.updateCharacteristic(
789
- this.platform.Characteristic.Active,
790
- this.Active,
791
- );
792
- this.debugLog(
793
- `Humidifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
794
- );
627
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
628
+ this.debugLog(`Humidifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
795
629
  }
796
630
  if (this.RelativeHumidityHumidifierThreshold === undefined) {
797
631
  this.debugLog(
798
- `Humidifier: ${this.accessory.displayName}` +
799
- ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`,
632
+ `Humidifier: ${this.accessory.displayName}` + ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`,
800
633
  );
801
634
  } else {
802
- this.service.updateCharacteristic(
803
- this.platform.Characteristic.RelativeHumidityHumidifierThreshold,
804
- this.RelativeHumidityHumidifierThreshold,
805
- );
635
+ this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, this.RelativeHumidityHumidifierThreshold);
806
636
  this.debugLog(
807
637
  `Humidifier: ${this.accessory.displayName}` +
808
638
  ` updateCharacteristic RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`,
@@ -810,81 +640,46 @@ export class Humidifier {
810
640
  }
811
641
  if (!this.device.humidifier?.hide_temperature && !this.device.ble) {
812
642
  if (this.CurrentTemperature === undefined) {
813
- this.debugLog(
814
- `Humidifier: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`,
815
- );
643
+ this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
816
644
  } else {
817
- this.temperatureservice?.updateCharacteristic(
818
- this.platform.Characteristic.CurrentTemperature,
819
- this.CurrentTemperature,
820
- );
821
- this.debugLog(
822
- `Humidifier: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`,
823
- );
645
+ this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
646
+ this.debugLog(`Humidifier: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
824
647
  }
825
648
  }
826
649
  }
827
650
 
828
- public apiError(e: any): void {
829
- this.service.updateCharacteristic(
830
- this.platform.Characteristic.CurrentRelativeHumidity,
831
- e,
832
- );
651
+ public apiError(e: any) {
652
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
833
653
  if (!this.device.ble) {
834
- this.service.updateCharacteristic(
835
- this.platform.Characteristic.WaterLevel,
836
- e,
837
- );
654
+ this.service.updateCharacteristic(this.platform.Characteristic.WaterLevel, e);
838
655
  }
839
- this.service.updateCharacteristic(
840
- this.platform.Characteristic.CurrentHumidifierDehumidifierState,
841
- e,
842
- );
843
- this.service.updateCharacteristic(
844
- this.platform.Characteristic.TargetHumidifierDehumidifierState,
845
- e,
846
- );
656
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, e);
657
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, e);
847
658
  this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
848
- this.service.updateCharacteristic(
849
- this.platform.Characteristic.RelativeHumidityHumidifierThreshold,
850
- e,
851
- );
659
+ this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, e);
852
660
  if (!this.device.humidifier?.hide_temperature && !this.device.ble) {
853
- this.temperatureservice?.updateCharacteristic(
854
- this.platform.Characteristic.CurrentTemperature,
855
- e,
856
- );
661
+ this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
857
662
  }
858
663
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
859
664
  }
860
665
 
861
- private statusCode(push: axios.AxiosResponse<{ statusCode: number }>): void {
666
+ private statusCode(push: AxiosResponse<{ statusCode: number }>) {
862
667
  switch (push.data.statusCode) {
863
668
  case 151:
864
- this.errorLog(
865
- `Humidifier: ${this.accessory.displayName} Command not supported by this device type.`,
866
- );
669
+ this.errorLog(`Humidifier: ${this.accessory.displayName} Command not supported by this device type.`);
867
670
  break;
868
671
  case 152:
869
- this.errorLog(
870
- `Humidifier: ${this.accessory.displayName} Device not found.`,
871
- );
672
+ this.errorLog(`Humidifier: ${this.accessory.displayName} Device not found.`);
872
673
  break;
873
674
  case 160:
874
- this.errorLog(
875
- `Humidifier: ${this.accessory.displayName} Command is not supported.`,
876
- );
675
+ this.errorLog(`Humidifier: ${this.accessory.displayName} Command is not supported.`);
877
676
  break;
878
677
  case 161:
879
- this.errorLog(
880
- `Humidifier: ${this.accessory.displayName} Device is offline.`,
881
- );
678
+ this.errorLog(`Humidifier: ${this.accessory.displayName} Device is offline.`);
882
679
  this.offlineOff();
883
680
  break;
884
681
  case 171:
885
- this.errorLog(
886
- `Humidifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
887
- );
682
+ this.errorLog(`Humidifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
888
683
  this.offlineOff();
889
684
  break;
890
685
  case 190:
@@ -894,35 +689,25 @@ export class Humidifier {
894
689
  );
895
690
  break;
896
691
  case 100:
897
- this.debugLog(
898
- `Humidifier: ${this.accessory.displayName} Command successfully sent.`,
899
- );
692
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Command successfully sent.`);
900
693
  break;
901
694
  default:
902
- this.debugLog(
903
- `Humidifier: ${this.accessory.displayName} Unknown statusCode.`,
904
- );
695
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Unknown statusCode.`);
905
696
  }
906
697
  }
907
698
 
908
699
  private offlineOff() {
909
700
  if (this.device.offline) {
910
701
  this.Active = this.platform.Characteristic.Active.INACTIVE;
911
- this.service
912
- .getCharacteristic(this.platform.Characteristic.Active)
913
- .updateValue(this.Active);
702
+ this.service.getCharacteristic(this.platform.Characteristic.Active).updateValue(this.Active);
914
703
  }
915
704
  }
916
705
 
917
706
  /**
918
707
  * Handle requests to set the "Target Humidifier Dehumidifier State" characteristic
919
708
  */
920
- private handleTargetHumidifierDehumidifierStateSet(
921
- value: homebridge.CharacteristicValue,
922
- ) {
923
- this.debugLog(
924
- `Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${value}`,
925
- );
709
+ private handleTargetHumidifierDehumidifierStateSet(value: CharacteristicValue) {
710
+ this.debugLog(`Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${value}`);
926
711
 
927
712
  this.TargetHumidifierDehumidifierState = value;
928
713
  this.doHumidifierUpdate.next();
@@ -931,7 +716,7 @@ export class Humidifier {
931
716
  /**
932
717
  * Handle requests to set the "Active" characteristic
933
718
  */
934
- private handleActiveSet(value: homebridge.CharacteristicValue) {
719
+ private handleActiveSet(value: CharacteristicValue) {
935
720
  this.debugLog(`Humidifier: ${this.accessory.displayName} Active: ${value}`);
936
721
  this.Active = value;
937
722
  this.doHumidifierUpdate.next();
@@ -940,105 +725,76 @@ export class Humidifier {
940
725
  /**
941
726
  * Handle requests to set the "Relative Humidity Humidifier Threshold" characteristic
942
727
  */
943
- private handleRelativeHumidityHumidifierThresholdSet(
944
- value: homebridge.CharacteristicValue,
945
- ) {
946
- this.debugLog(
947
- `Humidifier: ${this.accessory.displayName} RelativeHumidityHumidifierThreshold: ${value}`,
948
- );
728
+ private handleRelativeHumidityHumidifierThresholdSet(value: CharacteristicValue) {
729
+ this.debugLog(`Humidifier: ${this.accessory.displayName} RelativeHumidityHumidifierThreshold: ${value}`);
949
730
 
950
731
  this.RelativeHumidityHumidifierThreshold = value;
951
732
  if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
952
733
  this.Active = this.platform.Characteristic.Active.ACTIVE;
953
- this.CurrentHumidifierDehumidifierState =
954
- this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
734
+ this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
955
735
  }
956
736
  this.doHumidifierUpdate.next();
957
737
  }
958
738
 
959
- config(device: settings.device & settings.devicesConfig) {
739
+ config(device: device & devicesConfig) {
960
740
  let config = {};
961
741
  if (device.humidifier) {
962
742
  config = device.humidifier;
963
743
  }
964
744
  if (device.ble !== undefined) {
965
- config["ble"] = device.ble;
745
+ config['ble'] = device.ble;
966
746
  }
967
747
  if (device.logging !== undefined) {
968
- config["logging"] = device.logging;
748
+ config['logging'] = device.logging;
969
749
  }
970
750
  if (device.refreshRate !== undefined) {
971
- config["refreshRate"] = device.refreshRate;
751
+ config['refreshRate'] = device.refreshRate;
972
752
  }
973
753
  if (device.scanDuration !== undefined) {
974
- config["scanDuration"] = device.scanDuration;
754
+ config['scanDuration'] = device.scanDuration;
975
755
  }
976
756
  if (Object.entries(config).length !== 0) {
977
- this.warnLog(
978
- `Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(
979
- config,
980
- )}`,
981
- );
757
+ this.warnLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
982
758
  }
983
759
  }
984
760
 
985
- refreshRate(device: settings.device & settings.devicesConfig) {
761
+ refreshRate(device: device & devicesConfig) {
986
762
  if (device.refreshRate) {
987
- this.deviceRefreshRate = this.accessory.context.refreshRate =
988
- device.refreshRate;
989
- this.debugLog(
990
- `Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`,
991
- );
763
+ this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
764
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
992
765
  } else if (this.platform.config.options!.refreshRate) {
993
- this.deviceRefreshRate = this.accessory.context.refreshRate =
994
- this.platform.config.options!.refreshRate;
995
- this.debugLog(
996
- `Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`,
997
- );
766
+ this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
767
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
998
768
  }
999
769
  }
1000
770
 
1001
- scan(device: settings.device & settings.devicesConfig) {
771
+ scan(device: device & devicesConfig) {
1002
772
  if (device.scanDuration) {
1003
- this.scanDuration = this.accessory.context.scanDuration =
1004
- device.scanDuration;
773
+ this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
1005
774
  if (device.ble) {
1006
- this.debugLog(
1007
- `Humidifier: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`,
1008
- );
775
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
1009
776
  }
1010
777
  } else {
1011
778
  this.scanDuration = this.accessory.context.scanDuration = 1;
1012
779
  if (this.device.ble) {
1013
- this.debugLog(
1014
- `Humidifier: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`,
1015
- );
780
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
1016
781
  }
1017
782
  }
1018
783
  }
1019
784
 
1020
- logs(device: settings.device & settings.devicesConfig) {
785
+ logs(device: device & devicesConfig) {
1021
786
  if (this.platform.debugMode) {
1022
- this.deviceLogging = this.accessory.context.logging = "debugMode";
1023
- this.debugLog(
1024
- `Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
1025
- );
787
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
788
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
1026
789
  } else if (device.logging) {
1027
790
  this.deviceLogging = this.accessory.context.logging = device.logging;
1028
- this.debugLog(
1029
- `Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
1030
- );
791
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
1031
792
  } else if (this.platform.config.options?.logging) {
1032
- this.deviceLogging = this.accessory.context.logging =
1033
- this.platform.config.options?.logging;
1034
- this.debugLog(
1035
- `Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
1036
- );
793
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
794
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
1037
795
  } else {
1038
- this.deviceLogging = this.accessory.context.logging = "standard";
1039
- this.debugLog(
1040
- `Humidifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
1041
- );
796
+ this.deviceLogging = this.accessory.context.logging = 'standard';
797
+ this.debugLog(`Humidifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
1042
798
  }
1043
799
  }
1044
800
 
@@ -1054,28 +810,28 @@ export class Humidifier {
1054
810
  /**
1055
811
  * Logging for Device
1056
812
  */
1057
- infoLog(...log: any[]): void {
813
+ infoLog(...log: any[]) {
1058
814
  if (this.enablingDeviceLogging()) {
1059
815
  this.platform.log.info(String(...log));
1060
816
  }
1061
817
  }
1062
818
 
1063
- warnLog(...log: any[]): void {
819
+ warnLog(...log: any[]) {
1064
820
  if (this.enablingDeviceLogging()) {
1065
821
  this.platform.log.warn(String(...log));
1066
822
  }
1067
823
  }
1068
824
 
1069
- errorLog(...log: any[]): void {
825
+ errorLog(...log: any[]) {
1070
826
  if (this.enablingDeviceLogging()) {
1071
827
  this.platform.log.error(String(...log));
1072
828
  }
1073
829
  }
1074
830
 
1075
- debugLog(...log: any[]): void {
831
+ debugLog(...log: any[]) {
1076
832
  if (this.enablingDeviceLogging()) {
1077
- if (this.deviceLogging === "debug") {
1078
- this.platform.log.info("[DEBUG]", String(...log));
833
+ if (this.deviceLogging === 'debug') {
834
+ this.platform.log.info('[DEBUG]', String(...log));
1079
835
  } else {
1080
836
  this.platform.log.debug(String(...log));
1081
837
  }
@@ -1083,8 +839,6 @@ export class Humidifier {
1083
839
  }
1084
840
 
1085
841
  enablingDeviceLogging(): boolean {
1086
- return (
1087
- this.deviceLogging.includes("debug") || this.deviceLogging === "standard"
1088
- );
842
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
1089
843
  }
1090
844
  }