@switchbot/homebridge-switchbot 3.5.0-beta.26 → 3.5.0-beta.28

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 (108) hide show
  1. package/dist/device/blindtilt.d.ts.map +1 -1
  2. package/dist/device/blindtilt.js +19 -16
  3. package/dist/device/blindtilt.js.map +1 -1
  4. package/dist/device/bot.js +15 -15
  5. package/dist/device/bot.js.map +1 -1
  6. package/dist/device/ceilinglight.js +8 -8
  7. package/dist/device/ceilinglight.js.map +1 -1
  8. package/dist/device/colorbulb.js +4 -4
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.js +6 -6
  11. package/dist/device/contact.js.map +1 -1
  12. package/dist/device/curtain.d.ts.map +1 -1
  13. package/dist/device/curtain.js +13 -13
  14. package/dist/device/curtain.js.map +1 -1
  15. package/dist/device/device.d.ts +2 -1
  16. package/dist/device/device.d.ts.map +1 -1
  17. package/dist/device/device.js +10 -3
  18. package/dist/device/device.js.map +1 -1
  19. package/dist/device/hub.d.ts.map +1 -1
  20. package/dist/device/hub.js +7 -7
  21. package/dist/device/hub.js.map +1 -1
  22. package/dist/device/humidifier.js +5 -5
  23. package/dist/device/humidifier.js.map +1 -1
  24. package/dist/device/iosensor.js +6 -6
  25. package/dist/device/iosensor.js.map +1 -1
  26. package/dist/device/lightstrip.js +4 -4
  27. package/dist/device/lightstrip.js.map +1 -1
  28. package/dist/device/lock.js +7 -7
  29. package/dist/device/lock.js.map +1 -1
  30. package/dist/device/meter.js +6 -6
  31. package/dist/device/meter.js.map +1 -1
  32. package/dist/device/meterplus.js +6 -6
  33. package/dist/device/meterplus.js.map +1 -1
  34. package/dist/device/motion.js +6 -7
  35. package/dist/device/motion.js.map +1 -1
  36. package/dist/device/plug.js +4 -4
  37. package/dist/device/plug.js.map +1 -1
  38. package/dist/device/robotvacuumcleaner.js +6 -6
  39. package/dist/device/robotvacuumcleaner.js.map +1 -1
  40. package/dist/device/waterdetector.d.ts.map +1 -1
  41. package/dist/device/waterdetector.js +10 -17
  42. package/dist/device/waterdetector.js.map +1 -1
  43. package/dist/irdevice/airconditioner.d.ts +4 -14
  44. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  45. package/dist/irdevice/airconditioner.js +227 -235
  46. package/dist/irdevice/airconditioner.js.map +1 -1
  47. package/dist/irdevice/airpurifier.d.ts +3 -6
  48. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  49. package/dist/irdevice/airpurifier.js +66 -57
  50. package/dist/irdevice/airpurifier.js.map +1 -1
  51. package/dist/irdevice/camera.d.ts +2 -3
  52. package/dist/irdevice/camera.d.ts.map +1 -1
  53. package/dist/irdevice/camera.js +25 -28
  54. package/dist/irdevice/camera.js.map +1 -1
  55. package/dist/irdevice/fan.d.ts +2 -7
  56. package/dist/irdevice/fan.d.ts.map +1 -1
  57. package/dist/irdevice/fan.js +58 -62
  58. package/dist/irdevice/fan.js.map +1 -1
  59. package/dist/irdevice/irdevice.d.ts +2 -1
  60. package/dist/irdevice/irdevice.d.ts.map +1 -1
  61. package/dist/irdevice/irdevice.js +10 -3
  62. package/dist/irdevice/irdevice.js.map +1 -1
  63. package/dist/irdevice/light.d.ts +1 -1
  64. package/dist/irdevice/light.d.ts.map +1 -1
  65. package/dist/irdevice/light.js +14 -16
  66. package/dist/irdevice/light.js.map +1 -1
  67. package/dist/irdevice/other.js +52 -51
  68. package/dist/irdevice/other.js.map +1 -1
  69. package/dist/irdevice/tv.js +3 -3
  70. package/dist/irdevice/tv.js.map +1 -1
  71. package/dist/irdevice/vacuumcleaner.js +2 -2
  72. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  73. package/dist/irdevice/waterheater.js +2 -2
  74. package/dist/irdevice/waterheater.js.map +1 -1
  75. package/dist/platform.d.ts.map +1 -1
  76. package/dist/platform.js +22 -1
  77. package/dist/platform.js.map +1 -1
  78. package/package.json +2 -2
  79. package/src/custom.d.ts +1 -0
  80. package/src/device/blindtilt.ts +22 -20
  81. package/src/device/bot.ts +16 -16
  82. package/src/device/ceilinglight.ts +9 -9
  83. package/src/device/colorbulb.ts +5 -5
  84. package/src/device/contact.ts +7 -7
  85. package/src/device/curtain.ts +15 -14
  86. package/src/device/device.ts +11 -3
  87. package/src/device/hub.ts +8 -7
  88. package/src/device/humidifier.ts +6 -6
  89. package/src/device/iosensor.ts +7 -7
  90. package/src/device/lightstrip.ts +5 -5
  91. package/src/device/lock.ts +8 -8
  92. package/src/device/meter.ts +7 -7
  93. package/src/device/meterplus.ts +7 -7
  94. package/src/device/motion.ts +7 -7
  95. package/src/device/plug.ts +5 -5
  96. package/src/device/robotvacuumcleaner.ts +7 -7
  97. package/src/device/waterdetector.ts +10 -18
  98. package/src/irdevice/airconditioner.ts +240 -239
  99. package/src/irdevice/airpurifier.ts +76 -57
  100. package/src/irdevice/camera.ts +28 -28
  101. package/src/irdevice/fan.ts +64 -64
  102. package/src/irdevice/irdevice.ts +11 -3
  103. package/src/irdevice/light.ts +18 -16
  104. package/src/irdevice/other.ts +52 -52
  105. package/src/irdevice/tv.ts +3 -3
  106. package/src/irdevice/vacuumcleaner.ts +2 -2
  107. package/src/irdevice/waterheater.ts +2 -2
  108. package/src/platform.ts +21 -4
