homebridge-midea-platform 1.1.2-beta.1 → 1.1.2-beta.10

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 (95) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/AC_ori.lua +5150 -0
  3. package/CHANGELOG.md +9 -1
  4. package/README.md +1 -0
  5. package/config.schema.json +26 -56
  6. package/dist/accessory/AccessoryFactory.d.ts +12 -11
  7. package/dist/accessory/AccessoryFactory.d.ts.map +1 -1
  8. package/dist/accessory/AccessoryFactory.js +31 -28
  9. package/dist/accessory/AccessoryFactory.js.map +1 -1
  10. package/dist/accessory/AirConditionerAccessory.d.ts +89 -86
  11. package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
  12. package/dist/accessory/AirConditionerAccessory.js +584 -560
  13. package/dist/accessory/AirConditionerAccessory.js.map +1 -1
  14. package/dist/accessory/BaseAccessory.d.ts +11 -11
  15. package/dist/accessory/BaseAccessory.js +21 -21
  16. package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
  17. package/dist/accessory/DehumidifierAccessory.d.ts.map +1 -1
  18. package/dist/accessory/DehumidifierAccessory.js +345 -343
  19. package/dist/accessory/DehumidifierAccessory.js.map +1 -1
  20. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
  21. package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
  22. package/dist/accessory/FanAccessory.d.ts +39 -39
  23. package/dist/accessory/FanAccessory.js +123 -123
  24. package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -30
  25. package/dist/accessory/FrontLoadWasherAccessory.js +60 -60
  26. package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
  27. package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
  28. package/dist/core/MideaCloud.d.ts +35 -35
  29. package/dist/core/MideaCloud.js +350 -350
  30. package/dist/core/MideaConstants.d.ts +49 -49
  31. package/dist/core/MideaConstants.js +57 -57
  32. package/dist/core/MideaDevice.d.ts +76 -76
  33. package/dist/core/MideaDevice.js +409 -409
  34. package/dist/core/MideaDiscover.d.ts +35 -35
  35. package/dist/core/MideaDiscover.js +212 -212
  36. package/dist/core/MideaMessage.d.ts +75 -75
  37. package/dist/core/MideaMessage.js +184 -184
  38. package/dist/core/MideaPacketBuilder.d.ts +10 -10
  39. package/dist/core/MideaPacketBuilder.js +60 -60
  40. package/dist/core/MideaSecurity.d.ts +63 -63
  41. package/dist/core/MideaSecurity.d.ts.map +1 -1
  42. package/dist/core/MideaSecurity.js +251 -242
  43. package/dist/core/MideaSecurity.js.map +1 -1
  44. package/dist/core/MideaUtils.d.ts +32 -32
  45. package/dist/core/MideaUtils.js +181 -181
  46. package/dist/devices/DeviceFactory.d.ts +12 -11
  47. package/dist/devices/DeviceFactory.d.ts.map +1 -1
  48. package/dist/devices/DeviceFactory.js +33 -30
  49. package/dist/devices/DeviceFactory.js.map +1 -1
  50. package/dist/devices/a1/MideaA1Device.d.ts +76 -76
  51. package/dist/devices/a1/MideaA1Device.js +136 -136
  52. package/dist/devices/a1/MideaA1Message.d.ts +40 -40
  53. package/dist/devices/a1/MideaA1Message.js +198 -198
  54. package/dist/devices/ac/MideaACDevice.d.ts +100 -100
  55. package/dist/devices/ac/MideaACDevice.d.ts.map +1 -1
  56. package/dist/devices/ac/MideaACDevice.js +381 -370
  57. package/dist/devices/ac/MideaACDevice.js.map +1 -1
  58. package/dist/devices/ac/MideaACMessage.d.ts +92 -92
  59. package/dist/devices/ac/MideaACMessage.js +589 -589
  60. package/dist/devices/db/MideaDBDevice.d.ts +29 -29
  61. package/dist/devices/db/MideaDBDevice.d.ts.map +1 -1
  62. package/dist/devices/db/MideaDBDevice.js +89 -88
  63. package/dist/devices/db/MideaDBDevice.js.map +1 -1
  64. package/dist/devices/db/MideaDBMessage.d.ts +32 -32
  65. package/dist/devices/db/MideaDBMessage.d.ts.map +1 -1
  66. package/dist/devices/db/MideaDBMessage.js +101 -101
  67. package/dist/devices/db/MideaDBMessage.js.map +1 -1
  68. package/dist/devices/e2/MideaE2Device.d.ts +44 -44
  69. package/dist/devices/e2/MideaE2Device.js +119 -119
  70. package/dist/devices/e2/MideaE2Message.d.ts +33 -33
  71. package/dist/devices/e2/MideaE2Message.js +132 -132
  72. package/dist/devices/e3/MideaE3Device.d.ts +43 -43
  73. package/dist/devices/e3/MideaE3Device.js +125 -125
  74. package/dist/devices/e3/MideaE3Message.d.ts +51 -51
  75. package/dist/devices/e3/MideaE3Message.js +136 -136
  76. package/dist/devices/fa/MideaFADevice.d.ts +36 -36
  77. package/dist/devices/fa/MideaFADevice.js +92 -92
  78. package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
  79. package/dist/devices/fa/MideaFAMessage.js +98 -98
  80. package/dist/index.d.ts +6 -6
  81. package/dist/index.js +6 -6
  82. package/dist/platform.d.ts +60 -60
  83. package/dist/platform.d.ts.map +1 -1
  84. package/dist/platform.js +212 -213
  85. package/dist/platform.js.map +1 -1
  86. package/dist/platformUtils.d.ts +99 -97
  87. package/dist/platformUtils.d.ts.map +1 -1
  88. package/dist/platformUtils.js +97 -95
  89. package/dist/platformUtils.js.map +1 -1
  90. package/dist/settings.d.ts +8 -8
  91. package/dist/settings.js +11 -11
  92. package/docs/ac.md +2 -0
  93. package/docs/db.md +3 -0
  94. package/homebridge-ui/server.js +30 -26
  95. package/package.json +1 -1
