homebridge-midea-platform 1.1.0-beta.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/CHANGELOG.md +3 -0
  3. package/config.schema.json +8 -1
  4. package/dist/accessory/AccessoryFactory.d.ts +11 -11
  5. package/dist/accessory/AccessoryFactory.js +28 -28
  6. package/dist/accessory/AirConditionerAccessory.d.ts +86 -86
  7. package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
  8. package/dist/accessory/AirConditionerAccessory.js +560 -561
  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 +343 -343
  14. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
  15. package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
  16. package/dist/accessory/FanAccessory.d.ts +39 -39
  17. package/dist/accessory/FanAccessory.js +123 -123
  18. package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
  19. package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
  20. package/dist/core/MideaCloud.d.ts +35 -35
  21. package/dist/core/MideaCloud.js +350 -350
  22. package/dist/core/MideaConstants.d.ts +48 -48
  23. package/dist/core/MideaConstants.js +56 -56
  24. package/dist/core/MideaDevice.d.ts +76 -76
  25. package/dist/core/MideaDevice.js +409 -409
  26. package/dist/core/MideaDiscover.d.ts +35 -35
  27. package/dist/core/MideaDiscover.js +212 -212
  28. package/dist/core/MideaMessage.d.ts +75 -75
  29. package/dist/core/MideaMessage.js +184 -184
  30. package/dist/core/MideaPacketBuilder.d.ts +10 -10
  31. package/dist/core/MideaPacketBuilder.js +60 -60
  32. package/dist/core/MideaSecurity.d.ts +63 -63
  33. package/dist/core/MideaSecurity.js +242 -242
  34. package/dist/core/MideaUtils.d.ts +32 -32
  35. package/dist/core/MideaUtils.js +181 -181
  36. package/dist/devices/DeviceFactory.d.ts +11 -11
  37. package/dist/devices/DeviceFactory.js +30 -30
  38. package/dist/devices/a1/MideaA1Device.d.ts +76 -76
  39. package/dist/devices/a1/MideaA1Device.js +136 -136
  40. package/dist/devices/a1/MideaA1Message.d.ts +40 -40
  41. package/dist/devices/a1/MideaA1Message.js +198 -198
  42. package/dist/devices/ac/MideaACDevice.d.ts +100 -98
  43. package/dist/devices/ac/MideaACDevice.d.ts.map +1 -1
  44. package/dist/devices/ac/MideaACDevice.js +370 -357
  45. package/dist/devices/ac/MideaACDevice.js.map +1 -1
  46. package/dist/devices/ac/MideaACMessage.d.ts +92 -92
  47. package/dist/devices/ac/MideaACMessage.js +589 -589
  48. package/dist/devices/e2/MideaE2Device.d.ts +44 -44
  49. package/dist/devices/e2/MideaE2Device.js +119 -119
  50. package/dist/devices/e2/MideaE2Message.d.ts +33 -33
  51. package/dist/devices/e2/MideaE2Message.js +132 -132
  52. package/dist/devices/e3/MideaE3Device.d.ts +43 -43
  53. package/dist/devices/e3/MideaE3Device.js +125 -125
  54. package/dist/devices/e3/MideaE3Message.d.ts +51 -51
  55. package/dist/devices/e3/MideaE3Message.js +136 -136
  56. package/dist/devices/fa/MideaFADevice.d.ts +36 -36
  57. package/dist/devices/fa/MideaFADevice.js +92 -92
  58. package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
  59. package/dist/devices/fa/MideaFAMessage.js +98 -98
  60. package/dist/index.d.ts +6 -6
  61. package/dist/index.js +6 -6
  62. package/dist/platform.d.ts +60 -60
  63. package/dist/platform.js +213 -213
  64. package/dist/platformUtils.d.ts +97 -96
  65. package/dist/platformUtils.d.ts.map +1 -1
  66. package/dist/platformUtils.js +95 -94
  67. package/dist/platformUtils.js.map +1 -1
  68. package/dist/settings.d.ts +8 -8
  69. package/dist/settings.js +11 -11
  70. package/docs/ac.md +2 -0
  71. package/docs/fa.md +3 -0
  72. package/package.json +1 -1