@@ -15,16 +15,20 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
15
15
  */
16
16
  export class AirConditioner extends irdeviceBase {
17
17
  // Services
18
- coolerService!: Service;
19
-
20
- // Characteristic Values
21
- Active!: CharacteristicValue;
22
- RotationSpeed!: CharacteristicValue;
23
- CurrentTemperature!: CharacteristicValue;
24
- ThresholdTemperature!: CharacteristicValue;
25
- CurrentRelativeHumidity?: CharacteristicValue;
26
- TargetHeaterCoolerState!: CharacteristicValue;
27
- CurrentHeaterCoolerState!: CharacteristicValue;
18
+ private HeaterCooler: {
19
+ Service: Service;
20
+ Active: CharacteristicValue;
21
+ CurrentHeaterCoolerState: CharacteristicValue;
22
+ TargetHeaterCoolerState: CharacteristicValue;
23
+ CurrentTemperature: CharacteristicValue;
24
+ ThresholdTemperature: CharacteristicValue;
25
+ RotationSpeed: CharacteristicValue;
26
+ };
27
+
28
+ private HumiditySensor?: {
29
+ Service: Service;
30
+ CurrentRelativeHumidity: CharacteristicValue;
31
+ };
28
32
 
29
33
  // Others
30
34
  state!: string;
@@ -33,9 +37,6 @@ export class AirConditioner extends irdeviceBase {
33
37
  CurrentMode!: number;
34
38
  ValidValues: number[];
35
39
  CurrentFanSpeed!: number;
36
- static MODE_AUTO: number;
37
- static MODE_COOL: number;
38
- static MODE_HEAT: number;
39
40
 
40
41
  // Config
41
42
  hide_automode?: boolean;
@@ -45,9 +46,6 @@ export class AirConditioner extends irdeviceBase {
45
46
  set_min_cool?: number;
46
47
  meter?: PlatformAccessory;
47
48
 
48
- private readonly valid12 = [1, 2];
49
- private readonly valid012 = [0, 1, 2];
50
-
51
49
  constructor(
52
50
  readonly platform: SwitchBotPlatform,
53
51
  accessory: PlatformAccessory,
@@ -55,90 +53,44 @@ export class AirConditioner extends irdeviceBase {
55
53
  ) {
56
54
  super(platform, accessory, device);
57
55
 
58
- if (this.Active === undefined) {
59
- this.Active = this.hap.Characteristic.Active.INACTIVE;
60
- } else if (this.Active) {
61
- this.Active;
62
- } else {
63
- this.Active = this.accessory.context.Active;
64
- }
65
-
66
- if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
67
- this.CurrentTemperature = 24;
68
- } else {
69
- this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
70
- }
71
-
72
- if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
73
- this.ThresholdTemperature = 24;
74
- } else {
75
- this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
76
- }
77
-
78
- if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
79
- this.RotationSpeed = 4;
80
- } else {
81
- this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
82
- }
83
-
84
- if (this.device.irair?.hide_automode) {
85
- this.hide_automode = this.device.irair?.hide_automode;
86
- this.accessory.context.hide_automode = this.hide_automode;
87
- } else {
88
- this.hide_automode = this.device.irair?.hide_automode;
89
- this.accessory.context.hide_automode = this.hide_automode;
90
- }
91
-
92
- if (this.device.irair?.set_max_heat) {
93
- this.set_max_heat = this.device.irair?.set_max_heat;
94
- this.accessory.context.set_max_heat = this.set_max_heat;
95
- } else {
96
- this.set_max_heat = 35;
97
- this.accessory.context.set_max_heat = this.set_max_heat;
98
- }
99
- if (this.device.irair?.set_min_heat) {
100
- this.set_min_heat = this.device.irair?.set_min_heat;
101
- this.accessory.context.set_min_heat = this.set_min_heat;
102
- } else {
103
- this.set_min_heat = 0;
104
- this.accessory.context.set_min_heat = this.set_min_heat;
105
- }
106
-
107
- if (this.device.irair?.set_max_cool) {
108
- this.set_max_cool = this.device.irair?.set_max_cool;
109
- this.accessory.context.set_max_cool = this.set_max_cool;
110
- } else {
111
- this.set_max_cool = 35;
112
- this.accessory.context.set_max_cool = this.set_max_cool;
113
- }
114
- if (this.device.irair?.set_min_cool) {
115
- this.set_min_cool = this.device.irair?.set_min_cool;
116
- this.accessory.context.set_min_cool = this.set_min_cool;
117
- } else {
118
- this.set_min_cool = 0;
119
- this.accessory.context.set_min_cool = this.set_min_cool;
120
- }
121
-
122
- if (this.meter) {
123
- if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
124
- this.CurrentRelativeHumidity = 0;
125
- } else {
126
- this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
127
- }
56
+ // default placeholders
57
+ this.getAirConditionerConfigSettings(accessory, device);
58
+
59
+ // Initialize HeaterCooler property
60
+ this.HeaterCooler = {
61
+ Service: accessory.getService(this.hap.Service.Switch)!,
62
+ Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
63
+ CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState || this.hap.Characteristic.CurrentHeaterCoolerState.IDLE,
64
+ TargetHeaterCoolerState: accessory.context.TargetHeaterCoolerState || this.hap.Characteristic.TargetHeaterCoolerState.AUTO,
65
+ CurrentTemperature: accessory.context.CurrentTemperature || 24,
66
+ ThresholdTemperature: accessory.context.ThresholdTemperature || 24,
67
+ RotationSpeed: accessory.context.RotationSpeed || 4,
68
+ };
69
+
70
+ // Initialize HumiditySensor property
71
+ if (this.device.irair?.meterType && this.device.irair?.meterId) {
72
+ const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
73
+ this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
74
+ this.HumiditySensor = {
75
+ Service: this.meter!.getService(this.hap.Service.HumiditySensor)!,
76
+ CurrentRelativeHumidity: this.meter!.context.CurrentRelativeHumidity || 0,
77
+ };
128
78
  }
129
79
 
130
80
  // get the Television service if it exists, otherwise create a new Television service
131
81
  // you can create multiple services for each accessory
132
- const coolerService = `${accessory.displayName} ${device.remoteType}`;
133
- (this.coolerService = accessory.getService(this.hap.Service.HeaterCooler)
134
- || accessory.addService(this.hap.Service.HeaterCooler)), coolerService;
82
+ const HeaterCoolerService = `${accessory.displayName} ${device.remoteType}`;
83
+ (this.HeaterCooler.Service = accessory.getService(this.hap.Service.HeaterCooler)
84
+ || accessory.addService(this.hap.Service.HeaterCooler)), HeaterCoolerService;
135
85
 
136
- this.coolerService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
86
+ this.HeaterCooler.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
137
87
 
138
88
  // handle on / off events using the Active characteristic
139
- this.coolerService.getCharacteristic(this.hap.Characteristic.Active).onSet(this.ActiveSet.bind(this));
89
+ this.HeaterCooler.Service.getCharacteristic(this.hap.Characteristic.Active)
90
+ .onSet(this.ActiveSet.bind(this));
140
91
 
141
- this.coolerService.getCharacteristic(this.hap.Characteristic.CurrentTemperature).onGet(this.CurrentTemperatureGet.bind(this));
92
+ this.HeaterCooler.Service.getCharacteristic(this.hap.Characteristic.CurrentTemperature)
93
+ .onGet(this.CurrentTemperatureGet.bind(this));
142
94
 
143
95
  this.ValidValues = this.hide_automode ? [1, 2] : [0, 1, 2];
144
96
 
@@ -148,10 +100,11 @@ export class AirConditioner extends irdeviceBase {
148
100
  }
149
101
 
150
102
  if (this.meter) {
151
- this.coolerService.getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity).onGet(this.CurrentRelativeHumidityGet.bind(this));
103
+ this.HumiditySensor!.Service.getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
104
+ .onGet(this.CurrentRelativeHumidityGet.bind(this));
152
105
  }
153
106
 
154
- this.coolerService
107
+ this.HeaterCooler.Service
155
108
  .getCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState)
