@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
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AirConditioner = void 0;
7
7
  const https_1 = __importDefault(require("https"));
8
8
  const crypto_1 = __importDefault(require("crypto"));
9
+ const super_stringify_1 = __importDefault(require("super-stringify"));
9
10
  const settings_1 = require("../settings");
10
11
  /**
11
12
  * Platform Accessory
@@ -24,32 +25,16 @@ class AirConditioner {
24
25
  this.logs(device);
25
26
  this.config(device);
26
27
  this.pushOnChanges(device);
27
- if (this.Active === undefined) {
28
- this.Active = this.platform.Characteristic.Active.INACTIVE;
29
- }
30
- else {
31
- this.Active = this.accessory.context.Active;
32
- }
33
- if (this.CurrentTemperature === undefined) {
34
- this.CurrentTemperature = 24;
35
- }
36
- else {
37
- this.CurrentTemperature = this.accessory.context.CurrentTemperature;
38
- }
39
- if (device.irair?.hide_automode) {
40
- this.hide_automode = device.irair?.hide_automode;
41
- this.accessory.context.hide_automode = this.hide_automode;
42
- }
43
- else {
44
- this.hide_automode = device.irair?.hide_automode;
45
- this.accessory.context.hide_automode = this.hide_automode;
46
- }
28
+ this.context(device);
47
29
  // set accessory information
48
30
  accessory
49
31
  .getService(this.platform.Service.AccessoryInformation)
50
32
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
51
33
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
52
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId);
34
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
35
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
36
+ .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
37
+ .updateValue(this.FirmwareRevision(accessory, device));
53
38
  // get the Television service if it exists, otherwise create a new Television service
54
39
  // you can create multiple services for each accessory
55
40
  (this.coolerService = accessory.getService(this.platform.Service.HeaterCooler) || accessory.addService(this.platform.Service.HeaterCooler)),
@@ -75,13 +60,13 @@ class AirConditioner {
75
60
  if (this.hide_automode) {
76
61
  this.TargetHeaterCoolerState = 1 || 2;
77
62
  this.ValidValues = [1, 2];
78
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},` +
63
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${(0, super_stringify_1.default)(this.ValidValues)},` +
79
64
  ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
80
65
  }
81
66
  else {
82
67
  this.TargetHeaterCoolerState = 0 || 1 || 2;
83
68
  this.ValidValues = [0, 1, 2];
84
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},` +
69
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${(0, super_stringify_1.default)(this.ValidValues)},` +
85
70
  ` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
86
71
  }
87
72
  this.coolerService
@@ -141,7 +126,7 @@ class AirConditioner {
141
126
  */
