homebridge-midea-platform 1.1.2-beta.9 → 1.2.0-beta.2

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 (110) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/CHANGELOG.md +4 -2
  3. package/config.schema.json +46 -1
  4. package/dist/accessory/AccessoryFactory.d.ts +12 -12
  5. package/dist/accessory/AccessoryFactory.js +31 -31
  6. package/dist/accessory/AirConditionerAccessory.d.ts +92 -89
  7. package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
  8. package/dist/accessory/AirConditionerAccessory.js +607 -584
  9. package/dist/accessory/AirConditionerAccessory.js.map +1 -1
  10. package/dist/accessory/BaseAccessory.d.ts +11 -11
  11. package/dist/accessory/BaseAccessory.js +21 -21
  12. package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
  13. package/dist/accessory/DehumidifierAccessory.js +344 -344
  14. package/dist/accessory/DishwasherAccessory.d.ts +31 -0
  15. package/dist/accessory/DishwasherAccessory.d.ts.map +1 -0
  16. package/dist/accessory/DishwasherAccessory.js +64 -0
  17. package/dist/accessory/DishwasherAccessory.js.map +1 -0
  18. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
  19. package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
  20. package/dist/accessory/FanAccessory.d.ts +39 -39
  21. package/dist/accessory/FanAccessory.js +123 -123
  22. package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -30
  23. package/dist/accessory/FrontLoadWasherAccessory.d.ts.map +1 -1
  24. package/dist/accessory/FrontLoadWasherAccessory.js +66 -60
  25. package/dist/accessory/FrontLoadWasherAccessory.js.map +1 -1
  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 +50 -49
  31. package/dist/core/MideaConstants.d.ts.map +1 -1
  32. package/dist/core/MideaConstants.js +58 -57
  33. package/dist/core/MideaConstants.js.map +1 -1
  34. package/dist/core/MideaDevice.d.ts +76 -76
  35. package/dist/core/MideaDevice.js +409 -409
  36. package/dist/core/MideaDiscover.d.ts +35 -35
  37. package/dist/core/MideaDiscover.js +212 -212
  38. package/dist/core/MideaMessage.d.ts +75 -75
  39. package/dist/core/MideaMessage.js +184 -184
  40. package/dist/core/MideaPacketBuilder.d.ts +10 -10
  41. package/dist/core/MideaPacketBuilder.js +60 -60
  42. package/dist/core/MideaSecurity.d.ts +63 -63
  43. package/dist/core/MideaSecurity.js +251 -251
  44. package/dist/core/MideaUtils.d.ts +32 -32
  45. package/dist/core/MideaUtils.js +181 -181
  46. package/dist/devices/DeviceFactory.d.ts +13 -12
  47. package/dist/devices/DeviceFactory.d.ts.map +1 -1
  48. package/dist/devices/DeviceFactory.js +36 -33
  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.d.ts.map +1 -1
  52. package/dist/devices/a1/MideaA1Device.js +145 -136
  53. package/dist/devices/a1/MideaA1Device.js.map +1 -1
  54. package/dist/devices/a1/MideaA1Message.d.ts +40 -40
  55. package/dist/devices/a1/MideaA1Message.js +198 -198
  56. package/dist/devices/ac/MideaACDevice.d.ts +104 -100
  57. package/dist/devices/ac/MideaACDevice.d.ts.map +1 -1
  58. package/dist/devices/ac/MideaACDevice.js +384 -381
  59. package/dist/devices/ac/MideaACDevice.js.map +1 -1
  60. package/dist/devices/ac/MideaACMessage.d.ts +94 -92
  61. package/dist/devices/ac/MideaACMessage.d.ts.map +1 -1
  62. package/dist/devices/ac/MideaACMessage.js +611 -589
  63. package/dist/devices/ac/MideaACMessage.js.map +1 -1
  64. package/dist/devices/db/MideaDBDevice.d.ts +29 -29
  65. package/dist/devices/db/MideaDBDevice.d.ts.map +1 -1
  66. package/dist/devices/db/MideaDBDevice.js +100 -88
  67. package/dist/devices/db/MideaDBDevice.js.map +1 -1
  68. package/dist/devices/db/MideaDBMessage.d.ts +32 -32
  69. package/dist/devices/db/MideaDBMessage.d.ts.map +1 -1
  70. package/dist/devices/db/MideaDBMessage.js +101 -101
  71. package/dist/devices/db/MideaDBMessage.js.map +1 -1
  72. package/dist/devices/e1/MideaE1Device.d.ts +57 -0
  73. package/dist/devices/e1/MideaE1Device.d.ts.map +1 -0
  74. package/dist/devices/e1/MideaE1Device.js +129 -0
  75. package/dist/devices/e1/MideaE1Device.js.map +1 -0
  76. package/dist/devices/e1/MideaE1Message.d.ts +29 -0
  77. package/dist/devices/e1/MideaE1Message.d.ts.map +1 -0
  78. package/dist/devices/e1/MideaE1Message.js +108 -0
  79. package/dist/devices/e1/MideaE1Message.js.map +1 -0
  80. package/dist/devices/e2/MideaE2Device.d.ts +44 -44
  81. package/dist/devices/e2/MideaE2Device.d.ts.map +1 -1
  82. package/dist/devices/e2/MideaE2Device.js +129 -119
  83. package/dist/devices/e2/MideaE2Device.js.map +1 -1
  84. package/dist/devices/e2/MideaE2Message.d.ts +33 -33
  85. package/dist/devices/e2/MideaE2Message.js +132 -132
  86. package/dist/devices/e3/MideaE3Device.d.ts +43 -43
  87. package/dist/devices/e3/MideaE3Device.d.ts.map +1 -1
  88. package/dist/devices/e3/MideaE3Device.js +137 -125
  89. package/dist/devices/e3/MideaE3Device.js.map +1 -1
  90. package/dist/devices/e3/MideaE3Message.d.ts +51 -51
  91. package/dist/devices/e3/MideaE3Message.js +136 -136
  92. package/dist/devices/fa/MideaFADevice.d.ts +36 -36
  93. package/dist/devices/fa/MideaFADevice.d.ts.map +1 -1
  94. package/dist/devices/fa/MideaFADevice.js +106 -92
  95. package/dist/devices/fa/MideaFADevice.js.map +1 -1
  96. package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
  97. package/dist/devices/fa/MideaFAMessage.js +98 -98
  98. package/dist/index.d.ts +6 -6
  99. package/dist/index.js +6 -6
  100. package/dist/platform.d.ts +60 -60
  101. package/dist/platform.js +212 -212
  102. package/dist/platformUtils.d.ts +106 -99
  103. package/dist/platformUtils.d.ts.map +1 -1
  104. package/dist/platformUtils.js +101 -97
  105. package/dist/platformUtils.js.map +1 -1
  106. package/dist/settings.d.ts +8 -8
  107. package/dist/settings.js +11 -11
  108. package/docs/e1.md +3 -0
  109. package/homebridge-ui/server.js +3 -0
  110. package/package.json +1 -1
