homebridge-midea-platform 0.4.13 → 1.0.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 (73) hide show
  1. package/.gitattributes +3 -0
  2. package/.husky/pre-commit +2 -1
  3. package/.prettierrc +1 -0
  4. package/README.md +14 -156
  5. package/config.schema.json +162 -1
  6. package/dist/accessory/AccessoryFactory.d.ts +3 -1
  7. package/dist/accessory/AccessoryFactory.d.ts.map +1 -1
  8. package/dist/accessory/AccessoryFactory.js +6 -0
  9. package/dist/accessory/AccessoryFactory.js.map +1 -1
  10. package/dist/accessory/AirConditionerAccessory.d.ts +9 -0
  11. package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
  12. package/dist/accessory/AirConditionerAccessory.js +88 -12
  13. package/dist/accessory/AirConditionerAccessory.js.map +1 -1
  14. package/dist/accessory/DehumidifierAccessory.d.ts +5 -0
  15. package/dist/accessory/DehumidifierAccessory.d.ts.map +1 -1
  16. package/dist/accessory/DehumidifierAccessory.js +42 -2
  17. package/dist/accessory/DehumidifierAccessory.js.map +1 -1
  18. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +45 -0
  19. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts.map +1 -0
  20. package/dist/accessory/ElectricWaterHeaterAccessory.js +179 -0
  21. package/dist/accessory/ElectricWaterHeaterAccessory.js.map +1 -0
  22. package/dist/accessory/GasWaterHeaterAccessory.d.ts +52 -0
  23. package/dist/accessory/GasWaterHeaterAccessory.d.ts.map +1 -0
  24. package/dist/accessory/GasWaterHeaterAccessory.js +219 -0
  25. package/dist/accessory/GasWaterHeaterAccessory.js.map +1 -0
  26. package/dist/core/MideaCloud.d.ts +14 -14
  27. package/dist/core/MideaCloud.d.ts.map +1 -1
  28. package/dist/core/MideaCloud.js +150 -92
  29. package/dist/core/MideaCloud.js.map +1 -1
  30. package/dist/core/MideaConstants.d.ts +7 -2
  31. package/dist/core/MideaConstants.d.ts.map +1 -1
  32. package/dist/core/MideaConstants.js +8 -1
  33. package/dist/core/MideaConstants.js.map +1 -1
  34. package/dist/core/MideaPacketBuilder.d.ts.map +1 -1
  35. package/dist/core/MideaPacketBuilder.js +3 -2
  36. package/dist/core/MideaPacketBuilder.js.map +1 -1
  37. package/dist/core/MideaSecurity.d.ts +35 -11
  38. package/dist/core/MideaSecurity.d.ts.map +1 -1
  39. package/dist/core/MideaSecurity.js +75 -28
  40. package/dist/core/MideaSecurity.js.map +1 -1
  41. package/dist/core/MideaUtils.js +2 -1
  42. package/dist/core/MideaUtils.js.map +1 -1
  43. package/dist/devices/DeviceFactory.d.ts +4 -2
  44. package/dist/devices/DeviceFactory.d.ts.map +1 -1
  45. package/dist/devices/DeviceFactory.js +6 -0
  46. package/dist/devices/DeviceFactory.js.map +1 -1
  47. package/dist/devices/e2/MideaE2Device.d.ts +45 -0
  48. package/dist/devices/e2/MideaE2Device.d.ts.map +1 -0
  49. package/dist/devices/e2/MideaE2Device.js +120 -0
  50. package/dist/devices/e2/MideaE2Device.js.map +1 -0
  51. package/dist/devices/e2/MideaE2Message.d.ts +34 -0
  52. package/dist/devices/e2/MideaE2Message.d.ts.map +1 -0
  53. package/dist/devices/e2/MideaE2Message.js +133 -0
  54. package/dist/devices/e2/MideaE2Message.js.map +1 -0
  55. package/dist/devices/e3/MideaE3Device.d.ts +44 -0
  56. package/dist/devices/e3/MideaE3Device.d.ts.map +1 -0
  57. package/dist/devices/e3/MideaE3Device.js +126 -0
  58. package/dist/devices/e3/MideaE3Device.js.map +1 -0
  59. package/dist/devices/e3/MideaE3Message.d.ts +52 -0
  60. package/dist/devices/e3/MideaE3Message.d.ts.map +1 -0
  61. package/dist/devices/e3/MideaE3Message.js +137 -0
  62. package/dist/devices/e3/MideaE3Message.js.map +1 -0
  63. package/dist/platformUtils.d.ts +26 -0
  64. package/dist/platformUtils.d.ts.map +1 -1
  65. package/dist/platformUtils.js +24 -0
  66. package/dist/platformUtils.js.map +1 -1
  67. package/docs/a1.md +20 -0
  68. package/docs/ac.md +41 -0
  69. package/docs/e2.md +21 -0
  70. package/docs/e3.md +27 -0
  71. package/homebridge-ui/public/index.html +78 -25
  72. package/homebridge-ui/server.js +23 -4
  73. package/package.json +8 -1