142
127
  async pushAirConditionerOnChanges() {
143
128
  if (this.Active !== this.platform.Characteristic.Active.ACTIVE || this.pushOn) {
144
- const body = JSON.stringify({
129
+ const body = (0, super_stringify_1.default)({
145
130
  'command': 'turnOn',
146
131
  'parameter': 'default',
147
132
  'commandType': 'command',
@@ -150,7 +135,7 @@ class AirConditioner {
150
135
  }
151
136
  }
152
137
  async pushAirConditionerOffChanges() {
153
- const body = JSON.stringify({
138
+ const body = (0, super_stringify_1.default)({
154
139
  'command': 'turnOff',
155
140
  'parameter': 'default',
156
141
  'commandType': 'command',
@@ -182,22 +167,23 @@ class AirConditioner {
182
167
  }
183
168
  if (this.CurrentMode === 1) {
184
169
  this.CurrentTemperature = 25;
185
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` + ` CurrentTemperature: ${this.CurrentTemperature}`);
170
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
171
+ + ` CurrentTemperature: ${this.CurrentTemperature}`);
186
172
  }
187
173
  const parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
188
174
  if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
189
175
  this.CurrentTemperatureUndefined();
190
- if (this.CurrentTemperature < this.CurrentTemperatureCached) {
176
+ if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
191
177
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
192
178
  }
193
- else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
179
+ else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
194
180
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
195
181
  }
196
182
  }
197
183
  else {
198
184
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
199
185
  }
200
- const body = JSON.stringify({
186
+ const body = (0, super_stringify_1.default)({
201
187
  'command': 'setAll',
202
188
  'parameter': `${parameter}`,
203
189
  'commandType': 'command',
@@ -205,161 +191,73 @@ class AirConditioner {
205
191
  await this.pushChanges(body);
206
192
  }
207
193
  async pushChanges(body) {
208
- try {
209
- // Make Push On request to the API
210
- const t = Date.now();
211
- const nonce = 'requestID';
212
- const data = this.platform.config.credentials?.token + t + nonce;
213
- const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret)
214
- .update(Buffer.from(data, 'utf-8'))
215
- .digest();
216
- const sign = signTerm.toString('base64');
217
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} sign: ${sign}`);
218
- this.infoLog(`Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
219
- const options = {
220
- hostname: settings_1.HostDomain,
221
- port: 443,
222
- path: `${settings_1.DevicePath}/${this.device.deviceId}/commands`,
223
- method: 'POST',
224
- headers: {
225
- 'Authorization': this.platform.config.credentials?.token,
226
- 'sign': sign,
227
- 'nonce': nonce,
228
- 't': t,
229
- 'Content-Type': 'application/json',
230
- 'Content-Length': body.length,
231
- },
232
- };
233
- const req = https_1.default.request(options, res => {
234
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
235
- this.statusCode({ res });
236
- res.on('data', d => {
237
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} d: ${d}`);
194
+ if (this.device.connectionType === 'OpenAPI') {
195
+ try {
196
+ // Make Push On request to the API
197
+ const t = Date.now();
198
+ const nonce = 'requestID';
199
+ const data = this.platform.config.credentials?.token + t + nonce;
200
+ const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret)
201
+ .update(Buffer.from(data, 'utf-8'))
202
+ .digest();
203
+ const sign = signTerm.toString('base64');
204
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} sign: ${sign}`);
205
+ this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
206
+ const options = {
207
+ hostname: settings_1.HostDomain,
208
+ port: 443,
209
+ path: `${settings_1.DevicePath}/${this.device.deviceId}/commands`,
210
+ method: 'POST',
211
+ headers: {
212
+ 'Authorization': this.platform.config.credentials?.token,
213
+ 'sign': sign,
214
+ 'nonce': nonce,
215
+ 't': t,
216
+ 'Content-Type': 'application/json',
217
+ 'Content-Length': body.length,
218
+ },
219
+ };
220
+ const req = https_1.default.request(options, res => {
221
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges statusCode: ${res.statusCode}`);
222
+ this.statusCode({ res });
223
+ res.on('data', d => {
224
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
225
+ });
238
226
  });
239
- });
240
- req.on('error', (e) => {
241
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} error message: ${e.message}`);
242
- });
243
- req.write(body);
244
- req.end();
245
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
246
- this.CurrentTemperatureCached = this.CurrentTemperature;
247
- this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
248
- this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
249
- this.HeatingThresholdTemperatureCached = this.CurrentTemperatureCached;
250
- this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
251
- this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
252
- this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
253
- this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
254
- this.updateHomeKitCharacteristics();
255
- }
256
- catch (e) {
257
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
258
- if (this.deviceLogging.includes('debug')) {
259
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
227
+ req.on('error', (e) => {
228
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} error message: ${e.message}`);
229
+ });
230
+ req.write(body);
231
+ req.end();
232
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${(0, super_stringify_1.default)(req)}`);
233
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
234
+ this.HeatingThresholdTemperature = this.CurrentTemperature;
235
+ this.CoolingThresholdTemperature = this.CurrentTemperature;
236
+ this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
237
+ this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
238
+ this.updateHomeKitCharacteristics();
239
+ }
240
+ catch (e) {
241
+ this.apiError(e);
242
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
243
+ + ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
260
244
  }
261
- this.apiError(e);
262
- }
263
- }
264
- async statusCode({ res }) {
265
- switch (res.statusCode) {
266
- case 151:
267
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
268
- break;
269
- case 152:
270
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device not found.`);
271
- break;
272
- case 160:
273
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command is not supported.`);
274
- break;
275
- case 161:
276
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
277
- break;
278
- case 171:
279
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
280
- break;
281
- case 190:
282
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
283
- ` with server, Or command: ${JSON.stringify(res)} format is invalid`);
284
- break;
285
- case 100:
286
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
287
- break;
288
- default:
289
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`);
290
- }
291
- }
292
- async updateHomeKitCharacteristics() {
293
- if (this.Active === undefined) {
294
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
295
- }
296
- else {
297
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
298
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
299
- }
300
- if (this.RotationSpeed === undefined) {
301
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
302
- }
303
- else {
304
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
305
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
306
- }
307
- if (this.CurrentTemperature === undefined) {
308
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
309
- }
310
- else {
311
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
312
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
313
- }
314
- if (this.TargetHeaterCoolerState === undefined) {
315
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
316
- }
317
- else {
318
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
319
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
320
- }
321
- if (this.CurrentHeaterCoolerState === undefined) {
322
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
323
- }
324
- else {
325
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
326
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
327
- }
328
- if (this.HeatingThresholdTemperature === undefined) {
329
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
330
- }
331
- else {
332
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
333
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
334
- }
335
- if (this.CoolingThresholdTemperature === undefined) {
336
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
337
245
  }
338
246
  else {
339
- this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
340
- this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
247
+ this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
248
+ + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
341
249
  }
342
250
  }