@@ -1,561 +1,585 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
7
- const platformUtils_1 = require("../platformUtils");
8
- class AirConditionerAccessory extends BaseAccessory_1.default {
9
- /*********************************************************************
10
- * Constructor registers all the service types with Homebridge, registers
11
- * a callback function with the MideaDevice class, and requests device status.
12
- */
13
- constructor(platform, accessory, device, configDev) {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
15
- super(platform, accessory, device, configDev);
16
- this.device = device;
17
- this.configDev = configDev;
18
- this.service =
19
- this.accessory.getService(this.platform.Service.HeaterCooler) || this.accessory.addService(this.platform.Service.HeaterCooler);
20
- this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
21
- this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
22
- this.service
23
- .getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits)
24
- .onGet(this.getTemperatureDisplayUnits.bind(this))
25
- .onSet(this.setTemperatureDisplayUnits.bind(this));
26
- this.service
27
- .getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
28
- .onGet(this.getCurrentHeaterCoolerState.bind(this));
29
- this.service
30
- .getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
31
- .onGet(this.getTargetHeaterCoolerState.bind(this))
32
- .onSet(this.setTargetHeaterCoolerState.bind(this))
33
- .setProps({
34
- validValues: this.configDev.AC_options.heatingCapable
35
- ? [
36
- this.platform.Characteristic.TargetHeaterCoolerState.AUTO,
37
- this.platform.Characteristic.TargetHeaterCoolerState.HEAT,
38
- this.platform.Characteristic.TargetHeaterCoolerState.COOL,
39
- ]
40
- : [this.platform.Characteristic.TargetHeaterCoolerState.AUTO, this.platform.Characteristic.TargetHeaterCoolerState.COOL],
41
- });
42
- this.service.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getCurrentTemperature.bind(this));
43
- this.service
44
- .getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
45
- .onGet(this.getTargetTemperature.bind(this))
46
- .onSet(this.setTargetTemperature.bind(this))
47
- .setProps({
48
- minValue: this.configDev.AC_options.minTemp,
49
- maxValue: this.configDev.AC_options.maxTemp,
50
- minStep: this.configDev.AC_options.tempStep,
51
- });
52
- this.service
53
- .getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
54
- .onGet(this.getTargetTemperature.bind(this))
55
- .onSet(this.setTargetTemperature.bind(this))
56
- .setProps({
57
- minValue: this.configDev.AC_options.minTemp,
58
- maxValue: this.configDev.AC_options.maxTemp,
59
- minStep: this.configDev.AC_options.tempStep,
60
- });
61
- this.service
62
- .getCharacteristic(this.platform.Characteristic.RotationSpeed)
63
- .onGet(this.getRotationSpeed.bind(this))
64
- .onSet(this.setRotationSpeed.bind(this));
65
- // Swing modes
66
- if (this.configDev.AC_options.swing.mode !== platformUtils_1.SwingMode.NONE) {
67
- this.service
68
- .getCharacteristic(this.platform.Characteristic.SwingMode)
69
- .onGet(this.getSwingMode.bind(this))
70
- .onSet(this.setSwingMode.bind(this));
71
- }
72
- // Outdoor temperature sensor
73
- this.outDoorTemperatureService = this.accessory.getServiceById(this.platform.Service.TemperatureSensor, 'Outdoor');
74
- if (this.configDev.AC_options.outDoorTemp) {
75
- (_a = this.outDoorTemperatureService) !== null && _a !== void 0 ? _a : (this.outDoorTemperatureService = this.accessory.addService(this.platform.Service.TemperatureSensor, `${this.device.name} Outdoor`, 'Outdoor'));
76
- this.outDoorTemperatureService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Outdoor`);
77
- this.outDoorTemperatureService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Outdoor`);
78
- this.outDoorTemperatureService
79
- .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
80
- .onGet(this.getOutdoorTemperature.bind(this));
81
- this.outDoorTemperatureService
82
- .getCharacteristic(this.platform.Characteristic.StatusFault)
83
- .onGet(() => this.device.attributes.OUTDOOR_TEMPERATURE === undefined
84
- ? this.platform.Characteristic.StatusFault.GENERAL_FAULT
85
- : this.platform.Characteristic.StatusFault.NO_FAULT);
86
- }
87
- else if (this.outDoorTemperatureService) {
88
- this.accessory.removeService(this.outDoorTemperatureService);
89
- }
90
- // Fan-only mode switch
91
- this.fanOnlyService = this.accessory.getServiceById(this.platform.Service.Switch, 'FanOnly');
92
- if (this.configDev.AC_options.fanOnlyModeSwitch) {
93
- (_b = this.fanOnlyService) !== null && _b !== void 0 ? _b : (this.fanOnlyService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} FanOnly`, 'FanOnly'));
94
- this.fanOnlyService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Fan-only Mode`);
95
- this.fanOnlyService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Fan-only Mode`);
96
- this.fanOnlyService
97
- .getCharacteristic(this.platform.Characteristic.On)
98
- .onGet(this.getFanOnlyMode.bind(this))
99
- .onSet(this.setFanOnlyMode.bind(this));
100
- }
101
- else if (this.fanOnlyService) {
102
- this.accessory.removeService(this.fanOnlyService);
103
- }
104
- // Fan accessory
105
- this.fanService = this.accessory.getServiceById(this.platform.Service.Fanv2, 'Fan');
106
- if (this.configDev.AC_options.fanAccessory) {
107
- (_c = this.fanService) !== null && _c !== void 0 ? _c : (this.fanService = this.accessory.addService(this.platform.Service.Fanv2, `${this.device.name} Fan`, 'Fan'));
108
- this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Fan`);
109
- this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Fan`);
110
- this.fanService
111
- .getCharacteristic(this.platform.Characteristic.Active)
112
- .onGet(this.getActive.bind(this))
113
- .onSet(this.setActive.bind(this));
114
- this.fanService
115
- .getCharacteristic(this.platform.Characteristic.RotationSpeed)
116
- .onGet(this.getRotationSpeed.bind(this))
117
- .onSet(this.setRotationSpeed.bind(this));
118
- this.fanService
119
- .getCharacteristic(this.platform.Characteristic.TargetFanState)
120
- .onGet(this.getFanState.bind(this))
121
- .onSet(this.setFanState.bind(this));
122
- this.fanService
123
- .getCharacteristic(this.platform.Characteristic.SwingMode)
124
- .onGet(this.getSwingMode.bind(this))
125
- .onSet(this.setSwingMode.bind(this));
126
- }
127
- else if (this.fanService) {
128
- this.accessory.removeService(this.fanService);
129
- }
130
- // Display switch
131
- this.displayService = this.accessory.getServiceById(this.platform.Service.Switch, 'Display');
132
- if (this.configDev.AC_options.displaySwitch.flag) {
133
- this.device.set_alternate_switch_display(this.configDev.AC_options.displaySwitch.command);
134
- (_d = this.displayService) !== null && _d !== void 0 ? _d : (this.displayService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Display`, 'Display'));
135
- this.displayService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Display`);
136
- this.displayService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Display`);
137
- this.displayService
138
- .getCharacteristic(this.platform.Characteristic.On)
139
- .onGet(this.getDisplayActive.bind(this))
140
- .onSet(this.setDisplayActive.bind(this));
141
- }
142
- else if (this.displayService) {
143
- this.accessory.removeService(this.displayService);
144
- }
145
- // Eco mode switch
146
- this.ecoModeService = this.accessory.getServiceById(this.platform.Service.Switch, 'EcoMode');
147
- if (this.configDev.AC_options.ecoSwitch) {
148
- (_e = this.ecoModeService) !== null && _e !== void 0 ? _e : (this.ecoModeService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Eco`, 'EcoMode'));
149
- this.ecoModeService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Eco`);
150
- this.ecoModeService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Eco`);
151
- this.ecoModeService
152
- .getCharacteristic(this.platform.Characteristic.On)
153
- .onGet(this.getEcoMode.bind(this))
154
- .onSet(this.setEcoMode.bind(this));
155
- }
156
- else if (this.ecoModeService) {
157
- this.accessory.removeService(this.ecoModeService);
158
- }
159
- // Breeze away switch
160
- this.breezeAwayService = this.accessory.getServiceById(this.platform.Service.Switch, 'BreezeAway');
161
- if (this.configDev.AC_options.breezeAwaySwitch) {
162
- (_f = this.breezeAwayService) !== null && _f !== void 0 ? _f : (this.breezeAwayService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Breeze`, 'BreezeAway'));
163
- this.breezeAwayService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Breeze`);
164
- this.breezeAwayService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Breeze`);
165
- this.breezeAwayService
166
- .getCharacteristic(this.platform.Characteristic.On)
167
- .onGet(this.getBreezeAway.bind(this))
168
- .onSet(this.setBreezeAway.bind(this));
169
- }
170
- else if (this.breezeAwayService) {
171
- this.accessory.removeService(this.breezeAwayService);
172
- }
173
- // Dry mode switch
174
- this.dryModeService = this.accessory.getServiceById(this.platform.Service.Switch, 'DryMode');
175
- if (this.configDev.AC_options.dryModeSwitch) {
176
- (_g = this.dryModeService) !== null && _g !== void 0 ? _g : (this.dryModeService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Dry`, 'DryMode'));
177
- this.dryModeService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Dry`);
178
- this.dryModeService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Dry`);
179
- this.dryModeService
180
- .getCharacteristic(this.platform.Characteristic.On)
181
- .onGet(this.getDryMode.bind(this))
182
- .onSet(this.setDryMode.bind(this));
183
- }
184
- else if (this.dryModeService) {
185
- this.accessory.removeService(this.dryModeService);
186
- }
187
- // Aux switch
188
- this.auxService = this.accessory.getServiceById(this.platform.Service.Switch, 'Aux');
189
- if (this.configDev.AC_options.auxHeatingSwitches) {
190
- (_h = this.auxService) !== null && _h !== void 0 ? _h : (this.auxService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Aux`, 'Aux'));
191
- this.auxService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Aux`);
192
- this.auxService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Aux`);
193
- this.auxService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getAux.bind(this)).onSet(this.setAux.bind(this));
194
- }
195
- else if (this.auxService) {
196
- this.accessory.removeService(this.auxService);
197
- }
198
- // Aux+Heat switch
199
- this.auxHeatingService = this.accessory.getServiceById(this.platform.Service.Switch, 'AuxHeating');
200
- if (this.configDev.AC_options.auxHeatingSwitches) {
201
- (_j = this.auxHeatingService) !== null && _j !== void 0 ? _j : (this.auxHeatingService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Aux+Heat`, 'AuxHeating'));
202
- this.auxHeatingService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Aux+Heat`);
203
- this.auxHeatingService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Aux+Heat`);
204
- this.auxHeatingService
205
- .getCharacteristic(this.platform.Characteristic.On)
206
- .onGet(this.getAuxHeating.bind(this))
207
- .onSet(this.setAuxHeating.bind(this));
208
- }
209
- else if (this.auxHeatingService) {
210
- this.accessory.removeService(this.auxHeatingService);
211
- }
212
- const swingProps = this.configDev.AC_options.swing;
213
- this.swingAngleMainControl =
214
- swingProps.mode === platformUtils_1.SwingMode.VERTICAL || (swingProps.mode === platformUtils_1.SwingMode.BOTH && swingProps.angleMainControl === platformUtils_1.SwingAngle.VERTICAL)
215
- ? platformUtils_1.SwingAngle.VERTICAL
216
- : platformUtils_1.SwingAngle.HORIZONTAL;
217
- // Swing angle accessory
218
- this.swingAngleService = this.accessory.getServiceById(this.platform.Service.WindowCovering, 'SwingAngle');
219
- if (swingProps.mode !== platformUtils_1.SwingMode.NONE && swingProps.angleAccessory) {
220
- (_k = this.swingAngleService) !== null && _k !== void 0 ? _k : (this.swingAngleService = this.accessory.addService(this.platform.Service.WindowCovering, `${this.device.name} Swing`, 'SwingAngle'));
221
- this.swingAngleService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Swing`);
222
- this.swingAngleService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Swing`);
223
- this.swingAngleService
224
- .getCharacteristic(this.platform.Characteristic.CurrentPosition)
225
- .onGet(this.getSwingAngleCurrentPosition.bind(this));
226
- this.swingAngleService
227
- .getCharacteristic(this.platform.Characteristic.TargetPosition)
228
- .onGet(this.getSwingAngleTargetPosition.bind(this))
229
- .onSet(this.setSwingAngleTargetPosition.bind(this));
230
- this.swingAngleService
231
- .getCharacteristic(this.platform.Characteristic.PositionState)
232
- .onGet(this.getSwingAnglePositionState.bind(this));
233
- if (swingProps.mode === platformUtils_1.SwingMode.BOTH) {
234
- this.swingAngleService
235
- .getCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle)
236
- .onGet(this.getSwingAngleCurrentHorizontalTiltAngle.bind(this));
237
- this.swingAngleService
238
- .getCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle)
239
- .onGet(this.getSwingAngleTargetHorizontalTiltAngle.bind(this))
240
- .onSet(this.setSwingAngleTargetHorizontalTiltAngle.bind(this));
241
- this.swingAngleService
242
- .getCharacteristic(this.platform.Characteristic.CurrentVerticalTiltAngle)
243
- .onGet(this.getSwingAngleCurrentVerticalTiltAngle.bind(this));
244
- this.swingAngleService
245
- .getCharacteristic(this.platform.Characteristic.TargetVerticalTiltAngle)
246
- .onGet(this.getSwingAngleTargetVerticalTiltAngle.bind(this))
247
- .onSet(this.setSwingAngleTargetVerticalTiltAngle.bind(this));
248
- }
249
- }
250
- // Misc
251
- this.device.attributes.PROMPT_TONE = this.configDev.AC_options.audioFeedback;
252
- this.device.attributes.TEMP_FAHRENHEIT = this.configDev.AC_options.fahrenheit;
253
- }
254
- /*********************************************************************
255
- * Callback function called by MideaDevice whenever there is a change to
256
- * any attribute value.
257
- */
258
- async updateCharacteristics(attributes) {
259
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
260
- for (const [k, v] of Object.entries(attributes)) {
261
- this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
262
- let updateState = false;
263
- switch (k.toLowerCase()) {
264
- case 'power':
265
- updateState = true;
266
- break;
267
- case 'temp_fahrenheit':
268
- this.service.updateCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits, this.getTemperatureDisplayUnits());
269
- break;
270
- case 'screen_display':
271
- case 'screen_display_new':
272
- (_a = this.displayService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.On, this.getDisplayActive());
273
- break;
274
- case 'target_temperature':
275
- // If MODE is 4 then device is heating. Therefore target temperature value must be heating target? Right?
276
- if (this.device.attributes.MODE === 4) {
277
- this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.getTargetTemperature());
278
- }
279
- else {
280
- this.service.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.getTargetTemperature());
281
- }
282
- updateState = true;
283
- break;
284
- case 'indoor_temperature':
285
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.getCurrentTemperature());
286
- break;
287
- case 'outdoor_temperature':
288
- (_b = this.outDoorTemperatureService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.getOutdoorTemperature());
289
- break;
290
- case 'fan_speed':
291
- updateState = true;
292
- break;
293
- case 'fan_auto':
294
- (_c = this.fanService) === null || _c === void 0 ? void 0 : _c.updateCharacteristic(this.platform.Characteristic.TargetFanState, this.getFanState());
295
- break;
296
- case 'swing_vertical':
297
- case 'swing_horizontal':
298
- this.service.updateCharacteristic(this.platform.Characteristic.SwingMode, this.getSwingMode());
299
- break;
300
- case 'mode':
301
- updateState = true;
302
- break;
303
- case 'eco_mode':
304
- (_d = this.ecoModeService) === null || _d === void 0 ? void 0 : _d.updateCharacteristic(this.platform.Characteristic.On, this.getEcoMode());
305
- break;
306
- case 'indirect_wind':
307
- (_e = this.breezeAwayService) === null || _e === void 0 ? void 0 : _e.updateCharacteristic(this.platform.Characteristic.On, this.getBreezeAway());
308
- break;
309
- case 'aux_heating':
310
- (_f = this.auxHeatingService) === null || _f === void 0 ? void 0 : _f.updateCharacteristic(this.platform.Characteristic.On, this.getAuxHeating());
311
- break;
312
- case 'smart_eye':
313
- (_g = this.auxService) === null || _g === void 0 ? void 0 : _g.updateCharacteristic(this.platform.Characteristic.On, this.getAux());
314
- break;
315
- case 'wind_swing_lr_angle':
316
- case 'wind_swing_ud_angle':
317
- (_h = this.swingAngleService) === null || _h === void 0 ? void 0 : _h.updateCharacteristic(this.platform.Characteristic.CurrentPosition, this.getSwingAngleCurrentPosition());
318
- (_j = this.swingAngleService) === null || _j === void 0 ? void 0 : _j.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.getSwingAngleTargetPosition());
319
- if (this.configDev.AC_options.swing.mode === platformUtils_1.SwingMode.BOTH) {
320
- (_k = this.swingAngleService) === null || _k === void 0 ? void 0 : _k.updateCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle, this.getSwingAngleCurrentHorizontalTiltAngle());
321
- (_l = this.swingAngleService) === null || _l === void 0 ? void 0 : _l.updateCharacteristic(this.platform.Characteristic.CurrentVerticalTiltAngle, this.getSwingAngleCurrentVerticalTiltAngle());
322
- (_m = this.swingAngleService) === null || _m === void 0 ? void 0 : _m.updateCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle, this.getSwingAngleTargetHorizontalTiltAngle());
323
- (_o = this.swingAngleService) === null || _o === void 0 ? void 0 : _o.updateCharacteristic(this.platform.Characteristic.TargetVerticalTiltAngle, this.getSwingAngleTargetVerticalTiltAngle());
324
- }
325
- break;
326
- default:
327
- this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
328
- }
329
- if (updateState) {
330
- this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
331
- this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.getTargetHeaterCoolerState());
332
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.getCurrentHeaterCoolerState());
333
- this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.getRotationSpeed());
334
- (_p = this.fanOnlyService) === null || _p === void 0 ? void 0 : _p.updateCharacteristic(this.platform.Characteristic.On, this.getFanOnlyMode());
335
- (_q = this.fanService) === null || _q === void 0 ? void 0 : _q.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
336
- (_r = this.fanService) === null || _r === void 0 ? void 0 : _r.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.getRotationSpeed());
337
- (_s = this.dryModeService) === null || _s === void 0 ? void 0 : _s.updateCharacteristic(this.platform.Characteristic.On, this.getDryMode());
338
- (_t = this.displayService) === null || _t === void 0 ? void 0 : _t.updateCharacteristic(this.platform.Characteristic.On, this.getDisplayActive());
339
- (_u = this.ecoModeService) === null || _u === void 0 ? void 0 : _u.updateCharacteristic(this.platform.Characteristic.On, this.getEcoMode());
340
- (_v = this.breezeAwayService) === null || _v === void 0 ? void 0 : _v.updateCharacteristic(this.platform.Characteristic.On, this.getBreezeAway());
341
- (_w = this.auxService) === null || _w === void 0 ? void 0 : _w.updateCharacteristic(this.platform.Characteristic.On, this.getAux());
342
- (_x = this.auxHeatingService) === null || _x === void 0 ? void 0 : _x.updateCharacteristic(this.platform.Characteristic.On, this.getAuxHeating());
343
- }
344
- }
345
- }
346
- /*********************************************************************
347
- * Callback functions for each Homebridge/HomeKit service
348
- *
349
- */
350
- getActive() {
351
- // Show as inactive if device is off or in fan-only mode
352
- return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
353
- }
354
- async setActive(value) {
355
- var _a;
356
- await this.device.set_attribute({ POWER: !!value });
357
- this.device.attributes.SCREEN_DISPLAY = !!value;
358
- (_a = this.displayService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.On, !!value);
359
- }
360
- getTemperatureDisplayUnits() {
361
- return this.device.attributes.TEMP_FAHRENHEIT
362
- ? this.platform.Characteristic.TemperatureDisplayUnits.FAHRENHEIT
363
- : this.platform.Characteristic.TemperatureDisplayUnits.CELSIUS;
364
- }
365
- async setTemperatureDisplayUnits(value) {
366
- await this.device.set_attribute({ TEMP_FAHRENHEIT: value === this.platform.Characteristic.TemperatureDisplayUnits.FAHRENHEIT });
367
- }
368
- getCurrentHeaterCoolerState() {
369
- var _a;
370
- if (this.device.attributes.POWER && this.device.attributes.MODE > 0 && this.device.attributes.MODE < 5) {
371
- if (this.device.attributes.TARGET_TEMPERATURE < ((_a = this.device.attributes.INDOOR_TEMPERATURE) !== null && _a !== void 0 ? _a : 0)) {
372
- if ([1, 2].includes(this.device.attributes.MODE)) {
373
- return this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
374
- }
375
- else {
376
- return this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
377
- }
378
- }
379
- else if (this.device.attributes.TARGET_TEMPERATURE === this.device.attributes.INDOOR_TEMPERATURE) {
380
- return this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
381
- }
382
- else {
383
- if (this.device.attributes.MODE === 4) {
384
- return this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
385
- }
386
- else {
387
- return this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
388
- }
389
- }
390
- }
391
- else {
392
- return this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
393
- }
394
- }
395
- getTargetHeaterCoolerState() {
396
- if (this.device.attributes.MODE === 2) {
397
- return this.platform.Characteristic.TargetHeaterCoolerState.COOL;
398
- }
399
- else if (this.device.attributes.MODE === 4) {
400
- return this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
401
- }
402
- else {
403
- return this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
404
- }
405
- }
406
- async setTargetHeaterCoolerState(value) {
407
- switch (value) {
408
- case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
409
- await this.device.set_attribute({ MODE: 1 });
410
- break;
411
- case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
412
- await this.device.set_attribute({ MODE: 2 });
413
- break;
414
- case this.platform.Characteristic.TargetHeaterCoolerState.HEAT:
415
- await this.device.set_attribute({ MODE: 4 });
416
- break;
417
- }
418
- }
419
- getCurrentTemperature() {
420
- var _a;
421
- return (_a = this.device.attributes.INDOOR_TEMPERATURE) !== null && _a !== void 0 ? _a : this.configDev.AC_options.minTemp;
422
- }
423
- getTargetTemperature() {
424
- return Math.max(this.configDev.AC_options.minTemp, Math.min(this.configDev.AC_options.maxTemp, this.device.attributes.TARGET_TEMPERATURE));
425
- }
426
- getFanOnlyMode() {
427
- return this.device.attributes.POWER === true && this.device.attributes.MODE === 5;
428
- }
429
- async setFanOnlyMode(value) {
430
- if (value) {
431
- await this.device.set_attribute({ POWER: true, MODE: 5 });
432
- }
433
- else {
434
- await this.device.set_attribute({ POWER: false, MODE: 0 });
435
- }
436
- }
437
- getFanState() {
438
- return this.device.attributes.FAN_AUTO;
439
- }
440
- async setFanState(value) {
441
- await this.device.set_fan_auto(value === this.platform.Characteristic.TargetFanState.AUTO);
442
- }
443
- async setTargetTemperature(value) {
444
- value = Math.max(this.configDev.AC_options.minTemp, Math.min(this.configDev.AC_options.maxTemp, value));
445
- await this.device.set_target_temperature(value);
446
- }
447
- getSwingMode() {
448
- return this.device.attributes.SWING_HORIZONTAL || this.device.attributes.SWING_VERTICAL
449
- ? this.platform.Characteristic.SwingMode.SWING_ENABLED
450
- : this.platform.Characteristic.SwingMode.SWING_DISABLED;
451
- }
452
- async setSwingMode(value) {
453
- switch (value) {
454
- case this.platform.Characteristic.SwingMode.SWING_ENABLED:
455
- await this.device.set_swing([platformUtils_1.SwingMode.HORIZONTAL, platformUtils_1.SwingMode.BOTH].includes(this.configDev.AC_options.swing.mode), [platformUtils_1.SwingMode.VERTICAL, platformUtils_1.SwingMode.BOTH].includes(this.configDev.AC_options.swing.mode));
456
- break;
457
- case this.platform.Characteristic.SwingMode.SWING_DISABLED:
458
- await this.device.set_swing(false, false);
459
- break;
460
- }
461
- }
462
- getRotationSpeed() {
463
- var _a;
464
- return Math.min(100, (_a = this.device.attributes.FAN_SPEED) !== null && _a !== void 0 ? _a : 0);
465
- }
466
- async setRotationSpeed(value) {
467
- await this.device.set_attribute({ FAN_SPEED: value });
468
- }
469
- getOutdoorTemperature() {
470
- var _a;
471
- return (_a = this.device.attributes.OUTDOOR_TEMPERATURE) !== null && _a !== void 0 ? _a : -270;
472
- }
473
- getDisplayActive() {
474
- return this.device.attributes.SCREEN_DISPLAY === true;
475
- }
476
- async setDisplayActive(value) {
477
- if (this.device.attributes.POWER) {
478
- await this.device.set_attribute({ SCREEN_DISPLAY: !!value });
479
- }
480
- }
481
- getEcoMode() {
482
- return this.device.attributes.POWER === true && this.device.attributes.ECO_MODE;
483
- }
484
- async setEcoMode(value) {
485
- await this.device.set_attribute({ ECO_MODE: !!value });
486
- }
487
- getBreezeAway() {
488
- return this.device.attributes.POWER === true && this.device.attributes.INDIRECT_WIND;
489
- }
490
- async setBreezeAway(value) {
491
- await this.device.set_attribute({ INDIRECT_WIND: !!value });
492
- }
493
- getDryMode() {
494
- return this.device.attributes.POWER === true && this.device.attributes.MODE === 3;
495
- }
496
- async setDryMode(value) {
497
- if (value) {
498
- await this.device.set_attribute({ POWER: true, MODE: 3 });
499
- }
500
- else {
501
- await this.device.set_attribute({ POWER: false, MODE: 0 });
502
- }
503
- }
504
- getAux() {
505
- return this.device.attributes.POWER === true && this.device.attributes.SMART_EYE === true;
506
- }
507
- async setAux(value) {
508
- if (value) {
509
- await this.device.set_attribute({ SMART_EYE: true });
510
- }
511
- else {
512
- await this.device.set_attribute({ SMART_EYE: false });
513
- }
514
- }
515
- getAuxHeating() {
516
- return this.device.attributes.POWER === true && this.device.attributes.AUX_HEATING === true;
517
- }
518
- async setAuxHeating(value) {
519
- if (value) {
520
- await this.device.set_attribute({ AUX_HEATING: true });
521
- }
522
- else {
523
- await this.device.set_attribute({ AUX_HEATING: false });
524
- }
525
- }
526
- getSwingAngleCurrentPosition() {
527
- const value = this.swingAngleMainControl === platformUtils_1.SwingAngle.VERTICAL
528
- ? this.device.attributes.WIND_SWING_UD_ANGLE
529
- : this.device.attributes.WIND_SWING_LR_ANGLE;
530
- return value === 1 ? 0 : value;
531
- }
532
- getSwingAngleTargetPosition() {
533
- return this.getSwingAngleCurrentPosition();
534
- }
535
- async setSwingAngleTargetPosition(value) {
536
- await this.device.set_swing_angle(this.swingAngleMainControl, Math.max(1, value));
537
- }
538
- getSwingAnglePositionState() {
539
- return this.platform.Characteristic.PositionState.STOPPED;
540
- }
541
- getSwingAngleCurrentHorizontalTiltAngle() {
542
- return this.device.attributes.WIND_SWING_LR_ANGLE === 1 ? 0 : this.device.attributes.WIND_SWING_LR_ANGLE;
543
- }
544
- getSwingAngleTargetHorizontalTiltAngle() {
545
- return this.getSwingAngleCurrentHorizontalTiltAngle();
546
- }
547
- async setSwingAngleTargetHorizontalTiltAngle(value) {
548
- await this.device.set_swing_angle(platformUtils_1.SwingAngle.HORIZONTAL, Math.max(1, value));
549
- }
550
- getSwingAngleCurrentVerticalTiltAngle() {
551
- return this.device.attributes.WIND_SWING_UD_ANGLE === 1 ? 0 : this.device.attributes.WIND_SWING_UD_ANGLE;
552
- }
553
- getSwingAngleTargetVerticalTiltAngle() {
554
- return this.getSwingAngleCurrentVerticalTiltAngle();
555
- }
556
- async setSwingAngleTargetVerticalTiltAngle(value) {
557
- await this.device.set_swing_angle(platformUtils_1.SwingAngle.VERTICAL, Math.max(1, value));
558
- }
559
- }
560
- exports.default = AirConditionerAccessory;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
7
+ const platformUtils_1 = require("../platformUtils");
8
+ class AirConditionerAccessory extends BaseAccessory_1.default {
9
+ /*********************************************************************
10
+ * Constructor registers all the service types with Homebridge, registers
11
+ * a callback function with the MideaDevice class, and requests device status.
12
+ */
13
+ constructor(platform, accessory, device, configDev) {
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
15
+ super(platform, accessory, device, configDev);
16
+ this.device = device;
17
+ this.configDev = configDev;
18
+ this.service =
19
+ this.accessory.getService(this.platform.Service.HeaterCooler) || this.accessory.addService(this.platform.Service.HeaterCooler);
20
+ this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
21
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
22
+ this.service
23
+ .getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits)
24
+ .onGet(this.getTemperatureDisplayUnits.bind(this))
25
+ .onSet(this.setTemperatureDisplayUnits.bind(this));
26
+ this.service
27
+ .getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
28
+ .onGet(this.getCurrentHeaterCoolerState.bind(this));
29
+ this.service
30
+ .getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
31
+ .onGet(this.getTargetHeaterCoolerState.bind(this))
32
+ .onSet(this.setTargetHeaterCoolerState.bind(this))
33
+ .setProps({
34
+ validValues: this.configDev.AC_options.heatingCapable
35
+ ? [
36
+ this.platform.Characteristic.TargetHeaterCoolerState.AUTO,
37
+ this.platform.Characteristic.TargetHeaterCoolerState.HEAT,
38
+ this.platform.Characteristic.TargetHeaterCoolerState.COOL,
39
+ ]
40
+ : [this.platform.Characteristic.TargetHeaterCoolerState.AUTO, this.platform.Characteristic.TargetHeaterCoolerState.COOL],
41
+ });
42
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getCurrentTemperature.bind(this));
43
+ this.service
44
+ .getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
45
+ .onGet(this.getTargetTemperature.bind(this))
46
+ .onSet(this.setTargetTemperature.bind(this))
47
+ .setProps({
48
+ minValue: this.configDev.AC_options.minTemp,
49
+ maxValue: this.configDev.AC_options.maxTemp,
50
+ minStep: this.configDev.AC_options.tempStep,
51
+ });
52
+ this.service
53
+ .getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
54
+ .onGet(this.getTargetTemperature.bind(this))
55
+ .onSet(this.setTargetTemperature.bind(this))
56
+ .setProps({
57
+ minValue: this.configDev.AC_options.minTemp,
58
+ maxValue: this.configDev.AC_options.maxTemp,
59
+ minStep: this.configDev.AC_options.tempStep,
60
+ });
61
+ this.service
62
+ .getCharacteristic(this.platform.Characteristic.RotationSpeed)
63
+ .onGet(this.getRotationSpeed.bind(this))
64
+ .onSet(this.setRotationSpeed.bind(this));
65
+ // Swing modes
66
+ if (this.configDev.AC_options.swing.mode !== platformUtils_1.SwingMode.NONE) {
67
+ this.service
68
+ .getCharacteristic(this.platform.Characteristic.SwingMode)
69
+ .onGet(this.getSwingMode.bind(this))
70
+ .onSet(this.setSwingMode.bind(this));
71
+ }
72
+ // Outdoor temperature sensor
73
+ this.outDoorTemperatureService = this.accessory.getServiceById(this.platform.Service.TemperatureSensor, 'Outdoor');
74
+ if (this.configDev.AC_options.outDoorTemp) {
75
+ (_a = this.outDoorTemperatureService) !== null && _a !== void 0 ? _a : (this.outDoorTemperatureService = this.accessory.addService(this.platform.Service.TemperatureSensor, `${this.device.name} Outdoor`, 'Outdoor'));
76
+ this.outDoorTemperatureService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Outdoor`);
77
+ this.outDoorTemperatureService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Outdoor`);
78
+ this.outDoorTemperatureService
79
+ .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
80
+ .onGet(this.getOutdoorTemperature.bind(this));
81
+ this.outDoorTemperatureService
82
+ .getCharacteristic(this.platform.Characteristic.StatusFault)
83
+ .onGet(() => this.device.attributes.OUTDOOR_TEMPERATURE === undefined
84
+ ? this.platform.Characteristic.StatusFault.GENERAL_FAULT
85
+ : this.platform.Characteristic.StatusFault.NO_FAULT);
86
+ }
87
+ else if (this.outDoorTemperatureService) {
88
+ this.accessory.removeService(this.outDoorTemperatureService);
89
+ }
90
+ // Fan-only mode switch
91
+ this.fanOnlyService = this.accessory.getServiceById(this.platform.Service.Switch, 'FanOnly');
92
+ if (this.configDev.AC_options.fanOnlyModeSwitch) {
93
+ (_b = this.fanOnlyService) !== null && _b !== void 0 ? _b : (this.fanOnlyService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} FanOnly`, 'FanOnly'));
94
+ this.fanOnlyService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Fan-only Mode`);
95
+ this.fanOnlyService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Fan-only Mode`);
96
+ this.fanOnlyService
97
+ .getCharacteristic(this.platform.Characteristic.On)
98
+ .onGet(this.getFanOnlyMode.bind(this))
99
+ .onSet(this.setFanOnlyMode.bind(this));
100
+ }
101
+ else if (this.fanOnlyService) {
102
+ this.accessory.removeService(this.fanOnlyService);
103
+ }
104
+ // Fan accessory
105
+ this.fanService = this.accessory.getServiceById(this.platform.Service.Fanv2, 'Fan');
106
+ if (this.configDev.AC_options.fanAccessory) {
107
+ (_c = this.fanService) !== null && _c !== void 0 ? _c : (this.fanService = this.accessory.addService(this.platform.Service.Fanv2, `${this.device.name} Fan`, 'Fan'));
108
+ this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Fan`);
109
+ this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Fan`);
110
+ this.fanService
111
+ .getCharacteristic(this.platform.Characteristic.Active)
112
+ .onGet(this.getActive.bind(this))
113
+ .onSet(this.setActive.bind(this));
114
+ this.fanService
115
+ .getCharacteristic(this.platform.Characteristic.RotationSpeed)
116
+ .onGet(this.getRotationSpeed.bind(this))
117
+ .onSet(this.setRotationSpeed.bind(this));
118
+ this.fanService
119
+ .getCharacteristic(this.platform.Characteristic.TargetFanState)
120
+ .onGet(this.getFanState.bind(this))
121
+ .onSet(this.setFanState.bind(this));
122
+ this.fanService
123
+ .getCharacteristic(this.platform.Characteristic.SwingMode)
124
+ .onGet(this.getSwingMode.bind(this))
125
+ .onSet(this.setSwingMode.bind(this));
126
+ }
127
+ else if (this.fanService) {
128
+ this.accessory.removeService(this.fanService);
129
+ }
130
+ // Display switch
131
+ this.displayService = this.accessory.getServiceById(this.platform.Service.Switch, 'Display');
132
+ if (this.configDev.AC_options.displaySwitch.flag) {
133
+ this.device.set_alternate_switch_display(this.configDev.AC_options.displaySwitch.command);
134
+ (_d = this.displayService) !== null && _d !== void 0 ? _d : (this.displayService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Display`, 'Display'));
135
+ this.displayService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Display`);
136
+ this.displayService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Display`);
137
+ this.displayService
138
+ .getCharacteristic(this.platform.Characteristic.On)
139
+ .onGet(this.getDisplayActive.bind(this))
140
+ .onSet(this.setDisplayActive.bind(this));
141
+ }
142
+ else if (this.displayService) {
143
+ this.accessory.removeService(this.displayService);
144
+ }
145
+ // Eco mode switch
146
+ this.ecoModeService = this.accessory.getServiceById(this.platform.Service.Switch, 'EcoMode');
147
+ if (this.configDev.AC_options.ecoSwitch) {
148
+ (_e = this.ecoModeService) !== null && _e !== void 0 ? _e : (this.ecoModeService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Eco`, 'EcoMode'));
149
+ this.ecoModeService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Eco`);
150
+ this.ecoModeService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Eco`);
151
+ this.ecoModeService
152
+ .getCharacteristic(this.platform.Characteristic.On)
153
+ .onGet(this.getEcoMode.bind(this))
154
+ .onSet(this.setEcoMode.bind(this));
155
+ }
156
+ else if (this.ecoModeService) {
157
+ this.accessory.removeService(this.ecoModeService);
158
+ }
159
+ // Breeze away switch
160
+ this.breezeAwayService = this.accessory.getServiceById(this.platform.Service.Switch, 'BreezeAway');
161
+ if (this.configDev.AC_options.breezeAwaySwitch) {
162
+ (_f = this.breezeAwayService) !== null && _f !== void 0 ? _f : (this.breezeAwayService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Breeze`, 'BreezeAway'));
163
+ this.breezeAwayService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Breeze`);
164
+ this.breezeAwayService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Breeze`);
165
+ this.breezeAwayService
166
+ .getCharacteristic(this.platform.Characteristic.On)
167
+ .onGet(this.getBreezeAway.bind(this))
168
+ .onSet(this.setBreezeAway.bind(this));
169
+ }
170
+ else if (this.breezeAwayService) {
171
+ this.accessory.removeService(this.breezeAwayService);
172
+ }
173
+ // Dry mode switch
174
+ this.dryModeService = this.accessory.getServiceById(this.platform.Service.Switch, 'DryMode');
175
+ if (this.configDev.AC_options.dryModeSwitch) {
176
+ (_g = this.dryModeService) !== null && _g !== void 0 ? _g : (this.dryModeService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Dry`, 'DryMode'));
177
+ this.dryModeService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Dry`);
178
+ this.dryModeService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Dry`);
179
+ this.dryModeService
180
+ .getCharacteristic(this.platform.Characteristic.On)
181
+ .onGet(this.getDryMode.bind(this))
182
+ .onSet(this.setDryMode.bind(this));
183
+ }
184
+ else if (this.dryModeService) {
185
+ this.accessory.removeService(this.dryModeService);
186
+ }
187
+ this.boostModeService = this.accessory.getServiceById(this.platform.Service.Switch, 'BoostMode');
188
+ if (this.configDev.AC_options.boostModeSwitch) {
189
+ (_h = this.boostModeService) !== null && _h !== void 0 ? _h : (this.boostModeService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Boost`, 'BoostMode'));
190
+ this.boostModeService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Boost`);
191
+ this.boostModeService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Boost`);
192
+ this.boostModeService
193
+ .getCharacteristic(this.platform.Characteristic.On)
194
+ .onGet(this.getBoostMode.bind(this))
195
+ .onSet(this.setBoostMode.bind(this));
196
+ }
197
+ else if (this.boostModeService) {
198
+ this.accessory.removeService(this.boostModeService);
199
+ }
200
+ // Aux switch
201
+ this.auxService = this.accessory.getServiceById(this.platform.Service.Switch, 'Aux');
202
+ if (this.configDev.AC_options.auxHeatingSwitches) {
203
+ (_j = this.auxService) !== null && _j !== void 0 ? _j : (this.auxService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Aux`, 'Aux'));
204
+ this.auxService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Aux`);
205
+ this.auxService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Aux`);
206
+ this.auxService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getAux.bind(this)).onSet(this.setAux.bind(this));
207
+ }
208
+ else if (this.auxService) {
209
+ this.accessory.removeService(this.auxService);
210
+ }
211
+ // Aux+Heat switch
212
+ this.auxHeatingService = this.accessory.getServiceById(this.platform.Service.Switch, 'AuxHeating');
213
+ if (this.configDev.AC_options.auxHeatingSwitches) {
214
+ (_k = this.auxHeatingService) !== null && _k !== void 0 ? _k : (this.auxHeatingService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Aux+Heat`, 'AuxHeating'));
215
+ this.auxHeatingService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Aux+Heat`);
216
+ this.auxHeatingService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Aux+Heat`);
217
+ this.auxHeatingService
218
+ .getCharacteristic(this.platform.Characteristic.On)
219
+ .onGet(this.getAuxHeating.bind(this))
220
+ .onSet(this.setAuxHeating.bind(this));
221
+ }
222
+ else if (this.auxHeatingService) {
223
+ this.accessory.removeService(this.auxHeatingService);
224
+ }
225
+ const swingProps = this.configDev.AC_options.swing;
226
+ this.swingAngleMainControl =
227
+ swingProps.mode === platformUtils_1.SwingMode.VERTICAL || (swingProps.mode === platformUtils_1.SwingMode.BOTH && swingProps.angleMainControl === platformUtils_1.SwingAngle.VERTICAL)
228
+ ? platformUtils_1.SwingAngle.VERTICAL
229
+ : platformUtils_1.SwingAngle.HORIZONTAL;
230
+ // Swing angle accessory
231
+ this.swingAngleService = this.accessory.getServiceById(this.platform.Service.WindowCovering, 'SwingAngle');
232
+ if (swingProps.mode !== platformUtils_1.SwingMode.NONE && swingProps.angleAccessory) {
233
+ (_l = this.swingAngleService) !== null && _l !== void 0 ? _l : (this.swingAngleService = this.accessory.addService(this.platform.Service.WindowCovering, `${this.device.name} Swing`, 'SwingAngle'));
234
+ this.swingAngleService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Swing`);
235
+ this.swingAngleService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Swing`);
236
+ this.swingAngleService
237
+ .getCharacteristic(this.platform.Characteristic.CurrentPosition)
238
+ .onGet(this.getSwingAngleCurrentPosition.bind(this));
239
+ this.swingAngleService
240
+ .getCharacteristic(this.platform.Characteristic.TargetPosition)
241
+ .onGet(this.getSwingAngleTargetPosition.bind(this))
242
+ .onSet(this.setSwingAngleTargetPosition.bind(this));
243
+ this.swingAngleService
244
+ .getCharacteristic(this.platform.Characteristic.PositionState)
245
+ .onGet(this.getSwingAnglePositionState.bind(this));
246
+ if (swingProps.mode === platformUtils_1.SwingMode.BOTH) {
247
+ this.swingAngleService
248
+ .getCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle)
249
+ .onGet(this.getSwingAngleCurrentHorizontalTiltAngle.bind(this));
250
+ this.swingAngleService
251
+ .getCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle)
252
+ .onGet(this.getSwingAngleTargetHorizontalTiltAngle.bind(this))
253
+ .onSet(this.setSwingAngleTargetHorizontalTiltAngle.bind(this));
254
+ this.swingAngleService
255
+ .getCharacteristic(this.platform.Characteristic.CurrentVerticalTiltAngle)
256
+ .onGet(this.getSwingAngleCurrentVerticalTiltAngle.bind(this));
257
+ this.swingAngleService
258
+ .getCharacteristic(this.platform.Characteristic.TargetVerticalTiltAngle)
259
+ .onGet(this.getSwingAngleTargetVerticalTiltAngle.bind(this))
260
+ .onSet(this.setSwingAngleTargetVerticalTiltAngle.bind(this));
261
+ }
262
+ }
263
+ // Misc
264
+ this.device.attributes.PROMPT_TONE = this.configDev.AC_options.audioFeedback;
265
+ this.device.attributes.TEMP_FAHRENHEIT = this.configDev.AC_options.fahrenheit;
266
+ }
267
+ /*********************************************************************
268
+ * Callback function called by MideaDevice whenever there is a change to
269
+ * any attribute value.
270
+ */
271
+ async updateCharacteristics(attributes) {
272
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
273
+ for (const [k, v] of Object.entries(attributes)) {
274
+ this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
275
+ let updateState = false;
276
+ switch (k.toLowerCase()) {
277
+ case 'power':
278
+ updateState = true;
279
+ break;
280
+ case 'temp_fahrenheit':
281
+ this.service.updateCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits, this.getTemperatureDisplayUnits());
282
+ break;
283
+ case 'screen_display':
284
+ case 'screen_display_new':
285
+ (_a = this.displayService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.On, this.getDisplayActive());
286
+ break;
287
+ case 'target_temperature':
288
+ // If MODE is 4 then device is heating. Therefore target temperature value must be heating target? Right?
289
+ if (this.device.attributes.MODE === 4) {
290
+ this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.getTargetTemperature());
291
+ }
292
+ else {
293
+ this.service.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.getTargetTemperature());
294
+ }
295
+ updateState = true;
296
+ break;
297
+ case 'indoor_temperature':
298
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.getCurrentTemperature());
299
+ break;
300
+ case 'outdoor_temperature':
301
+ (_b = this.outDoorTemperatureService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.getOutdoorTemperature());
302
+ break;
303
+ case 'fan_speed':
304
+ updateState = true;
305
+ break;
306
+ case 'fan_auto':
307
+ (_c = this.fanService) === null || _c === void 0 ? void 0 : _c.updateCharacteristic(this.platform.Characteristic.TargetFanState, this.getFanState());
308
+ break;
309
+ case 'swing_vertical':
310
+ case 'swing_horizontal':
311
+ this.service.updateCharacteristic(this.platform.Characteristic.SwingMode, this.getSwingMode());
312
+ break;
313
+ case 'mode':
314
+ updateState = true;
315
+ break;
316
+ case 'eco_mode':
317
+ (_d = this.ecoModeService) === null || _d === void 0 ? void 0 : _d.updateCharacteristic(this.platform.Characteristic.On, this.getEcoMode());
318
+ break;
319
+ case 'indirect_wind':
320
+ (_e = this.breezeAwayService) === null || _e === void 0 ? void 0 : _e.updateCharacteristic(this.platform.Characteristic.On, this.getBreezeAway());
321
+ break;
322
+ case 'aux_heating':
323
+ (_f = this.auxHeatingService) === null || _f === void 0 ? void 0 : _f.updateCharacteristic(this.platform.Characteristic.On, this.getAuxHeating());
324
+ break;
325
+ case 'smart_eye':
326
+ (_g = this.auxService) === null || _g === void 0 ? void 0 : _g.updateCharacteristic(this.platform.Characteristic.On, this.getAux());
327
+ break;
328
+ case 'wind_swing_lr_angle':
329
+ case 'wind_swing_ud_angle':
330
+ (_h = this.swingAngleService) === null || _h === void 0 ? void 0 : _h.updateCharacteristic(this.platform.Characteristic.CurrentPosition, this.getSwingAngleCurrentPosition());
331
+ (_j = this.swingAngleService) === null || _j === void 0 ? void 0 : _j.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.getSwingAngleTargetPosition());
332
+ if (this.configDev.AC_options.swing.mode === platformUtils_1.SwingMode.BOTH) {
333
+ (_k = this.swingAngleService) === null || _k === void 0 ? void 0 : _k.updateCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle, this.getSwingAngleCurrentHorizontalTiltAngle());
334
+ (_l = this.swingAngleService) === null || _l === void 0 ? void 0 : _l.updateCharacteristic(this.platform.Characteristic.CurrentVerticalTiltAngle, this.getSwingAngleCurrentVerticalTiltAngle());
335
+ (_m = this.swingAngleService) === null || _m === void 0 ? void 0 : _m.updateCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle, this.getSwingAngleTargetHorizontalTiltAngle());
336
+ (_o = this.swingAngleService) === null || _o === void 0 ? void 0 : _o.updateCharacteristic(this.platform.Characteristic.TargetVerticalTiltAngle, this.getSwingAngleTargetVerticalTiltAngle());
337
+ }
338
+ break;
339
+ default:
340
+ this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
341
+ }
342
+ if (updateState) {
343
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
344
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.getTargetHeaterCoolerState());
345
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.getCurrentHeaterCoolerState());
346
+ this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.getRotationSpeed());
347
+ (_p = this.fanOnlyService) === null || _p === void 0 ? void 0 : _p.updateCharacteristic(this.platform.Characteristic.On, this.getFanOnlyMode());
348
+ (_q = this.fanService) === null || _q === void 0 ? void 0 : _q.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
349
+ (_r = this.fanService) === null || _r === void 0 ? void 0 : _r.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.getRotationSpeed());
350
+ (_s = this.dryModeService) === null || _s === void 0 ? void 0 : _s.updateCharacteristic(this.platform.Characteristic.On, this.getDryMode());
351
+ (_t = this.displayService) === null || _t === void 0 ? void 0 : _t.updateCharacteristic(this.platform.Characteristic.On, this.getDisplayActive());
352
+ (_u = this.ecoModeService) === null || _u === void 0 ? void 0 : _u.updateCharacteristic(this.platform.Characteristic.On, this.getEcoMode());
353
+ (_v = this.breezeAwayService) === null || _v === void 0 ? void 0 : _v.updateCharacteristic(this.platform.Characteristic.On, this.getBreezeAway());
354
+ (_w = this.auxService) === null || _w === void 0 ? void 0 : _w.updateCharacteristic(this.platform.Characteristic.On, this.getAux());
355
+ (_x = this.auxHeatingService) === null || _x === void 0 ? void 0 : _x.updateCharacteristic(this.platform.Characteristic.On, this.getAuxHeating());
356
+ }
357
+ }
358
+ }
359
+ /*********************************************************************
360
+ * Callback functions for each Homebridge/HomeKit service
361
+ *
362
+ */
363
+ getActive() {
364
+ // Show as inactive if device is off
365
+ return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
366
+ }
367
+ async setActive(value) {
368
+ var _a;
369
+ await this.device.set_attribute({ POWER: !!value });
370
+ this.device.attributes.SCREEN_DISPLAY = !!value;
371
+ (_a = this.displayService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.On, !!value);
372
+ }
373
+ getTemperatureDisplayUnits() {
374
+ return this.device.attributes.TEMP_FAHRENHEIT
375
+ ? this.platform.Characteristic.TemperatureDisplayUnits.FAHRENHEIT
376
+ : this.platform.Characteristic.TemperatureDisplayUnits.CELSIUS;
377
+ }
378
+ async setTemperatureDisplayUnits(value) {
379
+ await this.device.set_attribute({ TEMP_FAHRENHEIT: value === this.platform.Characteristic.TemperatureDisplayUnits.FAHRENHEIT });
380
+ }
381
+ getCurrentHeaterCoolerState() {
382
+ var _a;
383
+ if (this.device.attributes.POWER && this.device.attributes.MODE > 0 && this.device.attributes.MODE < 5) {
384
+ if (this.device.attributes.TARGET_TEMPERATURE < ((_a = this.device.attributes.INDOOR_TEMPERATURE) !== null && _a !== void 0 ? _a : 0)) {
385
+ if ([1, 2].includes(this.device.attributes.MODE)) {
386
+ return this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
387
+ }
388
+ else {
389
+ return this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
390
+ }
391
+ }
392
+ else if (this.device.attributes.TARGET_TEMPERATURE === this.device.attributes.INDOOR_TEMPERATURE) {
393
+ return this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
394
+ }
395
+ else {
396
+ if (this.device.attributes.MODE === 4) {
397
+ return this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
398
+ }
399
+ else {
400
+ return this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
401
+ }
402
+ }
403
+ }
404
+ else {
405
+ return this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
406
+ }
407
+ }
408
+ getTargetHeaterCoolerState() {
409
+ if (this.device.attributes.MODE === 2) {
410
+ return this.platform.Characteristic.TargetHeaterCoolerState.COOL;
411
+ }
412
+ else if (this.device.attributes.MODE === 4) {
413
+ return this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
414
+ }
415
+ else {
416
+ return this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
417
+ }
418
+ }
419
+ async setTargetHeaterCoolerState(value) {
420
+ switch (value) {
421
+ case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
422
+ await this.device.set_attribute({ POWER: true, MODE: 1 });
423
+ break;
424
+ case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
425
+ await this.device.set_attribute({ POWER: true, MODE: 2 });
426
+ break;
427
+ case this.platform.Characteristic.TargetHeaterCoolerState.HEAT:
428
+ await this.device.set_attribute({ POWER: true, MODE: 4 });
429
+ break;
430
+ }
431
+ }
432
+ getCurrentTemperature() {
433
+ var _a;
434
+ return (_a = this.device.attributes.INDOOR_TEMPERATURE) !== null && _a !== void 0 ? _a : this.configDev.AC_options.minTemp;
435
+ }
436
+ getTargetTemperature() {
437
+ return Math.max(this.configDev.AC_options.minTemp, Math.min(this.configDev.AC_options.maxTemp, this.device.attributes.TARGET_TEMPERATURE));
438
+ }
439
+ getFanOnlyMode() {
440
+ return this.device.attributes.POWER === true && this.device.attributes.MODE === 5;
441
+ }
442
+ async setFanOnlyMode(value) {
443
+ if (value) {
444
+ await this.device.set_attribute({ POWER: true, MODE: 5 });
445
+ }
446
+ else {
447
+ await this.device.set_attribute({ POWER: false, MODE: 0 });
448
+ }
449
+ }
450
+ getFanState() {
451
+ return this.device.attributes.FAN_AUTO;
452
+ }
453
+ async setFanState(value) {
454
+ await this.device.set_fan_auto(value === this.platform.Characteristic.TargetFanState.AUTO);
455
+ }
456
+ async setTargetTemperature(value) {
457
+ value = Math.max(this.configDev.AC_options.minTemp, Math.min(this.configDev.AC_options.maxTemp, value));
458
+ await this.device.set_target_temperature(value);
459
+ }
460
+ getSwingMode() {
461
+ return this.device.attributes.SWING_HORIZONTAL || this.device.attributes.SWING_VERTICAL
462
+ ? this.platform.Characteristic.SwingMode.SWING_ENABLED
463
+ : this.platform.Characteristic.SwingMode.SWING_DISABLED;
464
+ }
465
+ async setSwingMode(value) {
466
+ switch (value) {
467
+ case this.platform.Characteristic.SwingMode.SWING_ENABLED:
468
+ await this.device.set_swing([platformUtils_1.SwingMode.HORIZONTAL, platformUtils_1.SwingMode.BOTH].includes(this.configDev.AC_options.swing.mode), [platformUtils_1.SwingMode.VERTICAL, platformUtils_1.SwingMode.BOTH].includes(this.configDev.AC_options.swing.mode));
469
+ break;
470
+ case this.platform.Characteristic.SwingMode.SWING_DISABLED:
471
+ await this.device.set_swing(false, false);
472
+ break;
473
+ }
474
+ }
475
+ getRotationSpeed() {
476
+ var _a;
477
+ return Math.min(100, (_a = this.device.attributes.FAN_SPEED) !== null && _a !== void 0 ? _a : 0);
478
+ }
479
+ async setRotationSpeed(value) {
480
+ await this.device.set_attribute({ FAN_SPEED: value });
481
+ }
482
+ getOutdoorTemperature() {
483
+ var _a;
484
+ return (_a = this.device.attributes.OUTDOOR_TEMPERATURE) !== null && _a !== void 0 ? _a : -270;
485
+ }
486
+ getDisplayActive() {
487
+ return this.device.attributes.SCREEN_DISPLAY === true;
488
+ }
489
+ async setDisplayActive(value) {
490
+ if (this.device.attributes.POWER) {
491
+ await this.device.set_attribute({ SCREEN_DISPLAY: !!value });
492
+ }
493
+ }
494
+ getEcoMode() {
495
+ return this.device.attributes.POWER === true && this.device.attributes.ECO_MODE;
496
+ }
497
+ async setEcoMode(value) {
498
+ await this.device.set_attribute({ ECO_MODE: !!value });
499
+ }
500
+ getBreezeAway() {
501
+ return this.device.attributes.POWER === true && this.device.attributes.INDIRECT_WIND;
502
+ }
503
+ async setBreezeAway(value) {
504
+ await this.device.set_attribute({ INDIRECT_WIND: !!value });
505
+ }
506
+ getDryMode() {
507
+ return this.device.attributes.POWER === true && this.device.attributes.MODE === 3;
508
+ }
509
+ async setDryMode(value) {
510
+ if (value) {
511
+ await this.device.set_attribute({ POWER: true, MODE: 3 });
512
+ }
513
+ else {
514
+ await this.device.set_attribute({ POWER: false, MODE: 0 });
515
+ }
516
+ }
517
+ getBoostMode() {
518
+ return this.device.attributes.POWER === true && this.device.attributes.BOOST_MODE;
519
+ }
520
+ async setBoostMode(value) {
521
+ if (value) {
522
+ await this.device.set_attribute({ POWER: true, BOOST_MODE: true });
523
+ }
524
+ else {
525
+ await this.device.set_attribute({ BOOST_MODE: false });
526
+ }
527
+ }
528
+ getAux() {
529
+ return this.device.attributes.POWER === true && this.device.attributes.SMART_EYE === true;
530
+ }
531
+ async setAux(value) {
532
+ if (value) {
533
+ await this.device.set_attribute({ SMART_EYE: true });
534
+ }
535
+ else {
536
+ await this.device.set_attribute({ SMART_EYE: false });
537
+ }
538
+ }
539
+ getAuxHeating() {
540
+ return this.device.attributes.POWER === true && this.device.attributes.AUX_HEATING === true;
541
+ }
542
+ async setAuxHeating(value) {
543
+ if (value) {
544
+ await this.device.set_attribute({ AUX_HEATING: true });
545
+ }
546
+ else {
547
+ await this.device.set_attribute({ AUX_HEATING: false });
548
+ }
549
+ }
550
+ getSwingAngleCurrentPosition() {
551
+ const value = this.swingAngleMainControl === platformUtils_1.SwingAngle.VERTICAL
552
+ ? this.device.attributes.WIND_SWING_UD_ANGLE
553
+ : this.device.attributes.WIND_SWING_LR_ANGLE;
554
+ return value === 1 ? 0 : value;
555
+ }
556
+ getSwingAngleTargetPosition() {
557
+ return this.getSwingAngleCurrentPosition();
558
+ }
559
+ async setSwingAngleTargetPosition(value) {
560
+ await this.device.set_swing_angle(this.swingAngleMainControl, Math.max(1, value));
561
+ }
562
+ getSwingAnglePositionState() {
563
+ return this.platform.Characteristic.PositionState.STOPPED;
564
+ }
565
+ getSwingAngleCurrentHorizontalTiltAngle() {
566
+ return this.device.attributes.WIND_SWING_LR_ANGLE === 1 ? 0 : this.device.attributes.WIND_SWING_LR_ANGLE;
567
+ }
568
+ getSwingAngleTargetHorizontalTiltAngle() {
569
+ return this.getSwingAngleCurrentHorizontalTiltAngle();
570
+ }
571
+ async setSwingAngleTargetHorizontalTiltAngle(value) {
572
+ await this.device.set_swing_angle(platformUtils_1.SwingAngle.HORIZONTAL, Math.max(1, value));
573
+ }
574
+ getSwingAngleCurrentVerticalTiltAngle() {
575
+ return this.device.attributes.WIND_SWING_UD_ANGLE === 1 ? 0 : this.device.attributes.WIND_SWING_UD_ANGLE;
576
+ }
577
+ getSwingAngleTargetVerticalTiltAngle() {
578
+ return this.getSwingAngleCurrentVerticalTiltAngle();
579
+ }
580
+ async setSwingAngleTargetVerticalTiltAngle(value) {
581
+ await this.device.set_swing_angle(platformUtils_1.SwingAngle.VERTICAL, Math.max(1, value));
582
+ }
583
+ }
584
+ exports.default = AirConditionerAccessory;
561
585
  //# sourceMappingURL=AirConditionerAccessory.js.map