@@ -0,0 +1,179 @@
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 ElectricWaterHeaterAccessory extends BaseAccessory_1.default {
8
+ constructor(platform, accessory, device, configDev) {
9
+ var _a, _b;
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.E2_options.minTemp,
37
+ maxValue: this.configDev.E2_options.maxTemp,
38
+ minStep: this.configDev.E2_options.tempStep,
39
+ });
40
+ this.variableHeatingService = this.accessory.getServiceById(this.platform.Service.Switch, 'VariableHeating');
41
+ if (this.configDev.E2_options.variableHeatingSwitch) {
42
+ (_a = this.variableHeatingService) !== null && _a !== void 0 ? _a : (this.variableHeatingService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Variable Heating`, 'VariableHeating'));
43
+ this.variableHeatingService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Variable Heating`);
44
+ this.variableHeatingService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Variable Heating`);
45
+ this.variableHeatingService
46
+ .getCharacteristic(this.platform.Characteristic.On)
47
+ .onGet(this.getVariableHeating.bind(this))
48
+ .onSet(this.setVariableHeating.bind(this));
49
+ }
50
+ else if (this.variableHeatingService) {
51
+ this.accessory.removeService(this.variableHeatingService);
52
+ }
53
+ this.wholeTankHeatingService = this.accessory.getServiceById(this.platform.Service.Switch, 'WholeTankHeating');
54
+ if (this.configDev.E2_options.wholeTankHeatingSwitch) {
55
+ (_b = this.wholeTankHeatingService) !== null && _b !== void 0 ? _b : (this.wholeTankHeatingService = this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Whole Tank Heating`, 'WholeTankHeating'));
56
+ this.wholeTankHeatingService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Whole Tank Heating`);
57
+ this.wholeTankHeatingService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Whole Tank Heating`);
58
+ this.wholeTankHeatingService
59
+ .getCharacteristic(this.platform.Characteristic.On)
60
+ .onGet(this.getWholeTankHeating.bind(this))
61
+ .onSet(this.setWholeTankHeating.bind(this));
62
+ }
63
+ else if (this.wholeTankHeatingService) {
64
+ this.accessory.removeService(this.wholeTankHeatingService);
65
+ }
66
+ this.device.on('update', this.updateCharacteristics.bind(this));
67
+ this.device.refresh_status();
68
+ }
69
+ /*********************************************************************
70
+ * Callback function called by MideaDevice whenever there is a change to
71
+ * any attribute value.
72
+ */
73
+ async updateCharacteristics(attributes) {
74
+ var _a, _b;
75
+ for (const [k, v] of Object.entries(attributes)) {
76
+ this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
77
+ let updateState = false;
78
+ switch (k.toLowerCase()) {
79
+ case 'power':
80
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, v ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
81
+ updateState = true;
82
+ break;
83
+ case 'heating':
84
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, v ? this.platform.Characteristic.CurrentHeaterCoolerState.HEATING : this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
85
+ updateState = true;
86
+ break;
87
+ // case 'keep_warm':
88
+ // this.platform.log.debug(`[${this.device.name}] Keep warm: ${v}`);
89
+ // break;
90
+ // case 'protection':
91
+ // this.platform.log.debug(`[${this.device.name}] Protection: ${v}`);
92
+ // break;
93
+ case 'current_temperature':
94
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, v);
95
+ updateState = true;
96
+ break;
97
+ case 'target_temperature':
98
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetTemperature, v);
99
+ updateState = true;
100
+ break;
101
+ case 'whole_tank_heating':
102
+ (_a = this.wholeTankHeatingService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.On, v);
103
+ break;
104
+ case 'variable_heating':
105
+ (_b = this.variableHeatingService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.On, v);
106
+ break;
107
+ // case 'heating_time_remaining':
108
+ // this.platform.log.debug(`[${this.device.name}] Heating time remaining: ${v}`);
109
+ // break;
110
+ // case 'water_consumption':
111
+ // this.platform.log.debug(`[${this.device.name}] Water consumption: ${v}`);
112
+ // break;
113
+ // case 'heating_power':
114
+ // this.platform.log.debug(`[${this.device.name}] Heating power: ${v}`);
115
+ // break;
116
+ default:
117
+ this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
118
+ }
119
+ if (updateState) {
120
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.getTargetHeaterCoolerState());
121
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.getCurrentHeaterCoolerState());
122
+ }
123
+ }
124
+ }
125
+ /*********************************************************************
126
+ * Callback functions for each Homebridge/HomeKit service
127
+ *
128
+ */
129
+ getActive() {
130
+ return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
131
+ }
132
+ async setActive(value) {
133
+ await this.device.set_attribute({ POWER: !!value });
134
+ }
135
+ getCurrentHeaterCoolerState() {
136
+ if (this.device.attributes.POWER) {
137
+ return this.device.attributes.HEATING
138
+ ? this.platform.Characteristic.CurrentHeaterCoolerState.HEATING
139
+ : this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
140
+ }
141
+ return this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
142
+ }
143
+ getTargetHeaterCoolerState() {
144
+ return this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
145
+ }
146
+ async setTargetHeaterCoolerState(value) {
147
+ if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
148
+ await this.device.set_attribute({ POWER: true });
149
+ }
150
+ else {
151
+ await this.device.set_attribute({ POWER: false });
152
+ }
153
+ }
154
+ getCurrentTemperature() {
155
+ var _a;
156
+ return (_a = this.device.attributes.CURRENT_TEMPERATURE) !== null && _a !== void 0 ? _a : this.configDev.E2_options.minTemp;
157
+ }
158
+ getTargetTemperature() {
159
+ return Math.max(this.configDev.E2_options.minTemp, Math.min(this.configDev.E2_options.maxTemp, this.device.attributes.TARGET_TEMPERATURE));
160
+ }
161
+ async setTargetTemperature(value) {
162
+ value = Math.max(this.configDev.E2_options.minTemp, Math.min(this.configDev.E2_options.maxTemp, value));
163
+ await this.device.set_attribute({ TARGET_TEMPERATURE: value });
164
+ }
165
+ getVariableHeating() {
166
+ return this.device.attributes.VARIABLE_HEATING;
167
+ }
168
+ async setVariableHeating(value) {
169
+ await this.device.set_attribute({ VARIABLE_HEATING: !!value });
170
+ }
171
+ getWholeTankHeating() {
172
+ return this.device.attributes.WHOLE_TANK_HEATING;
173
+ }
174
+ async setWholeTankHeating(value) {
175
+ await this.device.set_attribute({ WHOLE_TANK_HEATING: !!value });
176
+ }
177
+ }
178
+ exports.default = ElectricWaterHeaterAccessory;
179
+ //# sourceMappingURL=ElectricWaterHeaterAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElectricWaterHeaterAccessory.js","sourceRoot":"","sources":["../../src/accessory/ElectricWaterHeaterAccessory.ts"],"names":[],"mappings":";;;;;AAYA,oEAA4C;AAI5C,MAAqB,4BAA6B,SAAQ,uBAA4B;IAMpF,YACE,QAAuB,EACvB,SAAyB,EACN,MAAqB,EACrB,SAAuB;;QAE1C,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAH3B,WAAM,GAAN,MAAM,CAAe;QACrB,cAAS,GAAT,SAAS,CAAc;QAI1C,IAAI,CAAC,OAAO;YACV,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAEjI,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEpF,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,KAAK,C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+CAoNC"}
@@ -0,0 +1,52 @@
1
+ /***********************************************************************
2
+ * Midea Platform Gas Water Heater Accessory class
3
+ *
4
+ * Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
5
+ *
6
+ * Based on https://github.com/homebridge/homebridge-plugin-template
7
+ *
8
+ * An instance of this class is created for each accessory the platform registers.
9
+ *
10
+ */
11
+ import { CharacteristicValue } from 'homebridge';
12
+ import MideaE3Device from '../devices/e3/MideaE3Device';
13
+ import BaseAccessory from './BaseAccessory';
14
+ import { MideaAccessory, MideaPlatform } from '../platform';
15
+ import { DeviceConfig } from '../platformUtils';
16
+ export default class GasWaterHeaterAccessory extends BaseAccessory<MideaE3Device> {
17
+ protected readonly device: MideaE3Device;
18
+ protected readonly configDev: DeviceConfig;
19
+ private service;
20
+ private burningStateService?;
21
+ private protectionService?;
22
+ private zeroColdWaterService?;
23
+ private zeroColdPulseService?;
24
+ private smartVolumeService?;
25
+ constructor(platform: MideaPlatform, accessory: MideaAccessory, device: MideaE3Device, configDev: DeviceConfig);
26
+ /*********************************************************************
27
+ * Callback function called by MideaDevice whenever there is a change to
28
+ * any attribute value.
29
+ */
30
+ private updateCharacteristics;
31
+ /*********************************************************************
32
+ * Callback functions for each Homebridge/HomeKit service
33
+ *
34
+ */
35
+ getActive(): CharacteristicValue;
36
+ setActive(value: CharacteristicValue): Promise<void>;
37
+ getCurrentHeaterCoolerState(): CharacteristicValue;
38
+ getTargetHeaterCoolerState(): CharacteristicValue;
39
+ setTargetHeaterCoolerState(value: CharacteristicValue): Promise<void>;
40
+ getCurrentTemperature(): CharacteristicValue;
41
+ getTargetTemperature(): CharacteristicValue;
42
+ setTargetTemperature(value: CharacteristicValue): Promise<void>;
43
+ getBurningState(): CharacteristicValue;
44
+ getProtection(): CharacteristicValue;
45
+ getZeroColdWater(): CharacteristicValue;
46
+ setZeroColdWater(value: CharacteristicValue): Promise<void>;
47
+ getZeroColdPulse(): CharacteristicValue;
48
+ setZeroColdPulse(value: CharacteristicValue): Promise<void>;
49
+ getSmartVolume(): CharacteristicValue;
50
+ setSmartVolume(value: CharacteristicValue): Promise<void>;
51
+ }
52
+ //# sourceMappingURL=GasWaterHeaterAccessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GasWaterHeaterAccessory.d.ts","sourceRoot":"","sources":["../../src/accessory/GasWaterHeaterAccessory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,mBAAmB,EAAW,MAAM,YAAY,CAAC;AAC1D,OAAO,aAA+B,MAAM,6BAA6B,CAAC;AAC1E,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,aAAa,CAAC,aAAa,CAAC;IAe7E,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa;IACxC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY;IAf5C,OAAO,CAAC,OAAO,CAAU;IAGzB,OAAO,CAAC,mBAAmB,CAAC,CAAU;IACtC,OAAO,CAAC,iBAAiB,CAAC,CAAU;IAGpC,OAAO,CAAC,oBAAoB,CAAC,CAAU;IACvC,OAAO,CAAC,oBAAoB,CAAC,CAAU;IACvC,OAAO,CAAC,kBAAkB,CAAC,CAAU;gBAGnC,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,cAAc,EACN,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,YAAY;IA8H5C;;;OAGG;YACW,qBAAqB;IA6CnC;;;OAGG;IACH,SAAS,IAAI,mBAAmB;IAI1B,SAAS,CAAC,KAAK,EAAE,mBAAmB;IAI1C,2BAA2B,IAAI,mBAAmB;IASlD,0BAA0B,IAAI,mBAAmB;IAI3C,0BAA0B,CAAC,KAAK,EAAE,mBAAmB;IAQ3D,qBAAqB,IAAI,mBAAmB;IAI5C,oBAAoB,IAAI,mBAAmB;IAOrC,oBAAoB,CAAC,KAAK,EAAE,mBAAmB;IAKrD,eAAe,IAAI,mBAAmB;IAItC,aAAa,IAAI,mBAAmB;IAIpC,gBAAgB,IAAI,mBAAmB;IAIjC,gBAAgB,CAAC,KAAK,EAAE,mBAAmB;IAIjD,gBAAgB,IAAI,mBAAmB;IAIjC,gBAAgB,CAAC,KAAK,EAAE,mBAAmB;IAIjD,cAAc,IAAI,mBAAmB;IAI/B,cAAc,CAAC,KAAK,EAAE,mBAAmB;CAGhD"}
@@ -0,0 +1,219 @@
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
+ this.device.on('update', this.updateCharacteristics.bind(this));
105
+ this.device.refresh_status();
106
+ }
107
+ /*********************************************************************
108
+ * Callback function called by MideaDevice whenever there is a change to
109
+ * any attribute value.
110
+ */
111
+ async updateCharacteristics(attributes) {
112
+ var _a, _b, _c, _d, _e;
113
+ for (const [k, v] of Object.entries(attributes)) {
114
+ this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
115
+ let updateState = false;
116
+ switch (k.toLowerCase()) {
117
+ case 'power':
118
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, v ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
119
+ updateState = true;
120
+ break;
121
+ case 'burning_state':
122
+ (_a = this.burningStateService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.MotionDetected, v);
123
+ break;
124
+ case 'zero_cold_water':
125
+ (_b = this.zeroColdWaterService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.On, v);
126
+ break;
127
+ case 'protection':
128
+ (_c = this.protectionService) === null || _c === void 0 ? void 0 : _c.updateCharacteristic(this.platform.Characteristic.MotionDetected, v);
129
+ break;
130
+ case 'zero_cold_pulse':
131
+ (_d = this.zeroColdPulseService) === null || _d === void 0 ? void 0 : _d.updateCharacteristic(this.platform.Characteristic.On, v);
132
+ break;
133
+ case 'smart_volume':
134
+ (_e = this.smartVolumeService) === null || _e === void 0 ? void 0 : _e.updateCharacteristic(this.platform.Characteristic.On, v);
135
+ break;
136
+ case 'current_temperature':
137
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, v);
138
+ updateState = true;
139
+ break;
140
+ case 'target_temperature':
141
+ this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, v);
142
+ updateState = true;
143
+ break;
144
+ default:
145
+ this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
146
+ }
147
+ if (updateState) {
148
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.getTargetHeaterCoolerState());
149
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.getCurrentHeaterCoolerState());
150
+ }
151
+ }
152
+ }
153
+ /*********************************************************************
154
+ * Callback functions for each Homebridge/HomeKit service
155
+ *
156
+ */
157
+ getActive() {
158
+ return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
159
+ }
160
+ async setActive(value) {
161
+ await this.device.set_attribute({ POWER: !!value });
162
+ }
163
+ getCurrentHeaterCoolerState() {
164
+ if (this.device.attributes.POWER) {
165
+ return this.device.attributes.HEATING
166
+ ? this.platform.Characteristic.CurrentHeaterCoolerState.HEATING
167
+ : this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
168
+ }
169
+ return this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
170
+ }
171
+ getTargetHeaterCoolerState() {
172
+ return this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
173
+ }
174
+ async setTargetHeaterCoolerState(value) {
175
+ if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
176
+ await this.device.set_attribute({ POWER: true });
177
+ }
178
+ else {
179
+ await this.device.set_attribute({ POWER: false });
180
+ }
181
+ }
182
+ getCurrentTemperature() {
183
+ var _a;
184
+ return (_a = this.device.attributes.CURRENT_TEMPERATURE) !== null && _a !== void 0 ? _a : this.configDev.E3_options.minTemp;
185
+ }
186
+ getTargetTemperature() {
187
+ return Math.max(this.configDev.E3_options.minTemp, Math.min(this.configDev.E3_options.maxTemp, this.device.attributes.TARGET_TEMPERATURE));
188
+ }
189
+ async setTargetTemperature(value) {
190
+ value = Math.max(this.configDev.E3_options.minTemp, Math.min(this.configDev.E3_options.maxTemp, value));
191
+ await this.device.set_attribute({ TARGET_TEMPERATURE: value });
192
+ }
193
+ getBurningState() {
194
+ return this.device.attributes.BURNING_STATE;
195
+ }
196
+ getProtection() {
197
+ return this.device.attributes.PROTECTION;
198
+ }
199
+ getZeroColdWater() {
200
+ return this.device.attributes.ZERO_COLD_WATER;
201
+ }
202
+ async setZeroColdWater(value) {
203
+ await this.device.set_attribute({ ZERO_COLD_WATER: !!value });
204
+ }
205
+ getZeroColdPulse() {
206
+ return this.device.attributes.ZERO_COLD_PULSE;
207
+ }
208
+ async setZeroColdPulse(value) {
209
+ await this.device.set_attribute({ ZERO_COLD_PULSE: !!value });
210
+ }
211
+ getSmartVolume() {
212
+ return this.device.attributes.SMART_VOLUME;
213
+ }
214
+ async setSmartVolume(value) {
215
+ await this.device.set_attribute({ SMART_VOLUME: !!value });
216
+ }
217
+ }
218
+ exports.default = GasWaterHeaterAccessory;
219
+ //# sourceMappingURL=GasWaterHeaterAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GasWaterHeaterAccessory.js","sourceRoot":"","sources":["../../src/accessory/GasWaterHeaterAccessory.ts"],"names":[],"mappings":";;;;;AAYA,oEAA4C;AAI5C,MAAqB,uBAAwB,SAAQ,uBAA4B;IAY/E,YACE,QAAuB,EACvB,SAAyB,EACN,MAAqB,EACrB,SAAuB;;QAE1C,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAH3B,WAAM,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AAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAA0B;QAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AA/QD,0CA+QC"}
@@ -1,33 +1,33 @@
1
1
  /// <reference types="node" />