@@ -1,217 +1,217 @@
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
- class GasWaterHeaterAccessory extends BaseAccessory_1.default {
8
- constructor(platform, accessory, device, configDev) {
9
- var _a, _b, _c, _d, _e;
10
- super(platform, accessory, device, configDev);
11
- this.device = device;
12
- this.configDev = configDev;
13
- this.service =
14
- this.accessory.getService(this.platform.Service.HeaterCooler) || this.accessory.addService(this.platform.Service.HeaterCooler);
15
- this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
16
- this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
17
- this.service
18
- .getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
19
- .onGet(this.getCurrentHeaterCoolerState.bind(this));
20
- this.service
21
- .getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
22
- .onGet(this.getTargetHeaterCoolerState.bind(this))
23
- .onSet(this.setTargetHeaterCoolerState.bind(this))
24
- .setProps({
25
- validValues: [
26
- this.platform.Characteristic.TargetHeatingCoolingState.OFF,
27
- this.platform.Characteristic.TargetHeaterCoolerState.HEAT,
28
- ],
29
- });
30
- this.service.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getCurrentTemperature.bind(this));
31
- this.service
32
- .getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
33
- .onGet(this.getTargetTemperature.bind(this))
34
- .onSet(this.setTargetTemperature.bind(this))
35
- .setProps({
36
- minValue: this.configDev.E3_options.minTemp,
37
- maxValue: this.configDev.E3_options.maxTemp,
38
- minStep: this.configDev.E3_options.tempStep,
39
- });
40
- // Burning state sensor
41
- this.burningStateService = this.accessory.getServiceById(this.platform.Service.MotionSensor, 'BurningState');
42
- if (this.configDev.E3_options.burningStateSensor) {
43
- (_a = this.burningStateService) !== null && _a !== void 0 ? _a : (this.burningStateService = this.accessory.addService(this.platform.Service.MotionSensor, `${this.device.name} Burning State`, 'BurningState'));
44
- this.burningStateService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Burning State`);
45
- this.burningStateService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Burning State`);
46
- this.burningStateService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getBurningState.bind(this));
47
- }
48
- else if (this.burningStateService) {
49
- this.accessory.removeService(this.burningStateService);
50
- }
51
- // Protection sensor
52
- this.protectionService = this.accessory.getServiceById(this.platform.Service.MotionSensor, 'Protection');
53
- if (this.configDev.E3_options.protectionSensor) {
54
- (_b = this.protectionService) !== null && _b !== void 0 ? _b : (this.protectionService = this.accessory.addService(this.platform.Service.MotionSensor, `${this.device.name} Protection`, 'Protection'));
55
- this.protectionService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Protection`);
56
- this.protectionService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Protection`);
57
- this.protectionService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getProtection.bind(this));
58
- }
59
- else if (this.protectionService) {
60
- this.accessory.removeService(this.protectionService);
61
- }
62
- // Zero Cold Water switch
63
- this.zeroColdWaterService = this.accessory.getServiceById(this.platform.Service.Switch, 'ZeroColdWater');
64
- if (this.configDev.E3_options.zeroColdWaterSwitch) {
65
- (_c = this.zeroColdWaterService) !== null && _c !== void 0 ? _c : (this.zeroColdWaterService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Zero Cold Water`, 'ZeroColdWater'));
66
- this.zeroColdWaterService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Zero Cold Water`);
67
- this.zeroColdWaterService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Zero Cold Water`);
68
- this.zeroColdWaterService
69
- .getCharacteristic(this.platform.Characteristic.On)
70
- .onGet(this.getZeroColdWater.bind(this))
71
- .onSet(this.setZeroColdWater.bind(this));
72
- }
73
- else if (this.zeroColdWaterService) {
74
- this.accessory.removeService(this.zeroColdWaterService);
75
- }
76
- // Zero Cold Pulse switch
77
- this.zeroColdPulseService = this.accessory.getServiceById(this.platform.Service.Switch, 'ZeroColdPulse');
78
- if (this.configDev.E3_options.zeroColdPulseSwitch) {
79
- (_d = this.zeroColdPulseService) !== null && _d !== void 0 ? _d : (this.zeroColdPulseService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Zero Cold Pulse`, 'ZeroColdPulse'));
80
- this.zeroColdPulseService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Zero Cold Pulse`);
81
- this.zeroColdPulseService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Zero Cold Pulse`);
82
- this.zeroColdPulseService
83
- .getCharacteristic(this.platform.Characteristic.On)
84
- .onGet(this.getZeroColdPulse.bind(this))
85
- .onSet(this.setZeroColdPulse.bind(this));
86
- }
87
- else if (this.zeroColdPulseService) {
88
- this.accessory.removeService(this.zeroColdPulseService);
89
- }
90
- // Smart Volume switch
91
- this.smartVolumeService = this.accessory.getServiceById(this.platform.Service.Switch, 'SmartVolume');
92
- if (this.configDev.E3_options.smartVolumeSwitch) {
93
- (_e = this.smartVolumeService) !== null && _e !== void 0 ? _e : (this.smartVolumeService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Smart Volume`, 'SmartVolume'));
94
- this.smartVolumeService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Smart Volume`);
95
- this.smartVolumeService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Smart Volume`);
96
- this.smartVolumeService
97
- .getCharacteristic(this.platform.Characteristic.On)
98
- .onGet(this.getSmartVolume.bind(this))
99
- .onSet(this.setSmartVolume.bind(this));
100
- }
101
- else if (this.smartVolumeService) {
102
- this.accessory.removeService(this.smartVolumeService);
103
- }
104
- }
105
- /*********************************************************************
106
- * Callback function called by MideaDevice whenever there is a change to
107
- * any attribute value.
108
- */
109
- async updateCharacteristics(attributes) {
110
- var _a, _b, _c, _d, _e;
111
- for (const [k, v] of Object.entries(attributes)) {
112
- this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
113
- let updateState = false;
114
- switch (k.toLowerCase()) {
115
- case 'power':
116
- this.service.updateCharacteristic(this.platform.Characteristic.Active, v ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
117
- updateState = true;
118
- break;
119
- case 'burning_state':
120
- (_a = this.burningStateService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.MotionDetected, v);
121
- break;
122
- case 'zero_cold_water':
123
- (_b = this.zeroColdWaterService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.On, v);
124
- break;
125
- case 'protection':
126
- (_c = this.protectionService) === null || _c === void 0 ? void 0 : _c.updateCharacteristic(this.platform.Characteristic.MotionDetected, v);
127
- break;
128
- case 'zero_cold_pulse':
129
- (_d = this.zeroColdPulseService) === null || _d === void 0 ? void 0 : _d.updateCharacteristic(this.platform.Characteristic.On, v);
130
- break;
131
- case 'smart_volume':
132
- (_e = this.smartVolumeService) === null || _e === void 0 ? void 0 : _e.updateCharacteristic(this.platform.Characteristic.On, v);
133
- break;
134
- case 'current_temperature':
135
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, v);
136
- updateState = true;
137
- break;
138
- case 'target_temperature':
139
- this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, v);
140
- updateState = true;
141
- break;
142
- default:
143
- this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
144
- }
145
- if (updateState) {
146
- this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.getTargetHeaterCoolerState());
147
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.getCurrentHeaterCoolerState());
148
- }
149
- }
150
- }
151
- /*********************************************************************
152
- * Callback functions for each Homebridge/HomeKit service
153
- *
154
- */
155
- getActive() {
156
- return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
157
- }
158
- async setActive(value) {
159
- await this.device.set_attribute({ POWER: !!value });
160
- }
161
- getCurrentHeaterCoolerState() {
162
- if (this.device.attributes.POWER) {
163
- return this.device.attributes.HEATING
164
- ? this.platform.Characteristic.CurrentHeaterCoolerState.HEATING
165
- : this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
166
- }
167
- return this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
168
- }
169
- getTargetHeaterCoolerState() {
170
- return this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
171
- }
172
- async setTargetHeaterCoolerState(value) {
173
- if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
174
- await this.device.set_attribute({ POWER: true });
175
- }
176
- else {
177
- await this.device.set_attribute({ POWER: false });
178
- }
179
- }
180
- getCurrentTemperature() {
181
- var _a;
182
- return (_a = this.device.attributes.CURRENT_TEMPERATURE) !== null && _a !== void 0 ? _a : this.configDev.E3_options.minTemp;
183
- }
184
- getTargetTemperature() {
185
- return Math.max(this.configDev.E3_options.minTemp, Math.min(this.configDev.E3_options.maxTemp, this.device.attributes.TARGET_TEMPERATURE));
186
- }
187
- async setTargetTemperature(value) {
188
- value = Math.max(this.configDev.E3_options.minTemp, Math.min(this.configDev.E3_options.maxTemp, value));
189
- await this.device.set_attribute({ TARGET_TEMPERATURE: value });
190
- }
191
- getBurningState() {
192
- return this.device.attributes.BURNING_STATE;
193
- }
194
- getProtection() {
195
- return this.device.attributes.PROTECTION;
196
- }
197
- getZeroColdWater() {
198
- return this.device.attributes.ZERO_COLD_WATER;
199
- }
200
- async setZeroColdWater(value) {
201
- await this.device.set_attribute({ ZERO_COLD_WATER: !!value });
202
- }
203
- getZeroColdPulse() {
204
- return this.device.attributes.ZERO_COLD_PULSE;
205
- }
206
- async setZeroColdPulse(value) {
207
- await this.device.set_attribute({ ZERO_COLD_PULSE: !!value });
208
- }
209
- getSmartVolume() {
210
- return this.device.attributes.SMART_VOLUME;
211
- }
212
- async setSmartVolume(value) {
213
- await this.device.set_attribute({ SMART_VOLUME: !!value });
214
- }
215
- }
216
- exports.default = GasWaterHeaterAccessory;
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
+ class GasWaterHeaterAccessory extends BaseAccessory_1.default {
8
+ constructor(platform, accessory, device, configDev) {
9
+ var _a, _b, _c, _d, _e;
10
+ super(platform, accessory, device, configDev);
11
+ this.device = device;
12
+ this.configDev = configDev;
13
+ this.service =
14
+ this.accessory.getService(this.platform.Service.HeaterCooler) || this.accessory.addService(this.platform.Service.HeaterCooler);
15
+ this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
16
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
17
+ this.service
18
+ .getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
19
+ .onGet(this.getCurrentHeaterCoolerState.bind(this));
20
+ this.service
21
+ .getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
22
+ .onGet(this.getTargetHeaterCoolerState.bind(this))
23
+ .onSet(this.setTargetHeaterCoolerState.bind(this))
24
+ .setProps({
25
+ validValues: [
26
+ this.platform.Characteristic.TargetHeatingCoolingState.OFF,
27
+ this.platform.Characteristic.TargetHeaterCoolerState.HEAT,
28
+ ],
29
+ });
30
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getCurrentTemperature.bind(this));
31
+ this.service
32
+ .getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
33
+ .onGet(this.getTargetTemperature.bind(this))
34
+ .onSet(this.setTargetTemperature.bind(this))
35
+ .setProps({
36
+ minValue: this.configDev.E3_options.minTemp,
37
+ maxValue: this.configDev.E3_options.maxTemp,
38
+ minStep: this.configDev.E3_options.tempStep,
39
+ });
40
+ // Burning state sensor
41
+ this.burningStateService = this.accessory.getServiceById(this.platform.Service.MotionSensor, 'BurningState');
42
+ if (this.configDev.E3_options.burningStateSensor) {
43
+ (_a = this.burningStateService) !== null && _a !== void 0 ? _a : (this.burningStateService = this.accessory.addService(this.platform.Service.MotionSensor, `${this.device.name} Burning State`, 'BurningState'));
44
+ this.burningStateService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Burning State`);
45
+ this.burningStateService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Burning State`);
46
+ this.burningStateService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getBurningState.bind(this));
47
+ }
48
+ else if (this.burningStateService) {
49
+ this.accessory.removeService(this.burningStateService);
50
+ }
51
+ // Protection sensor
52
+ this.protectionService = this.accessory.getServiceById(this.platform.Service.MotionSensor, 'Protection');
53
+ if (this.configDev.E3_options.protectionSensor) {
54
+ (_b = this.protectionService) !== null && _b !== void 0 ? _b : (this.protectionService = this.accessory.addService(this.platform.Service.MotionSensor, `${this.device.name} Protection`, 'Protection'));
55
+ this.protectionService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Protection`);
56
+ this.protectionService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Protection`);
57
+ this.protectionService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getProtection.bind(this));
58
+ }
59
+ else if (this.protectionService) {
60
+ this.accessory.removeService(this.protectionService);
61
+ }
62
+ // Zero Cold Water switch
63
+ this.zeroColdWaterService = this.accessory.getServiceById(this.platform.Service.Switch, 'ZeroColdWater');
64
+ if (this.configDev.E3_options.zeroColdWaterSwitch) {
65
+ (_c = this.zeroColdWaterService) !== null && _c !== void 0 ? _c : (this.zeroColdWaterService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Zero Cold Water`, 'ZeroColdWater'));
66
+ this.zeroColdWaterService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Zero Cold Water`);
67
+ this.zeroColdWaterService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Zero Cold Water`);
68
+ this.zeroColdWaterService
69
+ .getCharacteristic(this.platform.Characteristic.On)
70
+ .onGet(this.getZeroColdWater.bind(this))
71
+ .onSet(this.setZeroColdWater.bind(this));
72
+ }
73
+ else if (this.zeroColdWaterService) {
74
+ this.accessory.removeService(this.zeroColdWaterService);
75
+ }
76
+ // Zero Cold Pulse switch
77
+ this.zeroColdPulseService = this.accessory.getServiceById(this.platform.Service.Switch, 'ZeroColdPulse');
78
+ if (this.configDev.E3_options.zeroColdPulseSwitch) {
79
+ (_d = this.zeroColdPulseService) !== null && _d !== void 0 ? _d : (this.zeroColdPulseService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Zero Cold Pulse`, 'ZeroColdPulse'));
80
+ this.zeroColdPulseService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Zero Cold Pulse`);
81
+ this.zeroColdPulseService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Zero Cold Pulse`);
82
+ this.zeroColdPulseService
83
+ .getCharacteristic(this.platform.Characteristic.On)
84
+ .onGet(this.getZeroColdPulse.bind(this))
85
+ .onSet(this.setZeroColdPulse.bind(this));
86
+ }
87
+ else if (this.zeroColdPulseService) {
88
+ this.accessory.removeService(this.zeroColdPulseService);
89
+ }
90
+ // Smart Volume switch
91
+ this.smartVolumeService = this.accessory.getServiceById(this.platform.Service.Switch, 'SmartVolume');
92
+ if (this.configDev.E3_options.smartVolumeSwitch) {
93
+ (_e = this.smartVolumeService) !== null && _e !== void 0 ? _e : (this.smartVolumeService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Smart Volume`, 'SmartVolume'));
94
+ this.smartVolumeService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Smart Volume`);
95
+ this.smartVolumeService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Smart Volume`);
96
+ this.smartVolumeService
97
+ .getCharacteristic(this.platform.Characteristic.On)
98
+ .onGet(this.getSmartVolume.bind(this))
99
+ .onSet(this.setSmartVolume.bind(this));
100
+ }
101
+ else if (this.smartVolumeService) {
102
+ this.accessory.removeService(this.smartVolumeService);
103
+ }
104
+ }
105
+ /*********************************************************************
106
+ * Callback function called by MideaDevice whenever there is a change to
107
+ * any attribute value.
108
+ */
109
+ async updateCharacteristics(attributes) {
110
+ var _a, _b, _c, _d, _e;
111
+ for (const [k, v] of Object.entries(attributes)) {
112
+ this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
113
+ let updateState = false;
114
+ switch (k.toLowerCase()) {
115
+ case 'power':
116
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, v ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
117
+ updateState = true;
118
+ break;
119
+ case 'burning_state':
120
+ (_a = this.burningStateService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.MotionDetected, v);
121
+ break;
122
+ case 'zero_cold_water':
123
+ (_b = this.zeroColdWaterService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.On, v);
124
+ break;
125
+ case 'protection':
126
+ (_c = this.protectionService) === null || _c === void 0 ? void 0 : _c.updateCharacteristic(this.platform.Characteristic.MotionDetected, v);
127
+ break;
128
+ case 'zero_cold_pulse':
129
+ (_d = this.zeroColdPulseService) === null || _d === void 0 ? void 0 : _d.updateCharacteristic(this.platform.Characteristic.On, v);
130
+ break;
131
+ case 'smart_volume':
132
+ (_e = this.smartVolumeService) === null || _e === void 0 ? void 0 : _e.updateCharacteristic(this.platform.Characteristic.On, v);
133
+ break;
134
+ case 'current_temperature':
135
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, v);
136
+ updateState = true;
137
+ break;
138
+ case 'target_temperature':
139
+ this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, v);
140
+ updateState = true;
141
+ break;
142
+ default:
143
+ this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
144
+ }
145
+ if (updateState) {
146
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.getTargetHeaterCoolerState());
147
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.getCurrentHeaterCoolerState());
148
+ }
149
+ }
150
+ }
151
+ /*********************************************************************
152
+ * Callback functions for each Homebridge/HomeKit service
153
+ *
154
+ */
155
+ getActive() {
156
+ return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
157
+ }
158
+ async setActive(value) {
159
+ await this.device.set_attribute({ POWER: !!value });
160
+ }
161
+ getCurrentHeaterCoolerState() {
162
+ if (this.device.attributes.POWER) {
163
+ return this.device.attributes.HEATING
164
+ ? this.platform.Characteristic.CurrentHeaterCoolerState.HEATING
165
+ : this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
166
+ }
167
+ return this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
168
+ }
169
+ getTargetHeaterCoolerState() {
170
+ return this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
171
+ }
172
+ async setTargetHeaterCoolerState(value) {
173
+ if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
174
+ await this.device.set_attribute({ POWER: true });
175
+ }
176
+ else {
177
+ await this.device.set_attribute({ POWER: false });
178
+ }
179
+ }
180
+ getCurrentTemperature() {
181
+ var _a;
182
+ return (_a = this.device.attributes.CURRENT_TEMPERATURE) !== null && _a !== void 0 ? _a : this.configDev.E3_options.minTemp;
183
+ }
184
+ getTargetTemperature() {
185
+ return Math.max(this.configDev.E3_options.minTemp, Math.min(this.configDev.E3_options.maxTemp, this.device.attributes.TARGET_TEMPERATURE));
186
+ }
187
+ async setTargetTemperature(value) {
188
+ value = Math.max(this.configDev.E3_options.minTemp, Math.min(this.configDev.E3_options.maxTemp, value));
189
+ await this.device.set_attribute({ TARGET_TEMPERATURE: value });
190
+ }
191
+ getBurningState() {
192
+ return this.device.attributes.BURNING_STATE;
193
+ }
194
+ getProtection() {
195
+ return this.device.attributes.PROTECTION;
196
+ }
197
+ getZeroColdWater() {
198
+ return this.device.attributes.ZERO_COLD_WATER;
199
+ }
200
+ async setZeroColdWater(value) {
201
+ await this.device.set_attribute({ ZERO_COLD_WATER: !!value });
202
+ }
203
+ getZeroColdPulse() {
204
+ return this.device.attributes.ZERO_COLD_PULSE;
205
+ }
206
+ async setZeroColdPulse(value) {
207
+ await this.device.set_attribute({ ZERO_COLD_PULSE: !!value });
208
+ }
209
+ getSmartVolume() {
210
+ return this.device.attributes.SMART_VOLUME;
211
+ }
212
+ async setSmartVolume(value) {
213
+ await this.device.set_attribute({ SMART_VOLUME: !!value });
214
+ }
215
+ }
216
+ exports.default = GasWaterHeaterAccessory;
217
217
  //# sourceMappingURL=GasWaterHeaterAccessory.js.map
