@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,7 +1,7 @@
1
- import { AxiosResponse } from "axios";
2
- import { SwitchBotPlatform } from "../platform";
3
- import { irDevicesConfig, DeviceURL, irdevice, payload } from "../settings";
4
- import { CharacteristicValue, PlatformAccessory, Service } from "homebridge";
1
+ import { AxiosResponse } from 'axios';
2
+ import { SwitchBotPlatform } from '../platform';
3
+ import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -38,11 +38,7 @@ export class AirPurifier {
38
38
  // Config
39
39
  deviceLogging!: string;
40
40
 
41
- constructor(
42
- private readonly platform: SwitchBotPlatform,
43
- private accessory: PlatformAccessory,
44
- public device: irdevice & irDevicesConfig,
45
- ) {
41
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
46
42
  // default placeholders
47
43
  this.logs(device);
48
44
  this.config(device);
@@ -60,18 +56,13 @@ export class AirPurifier {
60
56
  // set accessory information
61
57
  accessory
62
58
  .getService(this.platform.Service.AccessoryInformation)!
63
- .setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
59
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
64
60
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
65
- .setCharacteristic(
66
- this.platform.Characteristic.SerialNumber,
67
- device.deviceId!,
68
- );
61
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
69
62
 
70
63
  // get the Television service if it exists, otherwise create a new Television service
71
64
  // you can create multiple services for each accessory
72
- (this.service =
73
- accessory.getService(this.platform.Service.AirPurifier) ||
74
- accessory.addService(this.platform.Service.AirPurifier)),
65
+ (this.service = accessory.getService(this.platform.Service.AirPurifier) || accessory.addService(this.platform.Service.AirPurifier)),
75
66
  `${accessory.displayName} Air Purifier`;
76
67
 
77
68
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
@@ -80,31 +71,20 @@ export class AirPurifier {
80
71
 
81
72
  // set the service name, this is what is displayed as the default name on the Home app
82
73
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
83
- this.service.setCharacteristic(
84
- this.platform.Characteristic.Name,
85
- accessory.displayName,
86
- );
74
+ this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
87
75
 
88
76
  // handle on / off events using the Active characteristic
89
- this.service
90
- .getCharacteristic(this.platform.Characteristic.Active)
91
- .onSet(this.ActiveSet.bind(this));
92
-
93
- this.service
94
- .getCharacteristic(this.platform.Characteristic.CurrentAirPurifierState)
95
- .onGet(() => {
96
- return this.CurrentAirPurifierStateGet();
97
- });
98
-
99
- this.service
100
- .getCharacteristic(this.platform.Characteristic.TargetAirPurifierState)
101
- .onSet(this.TargetAirPurifierStateSet.bind(this));
77
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
78
+
79
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentAirPurifierState).onGet(() => {
80
+ return this.CurrentAirPurifierStateGet();
81
+ });
82
+
83
+ this.service.getCharacteristic(this.platform.Characteristic.TargetAirPurifierState).onSet(this.TargetAirPurifierStateSet.bind(this));
102
84
  }
103
85
 
104
86
  private ActiveSet(value: CharacteristicValue) {
105
- this.debugLog(
106
- `Air Purifier: ${this.accessory.displayName} Set Active: ${value}`,
107
- );
87
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Set Active: ${value}`);
108
88
  if (value === this.platform.Characteristic.Active.INACTIVE) {
109
89
  this.pushAirPurifierOffChanges();
110
90
  } else {
@@ -117,44 +97,23 @@ export class AirPurifier {
117
97
 
118
98
  private updateHomeKitCharacteristics() {
119
99
  if (this.Active === undefined) {
120
- this.debugLog(
121
- `Air Purifier: ${this.accessory.displayName} Active: ${this.Active}`,
122
- );
100
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Active: ${this.Active}`);
123
101
  } else {
124
- this.service?.updateCharacteristic(
125
- this.platform.Characteristic.Active,
126
- this.Active,
127
- );
128
- this.debugLog(
129
- `Air Purifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
130
- );
102
+ this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
103
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
131
104
  }
132
105
  if (this.CurrentAirPurifierState === undefined) {
133
- this.debugLog(
134
- `Air Purifier: ${this.accessory.displayName} CurrentAirPurifierState: ${this.CurrentAirPurifierState}`,
135
- );
106
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
136
107
  } else {
137
- this.service?.updateCharacteristic(
138
- this.platform.Characteristic.CurrentAirPurifierState,
139
- this.CurrentAirPurifierState,
140
- );
141
- this.debugLog(
142
- `Air Purifier: ${this.accessory.displayName}` +
143
- ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`,
144
- );
108
+ this.service?.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, this.CurrentAirPurifierState);
109
+ this.debugLog(`Air Purifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
145
110
  }
146
111
  if (this.CurrentHeaterCoolerState === undefined) {
147
- this.debugLog(
148
- `Air Purifier: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
149
- );
112
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
150
113
  } else {
151
- this.service?.updateCharacteristic(
152
- this.platform.Characteristic.CurrentHeaterCoolerState,
153
- this.CurrentHeaterCoolerState,
154
- );
114
+ this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
155
115
  this.debugLog(
156
- `Air Purifier: ${this.accessory.displayName}` +
157
- ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
116
+ `Air Purifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
158
117
  );
159
118
  }
160
119
  }
@@ -177,11 +136,9 @@ export class AirPurifier {
177
136
 
178
137
  private CurrentAirPurifierStateGet() {
179
138
  if (this.Active === 1) {
180
- this.CurrentAirPurifierState =
181
- this.platform.Characteristic.CurrentAirPurifierState.PURIFYING_AIR;
139
+ this.CurrentAirPurifierState = this.platform.Characteristic.CurrentAirPurifierState.PURIFYING_AIR;
182
140
  } else {
183
- this.CurrentAirPurifierState =
184
- this.platform.Characteristic.CurrentAirPurifierState.INACTIVE;
141
+ this.CurrentAirPurifierState = this.platform.Characteristic.CurrentAirPurifierState.INACTIVE;
185
142
  }
186
143
  return this.CurrentAirPurifierState;
187
144
  }
@@ -200,9 +157,9 @@ export class AirPurifier {
200
157
  async pushAirPurifierOnChanges() {
201
158
  if (this.Active !== 1) {
202
159
  const payload = {
203
- commandType: "command",
204
- parameter: "default",
205
- command: "turnOn",
160
+ commandType: 'command',
161
+ parameter: 'default',
162
+ command: 'turnOn',
206
163
  } as payload;
207
164
  await this.pushChanges(payload);
208
165
  }
@@ -211,9 +168,9 @@ export class AirPurifier {
211
168
  async pushAirPurifierOffChanges() {
212
169
  if (this.Active !== 0) {
213
170
  const payload = {
214
- commandType: "command",
215
- parameter: "default",
216
- command: "turnOff",
171
+ commandType: 'command',
172
+ parameter: 'default',
173
+ command: 'turnOff',
217
174
  } as payload;
218
175
  await this.pushChanges(payload);
219
176
  }
@@ -222,41 +179,34 @@ export class AirPurifier {
222
179
  async pushAirConditionerStatusChanges() {
223
180
  if (!this.Busy) {
224
181
  this.Busy = true;
225
- this.CurrentHeaterCoolerState =
226
- this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
182
+ this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
227
183
  }
228
184
  clearTimeout(this.Timeout);
229
185
 
230
186
  // Make a new Timeout set to go off in 1000ms (1 second)
231
- this.Timeout = setTimeout(
232
- this.pushAirConditionerDetailsChanges.bind(this),
233
- 1500,
234
- );
187
+ this.Timeout = setTimeout(this.pushAirConditionerDetailsChanges.bind(this), 1500);
235
188
  }
236
189
 
237
190
  async pushAirConditionerDetailsChanges() {
238
191
  const payload = {
239
- commandType: "command",
240
- command: "setAll",
192
+ commandType: 'command',
193
+ command: 'setAll',
241
194
  } as payload;
242
195
 
243
196
  this.CurrentAPTemp = this.CurrentTemperature || 24;
244
197
  this.CurrentAPMode = this.CurrentMode || 1;
245
198
  this.CurrentAPFanSpeed = this.CurrentFanSpeed || 1;
246
- this.APActive = this.Active === 1 ? "on" : "off";
199
+ this.APActive = this.Active === 1 ? 'on' : 'off';
247
200
  payload.parameter = `${this.CurrentAPTemp},${this.CurrentAPMode},${this.CurrentAPFanSpeed},${this.APActive}`;
248
201
 
249
202
  if (this.Active === 1) {
250
203
  if ((this.CurrentTemperature || 24) < (this.LastTemperature || 30)) {
251
- this.CurrentHeaterCoolerState =
252
- this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
204
+ this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
253
205
  } else {
254
- this.CurrentHeaterCoolerState =
255
- this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
206
+ this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
256
207
  }
257
208
  } else {
258
- this.CurrentHeaterCoolerState =
259
- this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
209
+ this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
260
210
  }
261
211
 
262
212
  await this.pushChanges(payload);
@@ -270,32 +220,21 @@ export class AirPurifier {
270
220
  );
271
221
 
272
222
  // Make the API request
273
- const push = await this.platform.axios.post(
274
- `${DeviceURL}/${this.device.deviceId}/commands`,
275
- payload,
276
- );
277
- this.debugLog(
278
- `Air Purifier: ${this.accessory.displayName} pushChanges: ${push.data}`,
279
- );
223
+ const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
224
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} pushChanges: ${push.data}`);
280
225
  this.statusCode(push);
281
226
  this.updateHomeKitCharacteristics();
282
227
  this.CurrentTemperatureCached = this.CurrentTemperature;
283
228
  this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
284
229
  } catch (e: any) {
285
- this.errorLog(
286
- `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`,
287
- );
288
- if (this.deviceLogging === "debug") {
230
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
231
+ if (this.deviceLogging === 'debug') {
289
232
  this.errorLog(
290
- `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
291
- ` Error Message: ${JSON.stringify(e.message)}`,
233
+ `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
292
234
  );
293
235
  }
294
236
  if (this.platform.debugMode) {
295
- this.errorLog(
296
- `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
297
- ` Error: ${JSON.stringify(e)}`,
298
- );
237
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
299
238
  }
300
239
  this.apiError(e);
301
240
  }
@@ -304,63 +243,38 @@ export class AirPurifier {
304
243
  private statusCode(push: AxiosResponse<{ statusCode: number }>) {
305
244
  switch (push.data.statusCode) {
306
245
  case 151:
307
- this.errorLog(
308
- `Air Purifier: ${this.accessory.displayName} Command not supported by this device type.`,
309
- );
246
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Command not supported by this device type.`);
310
247
  break;
311
248
  case 152:
312
- this.errorLog(
313
- `Air Purifier: ${this.accessory.displayName} Device not found.`,
314
- );
249
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Device not found.`);
315
250
  break;
316
251
  case 160:
317
- this.errorLog(
318
- `Air Purifier: ${this.accessory.displayName} Command is not supported.`,
319
- );
252
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Command is not supported.`);
320
253
  break;
321
254
  case 161:
322
- this.errorLog(
323
- `Air Purifier: ${this.accessory.displayName} Device is offline.`,
324
- );
255
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Device is offline.`);
325
256
  break;
326
257
  case 171:
327
- this.errorLog(
328
- `Air Purifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
329
- );
258
+ this.errorLog(`Air Purifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
330
259
  break;
331
260
  case 190:
332
261
  this.errorLog(
333
262
  `Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
334
- ` with server, Or command: ${JSON.stringify(
335
- push.data,
336
- )} format is invalid`,
263
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`,
337
264
  );
338
265
  break;
339
266
  case 100:
340
- this.debugLog(
341
- `Air Purifier: ${this.accessory.displayName} Command successfully sent.`,
342
- );
267
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Command successfully sent.`);
343
268
  break;
344
269
  default:
345
- this.debugLog(
346
- `Air Purifier: ${this.accessory.displayName} Unknown statusCode.`,
347
- );
270
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Unknown statusCode.`);
348
271
  }
349
272
  }
350
273
 
351
274
  public apiError(e: any) {
352
- this.service.updateCharacteristic(
353
- this.platform.Characteristic.CurrentHeaterCoolerState,
354
- e,
355
- );
356
- this.service.updateCharacteristic(
357
- this.platform.Characteristic.CurrentAirPurifierState,
358
- e,
359
- );
360
- this.service.updateCharacteristic(
361
- this.platform.Characteristic.TargetAirPurifierState,
362
- e,
363
- );
275
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
276
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, e);
277
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetAirPurifierState, e);
364
278
  this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
365
279
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
366
280
  }
@@ -371,39 +285,26 @@ export class AirPurifier {
371
285
  config = device.irpur;
372
286
  }
373
287
  if (device.logging !== undefined) {
374
- config["logging"] = device.logging;
288
+ config['logging'] = device.logging;
375
289
  }
376
290
  if (Object.entries(config).length !== 0) {
377
- this.warnLog(
378
- `Air Purifier: ${this.accessory.displayName} Config: ${JSON.stringify(
379
- config,
380
- )}`,
381
- );
291
+ this.warnLog(`Air Purifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
382
292
  }