@@ -1,347 +1,347 @@
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 DehumidifierAccessory 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;
15
- super(platform, accessory, device, configDev);
16
- this.device = device;
17
- this.configDev = configDev;
18
- // Increment this every time we make a change to accessory that requires
19
- // previously cached Homebridge service to be deleted/replaced.
20
- this.serviceVersion = 1;
21
- this.platform.log.debug(`[${device.name}] Dehumidifier serviceVersion: ${this.serviceVersion}, currentVersion: ${this.accessory.context.serviceVersion}`);
22
- const service = this.accessory.getService(this.platform.Service.HumidifierDehumidifier);
23
- if (service && this.accessory.context.serviceVersion !== this.serviceVersion) {
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 DehumidifierAccessory 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;
15
+ super(platform, accessory, device, configDev);
16
+ this.device = device;
17
+ this.configDev = configDev;
18
+ // Increment this every time we make a change to accessory that requires
19
+ // previously cached Homebridge service to be deleted/replaced.
20
+ this.serviceVersion = 1;
21
+ this.platform.log.debug(`[${device.name}] Dehumidifier serviceVersion: ${this.serviceVersion}, currentVersion: ${this.accessory.context.serviceVersion}`);
22
+ const service = this.accessory.getService(this.platform.Service.HumidifierDehumidifier);
23
+ if (service && this.accessory.context.serviceVersion !== this.serviceVersion) {
24
24
  this.platform.log.info(`[${this.device.name}] New dehumidifier service version.\
25
- Upgrade from v${this.accessory.context.serviceVersion} to v${this.serviceVersion}.`);
26
- this.accessory.removeService(service);
27
- this.service = this.accessory.addService(this.platform.Service.HumidifierDehumidifier);
28
- this.accessory.context.serviceVersion = this.serviceVersion;
29
- }
30
- else if (service) {
31
- this.platform.log.debug(`[${this.device.name}] Existing dehumidifier service version.`);
32
- this.service = service;
33
- }
34
- else {
35
- this.platform.log.debug(`[${this.device.name}] Creating new dehumidifier service.`);
36
- this.service = this.accessory.addService(this.platform.Service.HumidifierDehumidifier);
37
- this.accessory.context.serviceVersion = this.serviceVersion;
38
- }
39
- this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
40
- this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
41
- this.service
42
- .getCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState)
43
- .onGet(this.getCurrentHumidifierDehumidifierState.bind(this));
44
- // need to set as dehumidifier before setting validValues as defult of 0 will
45
- // throw error when we state that only valid value is dehumidifier (2).
46
- this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER);
47
- this.service
48
- .getCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState)
49
- .onGet(this.getTargetHumidifierDehumidifierState.bind(this))
50
- .onSet(this.setTargetHumidifierDehumidifierState.bind(this))
51
- .setProps({
52
- validValues: [this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER],
53
- });
54
- this.service
55
- .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
56
- .onGet(this.getCurrentRelativeHumidity.bind(this))
57
- .setProps({
58
- minValue: 0,
59
- maxValue: 100,
60
- minStep: 1,
61
- });
62
- this.service
63
- .getCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold)
64
- .onGet(this.getRelativeHumidityDehumidifierThreshold.bind(this))
65
- .onSet(this.setRelativeHumidityDehumidifierThreshold.bind(this))
66
- .setProps({
67
- minValue: 0,
68
- maxValue: 100,
69
- minStep: 5,
70
- });
71
- this.service
72
- .getCharacteristic(this.platform.Characteristic.RotationSpeed)
73
- .onGet(this.getRotationSpeed.bind(this))
74
- .onSet(this.setRotationSpeed.bind(this));
75
- this.service.getCharacteristic(this.platform.Characteristic.WaterLevel).onGet(this.getWaterLevel.bind(this));
76
- // Temperature sensor
77
- this.temperatureService = this.accessory.getServiceById(this.platform.Service.TemperatureSensor, 'Temperature');
78
- if (this.configDev.A1_options.temperatureSensor) {
79
- (_a = this.temperatureService) !== null && _a !== void 0 ? _a : (this.temperatureService = this.accessory.addService(this.platform.Service.TemperatureSensor, 'Temperature', 'Temperature'));
80
- this.temperatureService.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getTemperature.bind(this));
81
- }
82
- else if (this.temperatureService) {
83
- this.accessory.removeService(this.temperatureService);
84
- }
85
- // Fan
86
- this.fanService = this.accessory.getServiceById(this.platform.Service.Fanv2, 'Fan');
87
- if (this.configDev.A1_options.fanAccessory) {
88
- (_b = this.fanService) !== null && _b !== void 0 ? _b : (this.fanService = this.accessory.addService(this.platform.Service.Fanv2, 'Fan', 'Fan'));
89
- this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Fan`);
90
- this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Fan`);
91
- this.fanService
92
- .getCharacteristic(this.platform.Characteristic.Active)
93
- .onGet(this.getActive.bind(this))
94
- .onSet(this.setActive.bind(this));
95
- this.fanService
96
- .getCharacteristic(this.platform.Characteristic.RotationSpeed)
97
- .onGet(this.getRotationSpeed.bind(this))
98
- .onSet(this.setRotationSpeed.bind(this));
99
- }
100
- else if (this.fanService) {
101
- this.accessory.removeService(this.fanService);
102
- }
103
- // Humidity sensor
104
- this.humiditySensorService = this.accessory.getServiceById(this.platform.Service.HumiditySensor, 'Humidity');
105
- if (this.configDev.A1_options.humiditySensor) {
106
- (_c = this.humiditySensorService) !== null && _c !== void 0 ? _c : (this.humiditySensorService = this.accessory.addService(this.platform.Service.HumiditySensor, 'Humidity', 'Humidity'));
107
- this.humiditySensorService
108
- .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
109
- .onGet(this.getCurrentRelativeHumidity.bind(this));
110
- }
111
- else if (this.humiditySensorService) {
112
- this.accessory.removeService(this.humiditySensorService);
113
- }
114
- // Pump switch
115
- this.pumpService = this.accessory.getServiceById(this.platform.Service.Switch, 'Pump');
116
- if (this.configDev.A1_options.pumpSwitch) {
117
- (_d = this.pumpService) !== null && _d !== void 0 ? _d : (this.pumpService = this.accessory.addService(this.platform.Service.Switch, 'Pump', 'Pump'));
118
- this.pumpService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Pump`);
119
- this.pumpService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Pump`);
120
- this.pumpService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getPump.bind(this)).onSet(this.setPump.bind(this));
121
- }
122
- else if (this.pumpService) {
123
- this.accessory.removeService(this.pumpService);
124
- }
125
- this.waterTankService =
126
- (_e = this.accessory.getServiceById(this.platform.Service.ContactSensor, 'WaterTankContact')) !== null && _e !== void 0 ? _e : this.accessory.getServiceById(this.platform.Service.LeakSensor, 'WaterTankLeak');
127
- if (this.configDev.A1_options.waterTankSensor !== platformUtils_1.WaterTankSensor.NONE) {
128
- if (this.configDev.A1_options.waterTankSensor === platformUtils_1.WaterTankSensor.CONTACT_SENSOR) {
129
- (_f = this.waterTankService) !== null && _f !== void 0 ? _f : (this.waterTankService = this.accessory.addService(this.platform.Service.ContactSensor, `${this.device.name} Water Tank Sensor`, 'WaterTankContact'));
130
- this.waterTankService.getCharacteristic(this.platform.Characteristic.ContactSensorState).onGet(this.getWaterTankFull.bind(this));
131
- }
132
- else {
133
- (_g = this.waterTankService) !== null && _g !== void 0 ? _g : (this.waterTankService = this.accessory.addService(this.platform.Service.LeakSensor, `${this.device.name} Water Tank Sensor`, 'WaterTankLeak'));
134
- this.waterTankService.getCharacteristic(this.platform.Characteristic.LeakDetected).onGet(this.getWaterTankFull.bind(this));
135
- }
136
- this.waterTankService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Water Tank Sensor`);
137
- this.waterTankService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Water Tank Sensor`);
138
- }
139
- else if (this.waterTankService) {
140
- this.accessory.removeService(this.waterTankService);
141
- }
142
- }
143
- /*********************************************************************
144
- * Callback function called by MideaDevice whenever there is a change to
145
- * any attribute value.
146
- */
147
- async updateCharacteristics(attributes) {
148
- var _a, _b, _c, _d, _e, _f, _g;
149
- for (const [k, v] of Object.entries(attributes)) {
150
- this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
151
- let updateState = false;
152
- switch (k.toLowerCase()) {
153
- case 'power':
154
- updateState = true;
155
- break;
156
- case 'target_humidity':
157
- this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold, v);
158
- updateState = true;
159
- break;
160
- case 'fan_speed':
161
- this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, v);
162
- (_a = this.fanService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.RotationSpeed, v);
163
- updateState = true;
164
- break;
165
- case 'current_humidity':
166
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, v);
167
- (_b = this.humiditySensorService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, v);
168
- updateState = true;
169
- break;
170
- case 'mode':
171
- updateState = true;
172
- break;
173
- case 'current_temperature':
174
- (_c = this.temperatureService) === null || _c === void 0 ? void 0 : _c.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, v);
175
- break;
176
- case 'tank_level':
177
- this.service.updateCharacteristic(this.platform.Characteristic.WaterLevel, v);
178
- break;
179
- case 'pump':
180
- (_d = this.pumpService) === null || _d === void 0 ? void 0 : _d.updateCharacteristic(this.platform.Characteristic.On, v);
181
- break;
182
- case 'tank_full':
183
- if (this.configDev.A1_options.waterTankSensor === platformUtils_1.WaterTankSensor.LEAK_SENSOR) {
184
- (_e = this.waterTankService) === null || _e === void 0 ? void 0 : _e.updateCharacteristic(this.platform.Characteristic.LeakDetected, v);
185
- }
186
- else if (this.configDev.A1_options.waterTankSensor === platformUtils_1.WaterTankSensor.CONTACT_SENSOR) {
187
- (_f = this.waterTankService) === null || _f === void 0 ? void 0 : _f.updateCharacteristic(this.platform.Characteristic.ContactSensorState, v);
188
- }
189
- break;
190
- case 'water_level_set':
191
- // No HomeKit characteristic
192
- break;
193
- case 'swing':
194
- // No HomeKit characteristic
195
- break;
196
- case 'child_lock':
197
- // No HomeKit characteristic
198
- break;
199
- default:
200
- this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
201
- }
202
- if (updateState) {
203
- this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
204
- this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER);
205
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, this.currentHumidifierDehumidifierState());
206
- (_g = this.fanService) === null || _g === void 0 ? void 0 : _g.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
207
- }
208
- }
209
- }
210
- /*********************************************************************
211
- * Callback functions for each Homebridge/HomeKit service
212
- *
213
- */
214
- getActive() {
215
- this.platform.log.debug(`[${this.device.name}] GET Active, value: ${this.device.attributes.POWER}`);
216
- return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
217
- }
218
- async setActive(value) {
219
- this.platform.log.debug(`[${this.device.name}] SET Active to: ${value}`);
220
- await this.device.set_attribute({ POWER: !!value });
221
- }
222
- // Handle requests to get the current value of the "HumidifierDehumidifierState" characteristic
223
- getCurrentHumidifierDehumidifierState() {
224
- this.platform.log.debug(`[${this.device.name}] GET CurrentHumidifierDehumidifierState, value: ${this.device.attributes.POWER},${this.device.attributes.MODE}`);
225
- return this.currentHumidifierDehumidifierState();
226
- }
227
- currentHumidifierDehumidifierState() {
228
- if (!this.device.attributes.POWER) {
229
- // Powered off, must be inactive
230
- return this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
231
- }
232
- else {
233
- // Powered on, check mode
234
- if (this.device.attributes.MODE >= 2) {
235
- // Dehumidifying
236
- return this.platform.Characteristic.CurrentHumidifierDehumidifierState.DEHUMIDIFYING;
237
- }
238
- else if (this.device.attributes.MODE === 1) {
239
- // Whether deumidifying depends on whether we have reached target. This is not
240
- // always accurate, but is best we can do to signal whether actively dehumidifing or not.
241
- if (this.device.attributes.CURRENT_HUMIDITY < this.device.attributes.TARGET_HUMIDITY) {
242
- return this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
243
- }
244
- else {
245
- return this.platform.Characteristic.CurrentHumidifierDehumidifierState.DEHUMIDIFYING;
246
- }
247
- }
248
- return this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
249
- }
250
- }
251
- // Handle requests to get the target value of the "HumidifierDehumidifierState" characteristic
252
- getTargetHumidifierDehumidifierState() {
253
- this.platform.log.debug(
254
- // eslint-disable-next-line max-len
255
- `[${this.device.name}] GET TargetHumidifierDehumidifierState, value: ${this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER}`);
256
- // Always return that we are a dehumidifier, other states not supported.
257
- return this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER;
258
- }
259
- // Handle requests to set the target value of the "HumidifierDehumidifierState" characteristic
260
- async setTargetHumidifierDehumidifierState(value) {
261
- this.platform.log.debug(`[${this.device.name}] SET TargetHumidifierDehumidifierState to: ${value}`);
262
- if (value !== this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER) {
263
- throw new Error(`Device ${this.device.name} (${this.device.id}) can only be a Dehumidifier, illegal value: ${value}`);
264
- }
265
- }
266
- // Handle requests to get the current value of the "RelativeHumidity" characteristic
267
- getCurrentRelativeHumidity() {
25
+ Upgrade from v${this.accessory.context.serviceVersion} to v${this.serviceVersion}.`);
26
+ this.accessory.removeService(service);
27
+ this.service = this.accessory.addService(this.platform.Service.HumidifierDehumidifier);
28
+ this.accessory.context.serviceVersion = this.serviceVersion;
29
+ }
30
+ else if (service) {
31
+ this.platform.log.debug(`[${this.device.name}] Existing dehumidifier service version.`);
32
+ this.service = service;
33
+ }
34
+ else {
35
+ this.platform.log.debug(`[${this.device.name}] Creating new dehumidifier service.`);
36
+ this.service = this.accessory.addService(this.platform.Service.HumidifierDehumidifier);
37
+ this.accessory.context.serviceVersion = this.serviceVersion;
38
+ }
39
+ this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
40
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
41
+ this.service
42
+ .getCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState)
43
+ .onGet(this.getCurrentHumidifierDehumidifierState.bind(this));
44
+ // need to set as dehumidifier before setting validValues as defult of 0 will
45
+ // throw error when we state that only valid value is dehumidifier (2).
46
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER);
47
+ this.service
48
+ .getCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState)
49
+ .onGet(this.getTargetHumidifierDehumidifierState.bind(this))
50
+ .onSet(this.setTargetHumidifierDehumidifierState.bind(this))
51
+ .setProps({
52
+ validValues: [this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER],
53
+ });
54
+ this.service
55
+ .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
56
+ .onGet(this.getCurrentRelativeHumidity.bind(this))
57
+ .setProps({
58
+ minValue: 0,
59
+ maxValue: 100,
60
+ minStep: 1,
61
+ });
62
+ this.service
63
+ .getCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold)
64
+ .onGet(this.getRelativeHumidityDehumidifierThreshold.bind(this))
65
+ .onSet(this.setRelativeHumidityDehumidifierThreshold.bind(this))
66
+ .setProps({
67
+ minValue: 0,
68
+ maxValue: 100,
69
+ minStep: 5,
70
+ });
71
+ this.service
72
+ .getCharacteristic(this.platform.Characteristic.RotationSpeed)
73
+ .onGet(this.getRotationSpeed.bind(this))
74
+ .onSet(this.setRotationSpeed.bind(this));
75
+ this.service.getCharacteristic(this.platform.Characteristic.WaterLevel).onGet(this.getWaterLevel.bind(this));
76
+ // Temperature sensor
77
+ this.temperatureService = this.accessory.getServiceById(this.platform.Service.TemperatureSensor, 'Temperature');
78
+ if (this.configDev.A1_options.temperatureSensor) {
79
+ (_a = this.temperatureService) !== null && _a !== void 0 ? _a : (this.temperatureService = this.accessory.addService(this.platform.Service.TemperatureSensor, 'Temperature', 'Temperature'));
80
+ this.temperatureService.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getTemperature.bind(this));
81
+ }
82
+ else if (this.temperatureService) {
83
+ this.accessory.removeService(this.temperatureService);
84
+ }
85
+ // Fan
86
+ this.fanService = this.accessory.getServiceById(this.platform.Service.Fanv2, 'Fan');
87
+ if (this.configDev.A1_options.fanAccessory) {
88
+ (_b = this.fanService) !== null && _b !== void 0 ? _b : (this.fanService = this.accessory.addService(this.platform.Service.Fanv2, 'Fan', 'Fan'));
89
+ this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Fan`);
90
+ this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Fan`);
91
+ this.fanService
92
+ .getCharacteristic(this.platform.Characteristic.Active)
93
+ .onGet(this.getActive.bind(this))
94
+ .onSet(this.setActive.bind(this));
95
+ this.fanService
96
+ .getCharacteristic(this.platform.Characteristic.RotationSpeed)
97
+ .onGet(this.getRotationSpeed.bind(this))
98
+ .onSet(this.setRotationSpeed.bind(this));
99
+ }
100
+ else if (this.fanService) {
101
+ this.accessory.removeService(this.fanService);
102
+ }
103
+ // Humidity sensor
104
+ this.humiditySensorService = this.accessory.getServiceById(this.platform.Service.HumiditySensor, 'Humidity');
105
+ if (this.configDev.A1_options.humiditySensor) {
106
+ (_c = this.humiditySensorService) !== null && _c !== void 0 ? _c : (this.humiditySensorService = this.accessory.addService(this.platform.Service.HumiditySensor, 'Humidity', 'Humidity'));
107
+ this.humiditySensorService
108
+ .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
109
+ .onGet(this.getCurrentRelativeHumidity.bind(this));
110
+ }
111
+ else if (this.humiditySensorService) {
112
+ this.accessory.removeService(this.humiditySensorService);
113
+ }
114
+ // Pump switch
115
+ this.pumpService = this.accessory.getServiceById(this.platform.Service.Switch, 'Pump');
116
+ if (this.configDev.A1_options.pumpSwitch) {
117
+ (_d = this.pumpService) !== null && _d !== void 0 ? _d : (this.pumpService = this.accessory.addService(this.platform.Service.Switch, 'Pump', 'Pump'));
118
+ this.pumpService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Pump`);
119
+ this.pumpService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Pump`);
120
+ this.pumpService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getPump.bind(this)).onSet(this.setPump.bind(this));
121
+ }
122
+ else if (this.pumpService) {
123
+ this.accessory.removeService(this.pumpService);
124
+ }
125
+ this.waterTankService =
126
+ (_e = this.accessory.getServiceById(this.platform.Service.ContactSensor, 'WaterTankContact')) !== null && _e !== void 0 ? _e : this.accessory.getServiceById(this.platform.Service.LeakSensor, 'WaterTankLeak');
127
+ if (this.configDev.A1_options.waterTankSensor !== platformUtils_1.WaterTankSensor.NONE) {
128
+ if (this.configDev.A1_options.waterTankSensor === platformUtils_1.WaterTankSensor.CONTACT_SENSOR) {
129
+ (_f = this.waterTankService) !== null && _f !== void 0 ? _f : (this.waterTankService = this.accessory.addService(this.platform.Service.ContactSensor, `${this.device.name} Water Tank Sensor`, 'WaterTankContact'));
130
+ this.waterTankService.getCharacteristic(this.platform.Characteristic.ContactSensorState).onGet(this.getWaterTankFull.bind(this));
131
+ }
132
+ else {
133
+ (_g = this.waterTankService) !== null && _g !== void 0 ? _g : (this.waterTankService = this.accessory.addService(this.platform.Service.LeakSensor, `${this.device.name} Water Tank Sensor`, 'WaterTankLeak'));
134
+ this.waterTankService.getCharacteristic(this.platform.Characteristic.LeakDetected).onGet(this.getWaterTankFull.bind(this));
135
+ }
136
+ this.waterTankService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Water Tank Sensor`);
137
+ this.waterTankService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Water Tank Sensor`);
138
+ }
139
+ else if (this.waterTankService) {
140
+ this.accessory.removeService(this.waterTankService);
141
+ }
142
+ }
143
+ /*********************************************************************
144
+ * Callback function called by MideaDevice whenever there is a change to
145
+ * any attribute value.
146
+ */
147
+ async updateCharacteristics(attributes) {
148
+ var _a, _b, _c, _d, _e, _f, _g;
149
+ for (const [k, v] of Object.entries(attributes)) {
150
+ this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
151
+ let updateState = false;
152
+ switch (k.toLowerCase()) {
153
+ case 'power':
154
+ updateState = true;
155
+ break;
156
+ case 'target_humidity':
157
+ this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold, v);
158
+ updateState = true;
159
+ break;
160
+ case 'fan_speed':
161
+ this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, v);
162
+ (_a = this.fanService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.RotationSpeed, v);
163
+ updateState = true;
164
+ break;
165
+ case 'current_humidity':
166
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, v);
167
+ (_b = this.humiditySensorService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, v);
168
+ updateState = true;
169
+ break;
170
+ case 'mode':
171
+ updateState = true;
172
+ break;
173
+ case 'current_temperature':
174
+ (_c = this.temperatureService) === null || _c === void 0 ? void 0 : _c.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, v);
175
+ break;
176
+ case 'tank_level':
177
+ this.service.updateCharacteristic(this.platform.Characteristic.WaterLevel, v);
178
+ break;
179
+ case 'pump':
180
+ (_d = this.pumpService) === null || _d === void 0 ? void 0 : _d.updateCharacteristic(this.platform.Characteristic.On, v);
181
+ break;
182
+ case 'tank_full':
183
+ if (this.configDev.A1_options.waterTankSensor === platformUtils_1.WaterTankSensor.LEAK_SENSOR) {
184
+ (_e = this.waterTankService) === null || _e === void 0 ? void 0 : _e.updateCharacteristic(this.platform.Characteristic.LeakDetected, v);
185
+ }
186
+ else if (this.configDev.A1_options.waterTankSensor === platformUtils_1.WaterTankSensor.CONTACT_SENSOR) {
187
+ (_f = this.waterTankService) === null || _f === void 0 ? void 0 : _f.updateCharacteristic(this.platform.Characteristic.ContactSensorState, v);
188
+ }
189
+ break;
190
+ case 'water_level_set':
191
+ // No HomeKit characteristic
192
+ break;
193
+ case 'swing':
194
+ // No HomeKit characteristic
195
+ break;
196
+ case 'child_lock':
197
+ // No HomeKit characteristic
198
+ break;
199
+ default:
200
+ this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
201
+ }
202
+ if (updateState) {
203
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
204
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER);
205
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, this.currentHumidifierDehumidifierState());
206
+ (_g = this.fanService) === null || _g === void 0 ? void 0 : _g.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
207
+ }
208
+ }
209
+ }
210
+ /*********************************************************************
211
+ * Callback functions for each Homebridge/HomeKit service
212
+ *
213
+ */
214
+ getActive() {
215
+ this.platform.log.debug(`[${this.device.name}] GET Active, value: ${this.device.attributes.POWER}`);
216
+ return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
217
+ }
218
+ async setActive(value) {
219
+ this.platform.log.debug(`[${this.device.name}] SET Active to: ${value}`);
220
+ await this.device.set_attribute({ POWER: !!value });
221
+ }
222
+ // Handle requests to get the current value of the "HumidifierDehumidifierState" characteristic
223
+ getCurrentHumidifierDehumidifierState() {
224
+ this.platform.log.debug(`[${this.device.name}] GET CurrentHumidifierDehumidifierState, value: ${this.device.attributes.POWER},${this.device.attributes.MODE}`);
225
+ return this.currentHumidifierDehumidifierState();
226
+ }
227
+ currentHumidifierDehumidifierState() {
228
+ if (!this.device.attributes.POWER) {
229
+ // Powered off, must be inactive
230
+ return this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
231
+ }
232
+ else {
233
+ // Powered on, check mode
234
+ if (this.device.attributes.MODE >= 2) {
235
+ // Dehumidifying
236
+ return this.platform.Characteristic.CurrentHumidifierDehumidifierState.DEHUMIDIFYING;
237
+ }
238
+ else if (this.device.attributes.MODE === 1) {
239
+ // Whether deumidifying depends on whether we have reached target. This is not
240
+ // always accurate, but is best we can do to signal whether actively dehumidifing or not.
241
+ if (this.device.attributes.CURRENT_HUMIDITY < this.device.attributes.TARGET_HUMIDITY) {
242
+ return this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
243
+ }
244
+ else {
245
+ return this.platform.Characteristic.CurrentHumidifierDehumidifierState.DEHUMIDIFYING;
246
+ }
247
+ }
248
+ return this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
249
+ }
250
+ }
251
+ // Handle requests to get the target value of the "HumidifierDehumidifierState" characteristic
252
+ getTargetHumidifierDehumidifierState() {
253
+ this.platform.log.debug(
254
+ // eslint-disable-next-line max-len
255
+ `[${this.device.name}] GET TargetHumidifierDehumidifierState, value: ${this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER}`);
256
+ // Always return that we are a dehumidifier, other states not supported.
257
+ return this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER;
258
+ }
259
+ // Handle requests to set the target value of the "HumidifierDehumidifierState" characteristic
260
+ async setTargetHumidifierDehumidifierState(value) {
261
+ this.platform.log.debug(`[${this.device.name}] SET TargetHumidifierDehumidifierState to: ${value}`);
262
+ if (value !== this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER) {
263
+ throw new Error(`Device ${this.device.name} (${this.device.id}) can only be a Dehumidifier, illegal value: ${value}`);
264
+ }
265
+ }
266
+ // Handle requests to get the current value of the "RelativeHumidity" characteristic
267
+ getCurrentRelativeHumidity() {
268
268
  this.platform.log.debug(`[${this.device.name}] GET CurrentRelativeHumidity, value: ${this.device.attributes.CURRENT_HUMIDITY},\