343
- async apiError(e) {
344
- this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
345
- this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
346
- this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
347
- this.coolerService.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
348
- this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
349
- this.coolerService.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
350
- this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
351
- //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
352
- }
353
251
  async CurrentTemperatureGet() {
354
252
  if (this.CurrentTemperature === undefined) {
355
253
  this.CurrentTemperature = 24;
356
- this.CurrentTemperatureCached = this.CurrentTemperature;
254
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
357
255
  }
358
256
  else {
359
- this.CurrentTemperatureCached = this.CurrentTemperature;
257
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
360
258
  }
361
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
362
- this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
259
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
260
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
363
261
  return this.CurrentTemperature;
364
262
  }
365
263
  async RotationSpeedGet() {
@@ -372,9 +270,8 @@ class AirConditioner {
372
270
  else {
373
271
  this.RotationSpeed = this.CurrentFanSpeed - 1;
374
272
  }
375
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
376
- this.RotationSpeedCached = this.RotationSpeed;
377
- this.accessory.context.RotationSpeed = this.RotationSpeedCached;
273
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
274
+ this.accessory.context.RotationSpeed = this.RotationSpeed;
378
275
  return this.RotationSpeed;
379
276
  }
380
277
  async RotationSpeedSet(value) {
@@ -385,21 +282,19 @@ class AirConditioner {
385
282
  this.CurrentFanSpeed = Number(value) + 1;
386
283
  }
387
284
  this.RotationSpeed = this.CurrentFanSpeed;
388
- this.RotationSpeedCached = this.RotationSpeed;
389
- this.accessory.context.RotationSpeed = this.RotationSpeedCached;
285
+ this.accessory.context.RotationSpeed = this.RotationSpeed;
390
286
  this.pushAirConditionerStatusChanges();
391
287
  }
392
288
  async ActiveSet(value) {
393
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`);
289
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
394
290
  this.Active = value;
395
- this.ActiveCached = this.Active;
396
- this.accessory.context.Active = this.ActiveCached;
291
+ this.accessory.context.Active = this.Active;
397
292
  if (value === this.platform.Characteristic.Active.INACTIVE) {
398
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
293
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
399
294
  this.pushAirConditionerOffChanges();
400
295
  }
401
296
  else {
402
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
297
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
403
298
  if (this.pushOn) {
404
299
  this.pushAirConditionerOnChanges();
405
300
  }
@@ -411,21 +306,20 @@ class AirConditioner {
411
306
  async TargetHeaterCoolerStateGet() {
412
307
  if (this.ValidValues === this.valid012) {
413
308
  this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
414
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
309
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
415
310
  ` ValidValues: ${this.ValidValues}`);
416
311
  }
417
312
  else if (this.ValidValues === this.valid12) {
418
313
  this.TargetHeaterCoolerState =
419
314
  this.platform.Characteristic.TargetHeaterCoolerState.COOL || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
420
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
315
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
421
316
  ` ValidValues: ${this.ValidValues}`);
422
317
  }
423
318
  else {
424
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
319
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
425
320
  ` ValidValues: ${this.ValidValues}`);
426
321
  }
427
- this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
428
- this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
322
+ this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
429
323
  return this.TargetHeaterCoolerState;
430
324
  }
431
325
  async TargetHeaterCoolerStateSet(value) {
@@ -437,7 +331,7 @@ class AirConditioner {
437
331
  this.TargetHeaterCoolerStateCOOL();
438
332
  }
439
333
  else {
440
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
334
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
441
335
  ` hide_automode: ${this.hide_automode} `);
442
336
  }
443
337
  }
@@ -452,96 +346,230 @@ class AirConditioner {
452
346
  this.TargetHeaterCoolerStateCOOL();
453
347
  }
454
348
  else {
455
- this.errorLog(`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
349
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
456
350
  ` hide_automode: ${this.hide_automode} `);
457
351
  }