383
293
  }
384
294
 
385
295
  logs(device: irdevice & irDevicesConfig) {
386
296
  if (this.platform.debugMode) {
387
- this.deviceLogging = this.accessory.context.logging = "debugMode";
388
- this.debugLog(
389
- `Air Purifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
390
- );
297
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
298
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
391
299
  } else if (device.logging) {
392
300
  this.deviceLogging = this.accessory.context.logging = device.logging;
393
- this.debugLog(
394
- `Air Purifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
395
- );
301
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
396
302
  } else if (this.platform.config.options?.logging) {
397
- this.deviceLogging = this.accessory.context.logging =
398
- this.platform.config.options?.logging;
399
- this.debugLog(
400
- `Air Purifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
401
- );
303
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
304
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
402
305
  } else {
403
- this.deviceLogging = this.accessory.context.logging = "standard";
404
- this.debugLog(
405
- `Air Purifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
406
- );
306
+ this.deviceLogging = this.accessory.context.logging = 'standard';
307
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
407
308
  }
408
309
  }
409
310
 
@@ -430,8 +331,8 @@ export class AirPurifier {
430
331
 
431
332
  debugLog(...log: any[]) {
432
333
  if (this.enablingDeviceLogging()) {
433
- if (this.deviceLogging === "debug") {
434
- this.platform.log.info("[DEBUG]", String(...log));
334
+ if (this.deviceLogging === 'debug') {
335
+ this.platform.log.info('[DEBUG]', String(...log));
435
336
  } else {
436
337
  this.platform.log.debug(String(...log));
437
338
  }
@@ -439,6 +340,6 @@ export class AirPurifier {
439
340
  }
440
341
 
441
342
  enablingDeviceLogging(): boolean {
442
- return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
343
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
443
344
  }
444
345
  }