269
- custom offset: ${this.configDev.A1_options.humidityOffset}`);
270
- // Adding custom offset to the humidity value
271
- return this.device.attributes.CURRENT_HUMIDITY + this.configDev.A1_options.humidityOffset;
272
- }
273
- // Handle requests to get the Relative value of the "HumidityDehumidifierThreshold" characteristic
274
- getRelativeHumidityDehumidifierThreshold() {
275
- this.platform.log.debug(`[${this.device.name}] GET RelativeHumidityDehumidifierThreshold, value: ${this.device.attributes.TARGET_HUMIDITY}`);
276
- return this.device.attributes.TARGET_HUMIDITY;
277
- }
278
- // Handle requests to set the Relative value of the "HumidityDehumidifierThreshold" characteristic
279
- async setRelativeHumidityDehumidifierThreshold(value) {
280
- let RequestedHumidity = value;
281
- // valid humidity has to be between min and max values
282
- RequestedHumidity =
283
- RequestedHumidity < this.device.MIN_HUMIDITY
284
- ? this.device.MIN_HUMIDITY
285
- : RequestedHumidity > this.device.MAX_HUMIDITY
286
- ? this.device.MAX_HUMIDITY
287
- : RequestedHumidity;
288
- this.platform.log.debug(`[${this.device.name}] SET RelativeHumidityDehumidifierThreshold to: ${RequestedHumidity} (${value})`);
289
- await this.device.set_attribute({ TARGET_HUMIDITY: RequestedHumidity });
290
- // Update HomeKit in case we adjusted the value outside of min and max values
291
- if (RequestedHumidity !== value) {
292
- // We had to adjust the requested value to within permitted range... Update homekit to actual value set.
293
- // Calling updateCharacteristic within set handler seems to fail, new value is not accepted. Workaround is
294
- // to request the update after short delay (say 50ms) to allow homebridge/homekit to complete the set handler.
295
- setTimeout(() => {
296
- this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold, RequestedHumidity);
297
- }, 50);
298
- }
299
- }
300
- // Handle requests to get the current value of the "RotationSpeed" characteristic
301
- getRotationSpeed() {
302
- this.platform.log.debug(`[${this.device.name}] GET RotationSpeed, value: ${this.device.attributes.FAN_SPEED}`);
303
- return this.device.attributes.FAN_SPEED;
304
- }
305
- // Handle requests to set the "RotationSpeed" characteristic
306
- async setRotationSpeed(value) {
307
- let speed = value;
308
- speed = speed <= 40 ? 40 : speed > 40 && speed <= 60 ? 60 : 80;
309
- this.platform.log.debug(`[${this.device.name}] SET RotationSpeed to: ${speed} (${value})`);
310
- await this.device.set_attribute({ FAN_SPEED: speed });
311
- if (speed !== value) {
312
- // We had to adjust the requested value to within permitted range... Update homekit to actual value set.
313
- // Calling updateCharacteristic within set handler seems to fail, new value is not accepted. Workaround is
314
- // to request the update after short delay (say 50ms) to allow homebridge/homekit to complete the set handler.
315
- setTimeout(() => {
316
- this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, speed);
317
- }, 50);
318
- }
319
- }
320
- // Handle requests to get the current value of the "WaterLevel" characteristic
321
- getWaterLevel() {
322
- this.platform.log.debug(`[${this.device.name}] GET WaterLevel, value: ${this.device.attributes.TANK_LEVEL}`);
323
- return this.device.attributes.TANK_LEVEL;
324
- }
325
- // Handle requests to get the current value of the "Pump" characteristic
326
- getTemperature() {
327
- this.platform.log.debug(`[${this.device.name}] GET Temperature, value: ${this.device.attributes.CURRENT_TEMPERATURE}`);
328
- return this.device.attributes.CURRENT_TEMPERATURE;
329
- }
330
- // Handle requests to get the current value of the "Pump" characteristic
331
- getPump() {
332
- this.platform.log.debug(`[${this.device.name}] GET Pump, value: ${this.device.attributes.PUMP}`);
333
- return this.device.attributes.POWER === true && this.device.attributes.PUMP;
334
- }
335
- // Handle requests to set the "Pump" characteristic
336
- async setPump(value) {
337
- this.platform.log.debug(`[${this.device.name}] SET Pump to: ${value}`);
338
- await this.device.set_attribute({ PUMP: !!value });
339
- }
340
- // Handle requests to get the current value of the "WaterTankFull" characteristic
341
- getWaterTankFull() {
342
- this.platform.log.debug(`[${this.device.name}] GET WaterTankFull, value: ${this.device.attributes.TANK_FULL}`);
343
- return this.device.attributes.TANK_FULL;
344
- }
345
- }
346
- exports.default = DehumidifierAccessory;
269
+ custom offset: ${this.configDev.A1_options.humidityOffset}`);
270
+ // Adding custom offset to the humidity value
271
+ return this.device.attributes.CURRENT_HUMIDITY + this.configDev.A1_options.humidityOffset;
272
+ }
273
+ // Handle requests to get the Relative value of the "HumidityDehumidifierThreshold" characteristic
274
+ getRelativeHumidityDehumidifierThreshold() {
275
+ this.platform.log.debug(`[${this.device.name}] GET RelativeHumidityDehumidifierThreshold, value: ${this.device.attributes.TARGET_HUMIDITY}`);
276
+ return this.device.attributes.TARGET_HUMIDITY;
277
+ }
278
+ // Handle requests to set the Relative value of the "HumidityDehumidifierThreshold" characteristic
279
+ async setRelativeHumidityDehumidifierThreshold(value) {
280
+ let RequestedHumidity = value;
281
+ // valid humidity has to be between min and max values
282
+ RequestedHumidity =
283
+ RequestedHumidity < this.device.MIN_HUMIDITY
284
+ ? this.device.MIN_HUMIDITY
285
+ : RequestedHumidity > this.device.MAX_HUMIDITY
286
+ ? this.device.MAX_HUMIDITY
287
+ : RequestedHumidity;
288
+ this.platform.log.debug(`[${this.device.name}] SET RelativeHumidityDehumidifierThreshold to: ${RequestedHumidity} (${value})`);
289
+ await this.device.set_attribute({ TARGET_HUMIDITY: RequestedHumidity });
290
+ // Update HomeKit in case we adjusted the value outside of min and max values
291
+ if (RequestedHumidity !== value) {
292
+ // We had to adjust the requested value to within permitted range... Update homekit to actual value set.
293
+ // Calling updateCharacteristic within set handler seems to fail, new value is not accepted. Workaround is
294
+ // to request the update after short delay (say 50ms) to allow homebridge/homekit to complete the set handler.
295
+ setTimeout(() => {
296
+ this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold, RequestedHumidity);
297
+ }, 50);
298
+ }
299
+ }
300
+ // Handle requests to get the current value of the "RotationSpeed" characteristic
301
+ getRotationSpeed() {
302
+ this.platform.log.debug(`[${this.device.name}] GET RotationSpeed, value: ${this.device.attributes.FAN_SPEED}`);
303
+ return this.device.attributes.FAN_SPEED;
304
+ }
305
+ // Handle requests to set the "RotationSpeed" characteristic
306
+ async setRotationSpeed(value) {
307
+ let speed = value;
308
+ speed = speed <= 40 ? 40 : speed > 40 && speed <= 60 ? 60 : 80;
309
+ this.platform.log.debug(`[${this.device.name}] SET RotationSpeed to: ${speed} (${value})`);
310
+ await this.device.set_attribute({ FAN_SPEED: speed });
311
+ if (speed !== value) {
312
+ // We had to adjust the requested value to within permitted range... Update homekit to actual value set.
313
+ // Calling updateCharacteristic within set handler seems to fail, new value is not accepted. Workaround is
314
+ // to request the update after short delay (say 50ms) to allow homebridge/homekit to complete the set handler.
315
+ setTimeout(() => {
316
+ this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, speed);
317
+ }, 50);
318
+ }
319
+ }
320
+ // Handle requests to get the current value of the "WaterLevel" characteristic
321
+ getWaterLevel() {
322
+ this.platform.log.debug(`[${this.device.name}] GET WaterLevel, value: ${this.device.attributes.TANK_LEVEL}`);
323
+ return this.device.attributes.TANK_LEVEL;
324
+ }
325
+ // Handle requests to get the current value of the "Pump" characteristic
326
+ getTemperature() {
327
+ this.platform.log.debug(`[${this.device.name}] GET Temperature, value: ${this.device.attributes.CURRENT_TEMPERATURE}`);
328
+ return this.device.attributes.CURRENT_TEMPERATURE;
329
+ }
330
+ // Handle requests to get the current value of the "Pump" characteristic
331
+ getPump() {
332
+ this.platform.log.debug(`[${this.device.name}] GET Pump, value: ${this.device.attributes.PUMP}`);
333
+ return this.device.attributes.POWER === true && this.device.attributes.PUMP;
334
+ }
335
+ // Handle requests to set the "Pump" characteristic
336
+ async setPump(value) {
337
+ this.platform.log.debug(`[${this.device.name}] SET Pump to: ${value}`);
338
+ await this.device.set_attribute({ PUMP: !!value });
339
+ }
340
+ // Handle requests to get the current value of the "WaterTankFull" characteristic
341
+ getWaterTankFull() {
342
+ this.platform.log.debug(`[${this.device.name}] GET WaterTankFull, value: ${this.device.attributes.TANK_FULL}`);
343
+ return this.device.attributes.TANK_FULL;
344
+ }
345
+ }
346
+ exports.default = DehumidifierAccessory;
347
347
  //# sourceMappingURL=DehumidifierAccessory.js.map