458
352
  }
459
- this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
460
- this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
353
+ this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
461
354
  this.pushAirConditionerStatusChanges();
462
355
  }
463
356
  async TargetHeaterCoolerStateAUTO() {
464
357
  this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
465
358
  this.CurrentMode = 1;
466
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
467
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
359
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
360
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
468
361
  }
469
362
  async TargetHeaterCoolerStateCOOL() {
470
363
  this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
471
364
  this.CurrentMode = 2;
472
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
473
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
365
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
366
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
474
367
  }
475
368
  async TargetHeaterCoolerStateHEAT() {
476
369
  this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
477
370
  this.CurrentMode = 5;
478
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
479
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
371
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
372
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
480
373
  }
481
374
  async CurrentHeaterCoolerStateGet() {
482
375
  if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
483
376
  this.CurrentTemperatureUndefined();
484
- if (this.CurrentTemperature < this.CurrentTemperatureCached) {
377
+ if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
485
378
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
486
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
379
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
380
+ + ` Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
487
381
  }
488
- else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
382
+ else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
489
383
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
490
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
384
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
385
+ + ` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
491
386
  }
492
387
  }
493
388
  else {
494
389
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
495
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
390
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
391
+ + ` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
496
392
  }
497
- this.CurrentHeaterCoolerStateCached = this.CurrentHeaterCoolerState;
498
- this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
393
+ this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
499
394
  return this.CurrentHeaterCoolerState;
500
395
  }
501
396
  async HeatingThresholdTemperatureGet() {
502
397
  this.CurrentTemperatureUndefined;
503
- this.CurrentTemperature = this.CurrentTemperatureCached;
504
- this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
505
- this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
506
- this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
507
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
398
+ this.CurrentTemperature = this.accessory.context.CurrentTemperature;
399
+ this.HeatingThresholdTemperature = this.accessory.context.CurrentTemperature;
400
+ this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
401
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
508
402
  return this.HeatingThresholdTemperature;
509
403
  }
510
404
  async HeatingThresholdTemperatureSet(value) {
511
- this.CurrentTemperatureCached = this.CurrentTemperature;
405
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
512
406
  this.CurrentTemperature = value;
513
- this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
514
- this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
515
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
516
- ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
407
+ this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
408
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
409
+ ` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`);
517
410
  this.pushAirConditionerStatusChanges();
518
411
  }
519
412
  async CoolingThresholdTemperatureGet() {
520
413
  this.CurrentTemperatureUndefined;
521
- this.CurrentTemperature = this.CurrentTemperatureCached;
522
- this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
523
- this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
524
- this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
525
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
414
+ this.CurrentTemperature = this.accessory.context.CurrentTemperature;
415
+ this.CoolingThresholdTemperature = this.accessory.context.CurrentTemperature;
416
+ this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
417
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
526
418
  return this.CoolingThresholdTemperature;
527
419
  }
528
420
  async CoolingThresholdTemperatureSet(value) {
529
- this.CurrentTemperatureCached = this.CurrentTemperature;
421
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
530
422
  this.CurrentTemperature = value;
531
- this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
532
- this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
533
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
534
- ` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
423
+ this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
424
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
425
+ ` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`);
535
426
  this.pushAirConditionerStatusChanges();
536
427
  }