2
- import { CloudSecurity } from './MideaSecurity';
3
- import { Endianness } from './MideaConstants';
4
2
  import { Semaphore } from 'semaphore-promise';
5
- declare abstract class CloudBase<T extends CloudSecurity> {
3
+ import { Endianness } from './MideaConstants';
4
+ import { CloudSecurity } from './MideaSecurity';
5
+ declare abstract class CloudBase<S extends CloudSecurity> {
6
6
  protected readonly account: string;
7
7
  protected readonly password: string;
8
- protected readonly security: T;
8
+ protected readonly security: S;
9
9
  protected readonly CLIENT_TYPE = 1;
10
10
  protected readonly FORMAT = 2;
11
- protected readonly APP_KEY = "4675636b";
12
11
  protected readonly LANGUAGE = "en_US";
13
- protected readonly APP_ID: string;
14
- protected readonly SRC: string;
12
+ protected abstract readonly APP_ID: string;
13
+ protected abstract readonly API_URL: string;
15
14
  protected readonly DEVICE_ID: string;
16
- protected abstract API_URL: string;
17
15
  protected access_token?: string;
16
+ protected uid?: string;
18
17
  protected key?: string;
19
18
  protected semaphore: Semaphore;
20
19
  loggedIn: boolean;
21
- constructor(account: string, password: string, security: T);
20
+ constructor(account: string, password: string, security: S);
22
21
  protected timestamp(): string;
23
- apiRequest(endpoint: string, args?: {
24
- [key: string]: any;
25
- }, data?: {
22
+ abstract buildRequestData(): {
23
+ [key: string]: string | number;
24
+ };
25
+ abstract apiRequest(endpoint: string, data: {
26
26
  [key: string]: any;
27
27
  }): Promise<any>;
28
28
  getLoginId(): Promise<any>;
29
- login(): Promise<void>;
30
- getToken(device_id: number, endianess: Endianness): Promise<[Buffer, Buffer]>;
29
+ abstract login(): Promise<void>;
30
+ getTokenKey(device_id: number, endianess: Endianness): Promise<[Buffer, Buffer]>;
31
31
  }
32
32
  export default class CloudFactory {
33
33
  static createCloud(account: string, password: string, cloud: string): CloudBase<CloudSecurity>;
@@ -1 +1 @@
1
- {"version":3,"file":"MideaCloud.d.ts","sourceRoot":"","sources":["../../src/core/MideaCloud.ts"],"names":[],"mappings":";AAYA,OAAO,EAAE,aAAa,EAA6D,MAAM,iBAAiB,CAAC;AAE3G,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,uBAAe,SAAS,CAAC,CAAC,SAAS,aAAa;IAkB5C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM;IAClC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACnC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAnBhC,SAAS,CAAC,QAAQ,CAAC,WAAW,KAAK;IACnC,SAAS,CAAC,QAAQ,CAAC,MAAM,KAAK;IAC9B,SAAS,CAAC,QAAQ,CAAC,OAAO,cAAc;IAExC,SAAS,CAAC,QAAQ,CAAC,QAAQ,WAAW;IACtC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAU;IAC3C,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAU;IACxC,SAAS,CAAC,QAAQ,CAAC,SAAS,SAAkC;IAE9D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACnC,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;IACxB,QAAQ,UAAS;gBAGH,OAAO,EAAE,MAAM,EACf,QAAQ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