156
109
  .setProps({
157
110
  validValues: this.ValidValues,
@@ -159,9 +112,10 @@ export class AirConditioner extends irdeviceBase {
159
112
  .onGet(this.TargetHeaterCoolerStateGet.bind(this))
160
113
  .onSet(this.TargetHeaterCoolerStateSet.bind(this));
161
114
 
162
- this.coolerService.getCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState).onGet(this.CurrentHeaterCoolerStateGet.bind(this));
115
+ this.HeaterCooler.Service.getCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState)
116
+ .onGet(this.CurrentHeaterCoolerStateGet.bind(this));
163
117
 
164
- this.coolerService
118
+ this.HeaterCooler.Service
165
119
  .getCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature)
166
120
  .setProps({
167
121
  minValue: this.set_min_heat,
@@ -171,7 +125,7 @@ export class AirConditioner extends irdeviceBase {
171
125
  .onGet(this.ThresholdTemperatureGet.bind(this))
172
126
  .onSet(this.ThresholdTemperatureSet.bind(this));
173
127
 
174
- this.coolerService
128
+ this.HeaterCooler.Service
175
129
  .getCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature)
176
130
  .setProps({
177
131
  minValue: this.set_min_cool,
@@ -181,7 +135,7 @@ export class AirConditioner extends irdeviceBase {
181
135
  .onGet(this.ThresholdTemperatureGet.bind(this))
182
136
  .onSet(this.ThresholdTemperatureSet.bind(this));
183
137
 
184
- this.coolerService
138
+ this.HeaterCooler.Service
185
139
  .getCharacteristic(this.hap.Characteristic.RotationSpeed)
186
140
  .setProps({
187
141
  format: 'int',
@@ -204,10 +158,10 @@ export class AirConditioner extends irdeviceBase {
204
158
  */
205
159
  async pushAirConditionerOnChanges(): Promise<void> {
206
160
  this.debugLog(
207
- `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.Active},` +
161
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active},` +
208
162
  ` disablePushOn: ${this.disablePushOn}`,
209
163
  );
210
- if (this.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
164
+ if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
211
165
  const commandType: string = await this.commandType();
212
166
  const command: string = await this.commandOn();
213
167
  const bodyChange = JSON.stringify({
@@ -221,10 +175,10 @@ export class AirConditioner extends irdeviceBase {
221
175
 
222
176
  async pushAirConditionerOffChanges(): Promise<void> {
223
177
  this.debugLog(
224
- `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.Active},` +
178
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active},` +
225
179
  ` disablePushOff: ${this.disablePushOff}`,
226
180
  );
227
- if (this.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
181
+ if (this.HeaterCooler.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
228
182
  const commandType: string = await this.commandType();
229
183
  const command: string = await this.commandOff();
230
184
  const bodyChange = JSON.stringify({
@@ -238,12 +192,12 @@ export class AirConditioner extends irdeviceBase {
238
192
 
239
193
  async pushAirConditionerStatusChanges(): Promise<void> {
240
194
  this.debugLog(
241
- `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.Active},` +
195
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active},` +
242
196
  ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
243
197
  );
244
198
  if (!this.Busy) {
245
199
  this.Busy = true;
246
- this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
200
+ this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
247
201
  }
248
202
  clearTimeout(this.Timeout);
249
203
 
@@ -253,7 +207,7 @@ export class AirConditioner extends irdeviceBase {
253
207
 
254
208
  async pushAirConditionerDetailsChanges(): Promise<void> {
255
209
  this.debugLog(
256
- `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.Active},` +
210
+ `${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active},` +
257
211
  ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
258
212
  );
259
213
  //await this.deviceContext();
@@ -263,20 +217,20 @@ export class AirConditioner extends irdeviceBase {
263
217
  if (this.CurrentFanSpeed === undefined) {
264
218
  this.CurrentFanSpeed = 1;
265
219
  }
266
- if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
220
+ if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
267
221
  this.state = 'on';
268
222
  } else {
269
223
  this.state = 'off';
270
224
  }
271
225
  if (this.CurrentMode === 1) {
272
226
  // Remove or make configurable?
273
- this.ThresholdTemperature = 25;
227
+ this.HeaterCooler.ThresholdTemperature = 25;
274
228
  this.debugLog(
275
229
  `${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` +
276
- ` ThresholdTemperature: ${this.ThresholdTemperature}`,
230
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`,
277
231
  );
278
232
  }
279
- const parameter = `${this.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
233
+ const parameter = `${this.HeaterCooler.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
280
234
 
281
235
  await this.UpdateCurrentHeaterCoolerState();
282
236
  const bodyChange = JSON.stringify({
@@ -289,32 +243,32 @@ export class AirConditioner extends irdeviceBase {
289
243
  }
290
244
 
291
245
  private async UpdateCurrentHeaterCoolerState() {
292
- if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
246
+ if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
293
247
 
294
- if (this.Active === undefined) {
295
- this.Active = this.hap.Characteristic.Active.INACTIVE;
296
- } else if (this.Active) {
297
- this.Active;
248
+ if (this.HeaterCooler.Active === undefined) {
249
+ this.HeaterCooler.Active = this.hap.Characteristic.Active.INACTIVE;
250
+ } else if (this.HeaterCooler.Active) {
251
+ this.HeaterCooler.Active;
298
252
  } else {
299
- this.Active = this.accessory.context.Active;
253
+ this.HeaterCooler.Active = this.accessory.context.Active;
300
254
  }
301
255
 
302
- if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
303
- this.CurrentTemperature = 24;
256
+ if (this.HeaterCooler.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
257
+ this.HeaterCooler.CurrentTemperature = 24;
304
258
  } else {
305
- this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
259
+ this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
306
260
  }
307
261
 
308
- if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
309
- this.ThresholdTemperature = 24;
262
+ if (this.HeaterCooler.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
263
+ this.HeaterCooler.ThresholdTemperature = 24;
310
264
  } else {
311
- this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
265
+ this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
312
266
  }
313
267
 
314
- if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
315
- this.RotationSpeed = 4;
268
+ if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
269
+ this.HeaterCooler.RotationSpeed = 4;
316
270
  } else {
317
- this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
271
+ this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
318
272
  }
319
273
 
320
274
  if (this.device.irair?.hide_automode) {
@@ -356,23 +310,24 @@ export class AirConditioner extends irdeviceBase {
356
310
  }
357
311
 
358
312
  if (this.meter) {
359
- if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
360
- this.CurrentRelativeHumidity = 0;
313
+ if (this.HumiditySensor!.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
314
+ this.HumiditySensor!.CurrentRelativeHumidity = 0;
361
315
  } else {
362
- this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
316
+ this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity
317
+ || this.accessory.context.CurrentRelativeHumidity;
363
318
  }
364
319
  }
365
- if (this.ThresholdTemperature < this.CurrentTemperature &&
366
- this.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.HEAT) {
367
- this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
368
- } else if (this.ThresholdTemperature > this.CurrentTemperature &&
369
- this.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
370
- this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
320
+ if (this.HeaterCooler.ThresholdTemperature < this.HeaterCooler.CurrentTemperature &&
321
+ this.HeaterCooler.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.HEAT) {
322
+ this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
323
+ } else if (this.HeaterCooler.ThresholdTemperature > this.HeaterCooler.CurrentTemperature &&
324
+ this.HeaterCooler.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
325
+ this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
371
326
  } else {
372
- this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
327
+ this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
373
328
  }
374
329
  } else {
375
- this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
330
+ this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
376
331
  }
377
332
  }
378
333
 
@@ -391,7 +346,7 @@ export class AirConditioner extends irdeviceBase {
391
346
  this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
392
347
  this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
393
348
  if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
394
- this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
349
+ this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
395
350
  + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
396
351
  this.successLog(`${this.device.remoteType}: ${this.accessory.displayName} request to SwitchBot API, body: ${bodyChange} sent successfully`);
397
352
  this.updateHomeKitCharacteristics();
@@ -428,9 +383,9 @@ export class AirConditioner extends irdeviceBase {
428
383
  );
429
384
  }
430
385
 
431
- this.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
432
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
433
- return this.CurrentTemperature;
386
+ this.HeaterCooler.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
387
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
388
+ return this.HeaterCooler.CurrentTemperature;
434
389
  }
435
390
 
436
391
  async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
@@ -442,19 +397,20 @@ export class AirConditioner extends irdeviceBase {
442
397
  );
443
398
  }
444
399
 
445
- this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
446
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
447
- return this.CurrentRelativeHumidity as CharacteristicValue;
400
+ this.HumiditySensor!.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
401
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get`
402
+ + ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
403
+ return this.HumiditySensor!.CurrentRelativeHumidity as CharacteristicValue;
448
404
  }
449
405
 
450
406
  async RotationSpeedGet(): Promise<number> {
451
407
  if (!this.CurrentFanSpeed || this.CurrentFanSpeed === 1) {
452
- this.RotationSpeed = 4;
408
+ this.HeaterCooler.RotationSpeed = 4;
453
409
  } else {
454
- this.RotationSpeed = this.CurrentFanSpeed - 1;
410
+ this.HeaterCooler.RotationSpeed = this.CurrentFanSpeed - 1;
455
411
  }
456
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
457
- return this.RotationSpeed;
412
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
413
+ return this.HeaterCooler.RotationSpeed;
458
414
  }
459
415
 
460
416
  async RotationSpeedSet(value: CharacteristicValue): Promise<void> {
@@ -463,37 +419,35 @@ export class AirConditioner extends irdeviceBase {
463
419
  } else {
464
420
  this.CurrentFanSpeed = Number(value) + 1;
465
421
  }
466
- this.RotationSpeed = value;
422
+ this.HeaterCooler.RotationSpeed = value;
467
423
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` +
468
- `Set RotationSpeed: ${this.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
424
+ `Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
469
425
  this.pushAirConditionerStatusChanges();
470
426
  }
471
427
 
472
428
  async ActiveSet(value: CharacteristicValue): Promise<void> {
473
429
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
474
430
 
475
- this.Active = value;
476
- if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
477
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
431
+ this.HeaterCooler.Active = value;
432
+ if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
433
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`);
478
434
  if (this.disablePushOn) {
479
435
  this.pushAirConditionerStatusChanges();
480
436
  } else {
481
437
  this.pushAirConditionerOnChanges();
482
438
  }
483
439
  } else {
484
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
440
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`);
485
441
  this.pushAirConditionerOffChanges();
486
442
  }
487
443
  }
488
444
 
489
445
  async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
490
- const targetState = this.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
491
- this.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
492
- this.debugLog(
493
- `${this.device.remoteType}: ${this.accessory.displayName} Get (${this.getTargetHeaterCoolerStateName()})` +
494
- ` TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`,
495
- );
496
- return this.TargetHeaterCoolerState;
446
+ const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
447
+ this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
448
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState:`
449
+ + ` ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`);
450
+ return this.HeaterCooler.TargetHeaterCoolerState;
497
451
  }
498
452
 
499
453
  async TargetHeaterCoolerStateSet(value: CharacteristicValue): Promise<void> {
@@ -505,7 +459,7 @@ export class AirConditioner extends irdeviceBase {
505
459
  this.TargetHeaterCoolerStateCOOL();
506
460
  } else {
507
461
  this.errorLog(
508
- `${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
462
+ `${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState},` +
509
463
  ` hide_automode: ${this.hide_automode} `,
510
464
  );
511
465
  }
@@ -513,23 +467,26 @@ export class AirConditioner extends irdeviceBase {
513
467
  }
514
468
 
515
469
  async TargetHeaterCoolerStateAUTO(): Promise<void> {
516
- this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
470
+ this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
517
471
  this.CurrentMode = 1;
518
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
472
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO)`
473
+ + ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
519
474
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
520
475
  }
521
476
 
522
477
  async TargetHeaterCoolerStateCOOL(): Promise<void> {
523
- this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
478
+ this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
524
479
  this.CurrentMode = 2;
525
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
480
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL)`
481
+ + ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
526
482
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
527
483
  }
528
484
 
529
485
  async TargetHeaterCoolerStateHEAT(): Promise<void> {
530
- this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
486
+ this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
531
487
  this.CurrentMode = 5;
532
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
488
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT)`
489
+ + ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
533
490
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
534
491
  }
535
492
 
@@ -537,15 +494,15 @@ export class AirConditioner extends irdeviceBase {
537
494
  await this.UpdateCurrentHeaterCoolerState();
538
495
  this.debugLog(
539
496
  `${this.device.remoteType}: ${this.accessory.displayName}` +
540
- ` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
497
+ ` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`,
541
498
  );
542
499
 
543
- return this.CurrentHeaterCoolerState;
500
+ return this.HeaterCooler.CurrentHeaterCoolerState;
544
501
  }
545
502
 
546
503
 
547
504
  private getTargetHeaterCoolerStateName(): string {
548
- switch (this.TargetHeaterCoolerState) {
505
+ switch (this.HeaterCooler.TargetHeaterCoolerState) {
549
506
  case this.hap.Characteristic.TargetHeaterCoolerState.AUTO:
550
507
  return 'AUTO';
551
508
  case this.hap.Characteristic.TargetHeaterCoolerState.HEAT:
@@ -553,36 +510,36 @@ export class AirConditioner extends irdeviceBase {
553
510
  case this.hap.Characteristic.TargetHeaterCoolerState.COOL:
554
511
  return 'COOL';
555
512
  default:
556
- return this.TargetHeaterCoolerState.toString();
513
+ return this.HeaterCooler.TargetHeaterCoolerState.toString();
557
514
  }
558
515
  }
559
516
 
560
517
  async ThresholdTemperatureGet(): Promise<CharacteristicValue> {
561
518
 
562
- if (this.Active === undefined) {
563
- this.Active = this.hap.Characteristic.Active.INACTIVE;
564
- } else if (this.Active) {
565
- this.Active;
519
+ if (this.HeaterCooler.Active === undefined) {
520
+ this.HeaterCooler.Active = this.hap.Characteristic.Active.INACTIVE;
521
+ } else if (this.HeaterCooler.Active) {
522
+ this.HeaterCooler.Active;
566
523
  } else {
567
- this.Active = this.accessory.context.Active;
524
+ this.HeaterCooler.Active = this.accessory.context.Active;
568
525
  }
569
526
 
570
- if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
571
- this.CurrentTemperature = 24;
527
+ if (this.HeaterCooler.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
528
+ this.HeaterCooler.CurrentTemperature = 24;
572
529
  } else {
573
- this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
530
+ this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
574
531
  }
575
532
 
576
- if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
577
- this.ThresholdTemperature = 24;
533
+ if (this.HeaterCooler.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
534
+ this.HeaterCooler.ThresholdTemperature = 24;
578
535
  } else {
579
- this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
536
+ this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
580
537
  }
581
538
 
582
- if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
583
- this.RotationSpeed = 4;
539
+ if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
540
+ this.HeaterCooler.RotationSpeed = 4;
584
541
  } else {
585
- this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
542
+ this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
586
543
  }
587
544
 
588
545
  if (this.device.irair?.hide_automode) {
@@ -624,20 +581,20 @@ export class AirConditioner extends irdeviceBase {
624
581
  }
625
582
 
626
583
  if (this.meter) {
627
- if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
628
- this.CurrentRelativeHumidity = 0;
584
+ if (this.HumiditySensor!.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
585
+ this.HumiditySensor!.CurrentRelativeHumidity = 0;
629
586
  } else {
630
- this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
587
+ this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
631
588
  }
632
589
  }
633
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.ThresholdTemperature}`);
634
- return this.ThresholdTemperature;
590
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
591
+ return this.HeaterCooler.ThresholdTemperature;
635
592
  }
636
593
 
637
594
  async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
638
- this.ThresholdTemperature = value;
595
+ this.HeaterCooler.ThresholdTemperature = value;
639
596
  this.debugLog(
640
- `${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.ThresholdTemperature},` +
597
+ `${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature},` +
641
598
  ` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`,
642
599
  );
643
600
  this.pushAirConditionerStatusChanges();
@@ -645,83 +602,127 @@ export class AirConditioner extends irdeviceBase {
645
602
 
646
603
  async updateHomeKitCharacteristics(): Promise<void> {
647
604
  // Active
648
- if (this.Active === undefined) {
649
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
605
+ if (this.HeaterCooler.Active === undefined) {
606
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.HeaterCooler.Active}`);
650
607
  } else {
651
- this.accessory.context.Active = this.Active;
652
- this.coolerService?.updateCharacteristic(this.hap.Characteristic.Active, this.Active);
653
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
608
+ this.accessory.context.Active = this.HeaterCooler.Active;
609
+ this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.Active, this.HeaterCooler.Active);
610
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HeaterCooler.Active}`);
654
611
  }
655
612
  // RotationSpeed
656
- if (this.RotationSpeed === undefined) {
657
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
613
+ if (this.HeaterCooler.RotationSpeed === undefined) {
614
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
658
615
  } else {
659
- this.accessory.context.RotationSpeed = this.RotationSpeed;
660
- this.coolerService?.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.RotationSpeed);
661
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
616
+ this.accessory.context.RotationSpeed = this.HeaterCooler.RotationSpeed;
617
+ this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.HeaterCooler.RotationSpeed);
618
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
619
+ + ` RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
662
620
  }
663
621
  // CurrentTemperature
664
- if (this.CurrentTemperature === undefined) {
665
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
622
+ if (this.HeaterCooler.CurrentTemperature === undefined) {
623
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
666
624
  } else {
667
- this.accessory.context.CurrentTemperature = this.CurrentTemperature;
668
- this.coolerService?.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.CurrentTemperature);
669
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
625
+ this.accessory.context.CurrentTemperature = this.HeaterCooler.CurrentTemperature;
626
+ this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.HeaterCooler.CurrentTemperature);
627
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
628
+ + ` CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
670
629
  }
671
630
  // CurrentRelativeHumidity
672
631
  if (this.meter) {
673
- if (this.CurrentRelativeHumidity === undefined) {
674
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
632
+ if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
633
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
634
+ + ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
675
635
  } else {
676
- this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
677
- this.coolerService?.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
636
+ this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
637
+ this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
638
+ this.HumiditySensor!.CurrentRelativeHumidity);
678
639
  this.debugLog(
679
- `${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
640
+ `${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
641
+ + ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`,
680
642
  );
681
643
  }
682
644
  }
683
645
  // TargetHeaterCoolerState
684
- if (this.TargetHeaterCoolerState === undefined) {
685
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
646
+ if (this.HeaterCooler.TargetHeaterCoolerState === undefined) {
647
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
686
648
  } else {
687
- this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
688
- this.coolerService?.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
689
- this.debugLog(
690
- `${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
691
- );
649
+ this.accessory.context.TargetHeaterCoolerState = this.HeaterCooler.TargetHeaterCoolerState;
650
+ this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.HeaterCooler.TargetHeaterCoolerState);
651
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
652
+ + ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
692
653
  }
693
654
  // CurrentHeaterCoolerState
694
- if (this.CurrentHeaterCoolerState === undefined) {
695
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
655
+ if (this.HeaterCooler.CurrentHeaterCoolerState === undefined) {
656
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
657
+ + ` CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
696
658
  } else {
697
- this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
698
- this.coolerService?.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
659
+ this.accessory.context.CurrentHeaterCoolerState = this.HeaterCooler.CurrentHeaterCoolerState;
660
+ this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.HeaterCooler.CurrentHeaterCoolerState);
699
661
  this.debugLog(
700
662
  `${this.device.remoteType}: ${this.accessory.displayName}` +
701
- ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
663
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`,
702
664
  );
703
665
  }
704
666
  // ThresholdTemperature
705
- if (this.ThresholdTemperature === undefined) {
706
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.ThresholdTemperature}`);
667
+ if (this.HeaterCooler.ThresholdTemperature === undefined) {
668
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
707
669
  } else {
708
- this.accessory.context.ThresholdTemperature = this.ThresholdTemperature;
709
- this.coolerService?.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.ThresholdTemperature);
710
- this.coolerService?.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.ThresholdTemperature);
711
- this.debugLog(
712
- `${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic ThresholdTemperature: ${this.ThresholdTemperature}`,
713
- );
670
+ this.accessory.context.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature;
671
+ this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
672
+ this.HeaterCooler.Service?.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
673
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
674
+ + ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
714
675
  }
715
676
  }
716
677
 
717
678
  async apiError({ e }: { e: any }): Promise<void> {
718
- this.coolerService.updateCharacteristic(this.hap.Characteristic.Active, e);
719
- this.coolerService.updateCharacteristic(this.hap.Characteristic.RotationSpeed, e);
720
- this.coolerService.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
721
- this.coolerService.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e);
722
- this.coolerService.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, e);
723
- this.coolerService.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
724
- this.coolerService.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, e);
725
- this.coolerService.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, e);
679
+ this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
680
+ this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, e);
681
+ this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
682
+ this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e);
683
+ this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, e);
684
+ this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
685
+ this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, e);
686
+ this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, e);
687
+ }
688
+
689
+ async getAirConditionerConfigSettings(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): Promise<void> {
690
+ if (this.device.irair?.hide_automode) {
691
+ this.hide_automode = device.irair?.hide_automode;
692
+ accessory.context.hide_automode = this.hide_automode;
693
+ } else {
694
+ this.hide_automode = device.irair?.hide_automode;
695
+ accessory.context.hide_automode = this.hide_automode;
696
+ }
697
+
698
+ if (this.device.irair?.set_max_heat) {
699
+ this.set_max_heat = device.irair?.set_max_heat;
700
+ accessory.context.set_max_heat = this.set_max_heat;
701
+ } else {
702
+ this.set_max_heat = 35;
703
+ accessory.context.set_max_heat = this.set_max_heat;
704
+ }
705
+ if (this.device.irair?.set_min_heat) {
706
+ this.set_min_heat = device.irair?.set_min_heat;
707
+ accessory.context.set_min_heat = this.set_min_heat;
708
+ } else {
709
+ this.set_min_heat = 0;
710
+ accessory.context.set_min_heat = this.set_min_heat;
711
+ }
712
+
713
+ if (this.device.irair?.set_max_cool) {
714
+ this.set_max_cool = device.irair?.set_max_cool;
715
+ accessory.context.set_max_cool = this.set_max_cool;
716
+ } else {
717
+ this.set_max_cool = 35;
718
+ accessory.context.set_max_cool = this.set_max_cool;
719
+ }
720
+ if (this.device.irair?.set_min_cool) {
721
+ this.set_min_cool = device.irair?.set_min_cool;
722
+ accessory.context.set_min_cool = this.set_min_cool;
723
+ } else {
724
+ this.set_min_cool = 0;
725
+ accessory.context.set_min_cool = this.set_min_cool;
726
+ }
726
727
  }
727
728
  }