@@ -1,36 +1,36 @@
1
- /// <reference types="node" />
2
- import { Semaphore } from 'semaphore-promise';
3
- import { Endianness } from './MideaConstants';
4
- import { CloudSecurity } from './MideaSecurity';
5
- declare abstract class CloudBase<S extends CloudSecurity> {
6
- protected readonly account: string;
7
- protected readonly password: string;
8
- protected readonly security: S;
9
- protected readonly CLIENT_TYPE = 1;
10
- protected readonly FORMAT = 2;
11
- protected readonly LANGUAGE = "en_US";
12
- protected abstract readonly APP_ID: string;
13
- protected abstract readonly API_URL: string;
14
- protected readonly DEVICE_ID: string;
15
- protected access_token?: string;
16
- protected uid?: string;
17
- protected key?: string;
18
- protected semaphore: Semaphore;
19
- loggedIn: boolean;
20
- constructor(account: string, password: string, security: S);
21
- protected timestamp(): string;
22
- abstract buildRequestData(): {
23
- [key: string]: string | number;
24
- };
25
- abstract apiRequest(endpoint: string, data: {
26
- [key: string]: any;
27
- }): Promise<any>;
28
- getLoginId(): Promise<any>;
29
- abstract login(): Promise<void>;
30
- getTokenKey(device_id: number, endianess: Endianness): Promise<[Buffer, Buffer]>;
31
- }
32
- export default class CloudFactory {
33
- static createCloud(account: string, password: string, cloud: string): CloudBase<CloudSecurity>;
34
- }
35
- export {};
1
+ /// <reference types="node" />
2
+ import { Semaphore } from 'semaphore-promise';
3
+ import { Endianness } from './MideaConstants';
4
+ import { CloudSecurity } from './MideaSecurity';
5
+ declare abstract class CloudBase<S extends CloudSecurity> {
6
+ protected readonly account: string;
7
+ protected readonly password: string;
8
+ protected readonly security: S;
9
+ protected readonly CLIENT_TYPE = 1;
10
+ protected readonly FORMAT = 2;
11
+ protected readonly LANGUAGE = "en_US";
12
+ protected abstract readonly APP_ID: string;
13
+ protected abstract readonly API_URL: string;
14
+ protected readonly DEVICE_ID: string;
15
+ protected access_token?: string;
16
+ protected uid?: string;
17
+ protected key?: string;
18
+ protected semaphore: Semaphore;
19
+ loggedIn: boolean;
20
+ constructor(account: string, password: string, security: S);
21
+ protected timestamp(): string;
22
+ abstract buildRequestData(): {
23
+ [key: string]: string | number;
24
+ };
25
+ abstract apiRequest(endpoint: string, data: {
26
+ [key: string]: any;
27
+ }): Promise<any>;
28
+ getLoginId(): Promise<any>;
29
+ abstract login(): Promise<void>;
30
+ getTokenKey(device_id: number, endianess: Endianness): Promise<[Buffer, Buffer]>;
31
+ }
32
+ export default class CloudFactory {
33
+ static createCloud(account: string, password: string, cloud: string): CloudBase<CloudSecurity>;
34
+ }
35
+ export {};
36
36
  //# sourceMappingURL=MideaCloud.d.ts.map