537
428
  async CurrentTemperatureUndefined() {
538
429
  if (this.CurrentTemperature === undefined) {
539
430
  this.CurrentTemperature = 24;
540
431
  }
541
- if (this.CurrentTemperatureCached === undefined) {
432
+ if (this.accessory.context.CurrentTemperature === undefined) {
542
433
  this.CurrentTemperature = 30;
543
434
  }
544
435
  }
436
+ async updateHomeKitCharacteristics() {
437
+ if (this.Active === undefined) {
438
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
439
+ }
440
+ else {
441
+ this.accessory.context.Active = this.Active;
442
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
443
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
444
+ }
445
+ if (this.RotationSpeed === undefined) {
446
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
447
+ }
448
+ else {
449
+ this.accessory.context.RotationSpeed = this.RotationSpeed;
450
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
451
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
452
+ }
453
+ if (this.CurrentTemperature === undefined) {
454
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
455
+ }
456
+ else {
457
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
458
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
459
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
460
+ }
461
+ if (this.TargetHeaterCoolerState === undefined) {
462
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
463
+ }
464
+ else {
465
+ this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
466
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
467
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
468
+ }
469
+ if (this.CurrentHeaterCoolerState === undefined) {
470
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
471
+ }
472
+ else {
473
+ this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
474
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
475
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
476
+ + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
477
+ }
478
+ if (this.HeatingThresholdTemperature === undefined) {
479
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
480
+ }
481
+ else {
482
+ this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
483
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
484
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
485
+ + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
486
+ }
487
+ if (this.CoolingThresholdTemperature === undefined) {
488
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
489
+ }
490
+ else {
491
+ this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
492
+ this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
493
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
494
+ + ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
495
+ }
496
+ }
497
+ async statusCode({ res }) {
498
+ switch (res.statusCode) {
499
+ case 151:
500
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
501
+ break;
502
+ case 152:
503
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
504
+ break;
505
+ case 160:
506
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
507
+ break;
508
+ case 161:
509
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
510
+ break;
511
+ case 171:
512
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
513
+ break;
514
+ case 190:
515
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
516
+ ` with server, Or command: ${(0, super_stringify_1.default)(res)} format is invalid`);
517
+ break;
518
+ case 100:
519
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
520
+ break;
521
+ default:
522
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
523
+ }
524
+ }
525
+ async apiError(e) {
526
+ this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
527
+ this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
528
+ this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
529
+ this.coolerService.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
530
+ this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
531
+ this.coolerService.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
532
+ this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
533
+ }
534
+ FirmwareRevision(accessory, device) {
535
+ let FirmwareRevision;
536
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
537
+ + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
538
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
539
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
540
+ if (accessory.context.FirmwareRevision) {
541
+ FirmwareRevision = accessory.context.FirmwareRevision;
542
+ }
543
+ else if (device.firmware) {
544
+ FirmwareRevision = device.firmware;
545
+ }
546
+ else {
547
+ FirmwareRevision = this.platform.version;
548
+ }
549
+ return FirmwareRevision;
550
+ }
551
+ async context(device) {
552
+ if (this.Active === undefined) {
553
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
554
+ }
555
+ else {
556
+ this.Active = this.accessory.context.Active;
557
+ }
558
+ if (this.CurrentTemperature === undefined) {
559
+ this.CurrentTemperature = 24;
560
+ }
561
+ else {
562
+ this.CurrentTemperature = this.accessory.context.CurrentTemperature;
563
+ }
564
+ if (device.irair?.hide_automode) {
565
+ this.hide_automode = device.irair?.hide_automode;
566
+ this.accessory.context.hide_automode = this.hide_automode;
567
+ }
568
+ else {
569
+ this.hide_automode = device.irair?.hide_automode;
570
+ this.accessory.context.hide_automode = this.hide_automode;
571
+ }
572
+ }
545
573
  async config(device) {
546
574
  let config = {};
547
575
  if (device.irair) {
@@ -550,26 +578,29 @@ class AirConditioner {
550
578
  if (device.logging !== undefined) {
551
579
  config['logging'] = device.logging;
552
580
  }
581
+ if (device.connectionType !== undefined) {
582
+ config['connectionType'] = device.connectionType;
583
+ }
553
584
  if (Object.entries(config).length !== 0) {
554
- this.infoLog(`Air Conditioner: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
585
+ this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${(0, super_stringify_1.default)(config)}`);
555
586
  }
556
587
  }
557
588
  async logs(device) {
558
589
  if (this.platform.debugMode) {
559
590
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
560
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
591
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
561
592
  }
562
593
  else if (device.logging) {
563
594
  this.deviceLogging = this.accessory.context.logging = device.logging;
564
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
595
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
565
596
  }
566
597
  else if (this.platform.config.options?.logging) {
567
598
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
568
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
599
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
569
600
  }
570
601
  else {
571
602
  this.deviceLogging = this.accessory.context.logging = 'standard';
572
- this.debugLog(`Air Conditioner: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
603
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
573
604
  }
574
605
  }
575
606
  async pushOnChanges(device) {