homebridge-midea-platform 1.1.2-beta.3 → 1.1.2-beta.4

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 (69) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/dist/accessory/AccessoryFactory.d.ts +12 -12
  3. package/dist/accessory/AccessoryFactory.js +31 -31
  4. package/dist/accessory/AirConditionerAccessory.d.ts +86 -86
  5. package/dist/accessory/AirConditionerAccessory.js +560 -560
  6. package/dist/accessory/AirConditionerAccessory.js.map +1 -1
  7. package/dist/accessory/BaseAccessory.d.ts +11 -11
  8. package/dist/accessory/BaseAccessory.js +21 -21
  9. package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
  10. package/dist/accessory/DehumidifierAccessory.js +344 -344
  11. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
  12. package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
  13. package/dist/accessory/FanAccessory.d.ts +39 -39
  14. package/dist/accessory/FanAccessory.js +123 -123
  15. package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -30
  16. package/dist/accessory/FrontLoadWasherAccessory.js +60 -60
  17. package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
  18. package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
  19. package/dist/core/MideaCloud.d.ts +35 -35
  20. package/dist/core/MideaCloud.js +350 -350
  21. package/dist/core/MideaConstants.d.ts +49 -49
  22. package/dist/core/MideaConstants.js +57 -57
  23. package/dist/core/MideaDevice.d.ts +76 -76
  24. package/dist/core/MideaDevice.js +409 -409
  25. package/dist/core/MideaDiscover.d.ts +35 -35
  26. package/dist/core/MideaDiscover.js +212 -212
  27. package/dist/core/MideaMessage.d.ts +75 -75
  28. package/dist/core/MideaMessage.js +184 -184
  29. package/dist/core/MideaPacketBuilder.d.ts +10 -10
  30. package/dist/core/MideaPacketBuilder.js +60 -60
  31. package/dist/core/MideaSecurity.d.ts +63 -63
  32. package/dist/core/MideaSecurity.js +242 -242
  33. package/dist/core/MideaUtils.d.ts +32 -32
  34. package/dist/core/MideaUtils.js +181 -181
  35. package/dist/devices/DeviceFactory.d.ts +12 -12
  36. package/dist/devices/DeviceFactory.js +33 -33
  37. package/dist/devices/a1/MideaA1Device.d.ts +76 -76
  38. package/dist/devices/a1/MideaA1Device.js +136 -136
  39. package/dist/devices/a1/MideaA1Message.d.ts +40 -40
  40. package/dist/devices/a1/MideaA1Message.js +198 -198
  41. package/dist/devices/ac/MideaACDevice.d.ts +100 -100
  42. package/dist/devices/ac/MideaACDevice.js +370 -370
  43. package/dist/devices/ac/MideaACMessage.d.ts +92 -92
  44. package/dist/devices/ac/MideaACMessage.js +589 -589
  45. package/dist/devices/db/MideaDBDevice.d.ts +29 -29
  46. package/dist/devices/db/MideaDBDevice.js +88 -88
  47. package/dist/devices/db/MideaDBMessage.d.ts +32 -32
  48. package/dist/devices/db/MideaDBMessage.js +101 -101
  49. package/dist/devices/e2/MideaE2Device.d.ts +44 -44
  50. package/dist/devices/e2/MideaE2Device.js +119 -119
  51. package/dist/devices/e2/MideaE2Message.d.ts +33 -33
  52. package/dist/devices/e2/MideaE2Message.js +132 -132
  53. package/dist/devices/e3/MideaE3Device.d.ts +43 -43
  54. package/dist/devices/e3/MideaE3Device.js +125 -125
  55. package/dist/devices/e3/MideaE3Message.d.ts +51 -51
  56. package/dist/devices/e3/MideaE3Message.js +136 -136
  57. package/dist/devices/fa/MideaFADevice.d.ts +36 -36
  58. package/dist/devices/fa/MideaFADevice.js +92 -92
  59. package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
  60. package/dist/devices/fa/MideaFAMessage.js +98 -98
  61. package/dist/index.d.ts +6 -6
  62. package/dist/index.js +6 -6
  63. package/dist/platform.d.ts +60 -60
  64. package/dist/platform.js +213 -213
  65. package/dist/platformUtils.d.ts +98 -98
  66. package/dist/platformUtils.js +96 -96
  67. package/dist/settings.d.ts +8 -8
  68. package/dist/settings.js +11 -11
  69. package/package.json +1 -1
@@ -1,45 +1,45 @@
1
- /***********************************************************************
2
- * Midea Platform Electric 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 MideaE2Device, { E2Attributes } from '../devices/e2/MideaE2Device';
13
- import BaseAccessory from './BaseAccessory';
14
- import { MideaAccessory, MideaPlatform } from '../platform';
15
- import { DeviceConfig } from '../platformUtils';
16
- export default class ElectricWaterHeaterAccessory extends BaseAccessory<MideaE2Device> {
17
- protected readonly device: MideaE2Device;
18
- protected readonly configDev: DeviceConfig;
19
- private service;
20
- private variableHeatingService?;
21
- private wholeTankHeatingService?;
22
- constructor(platform: MideaPlatform, accessory: MideaAccessory, device: MideaE2Device, configDev: DeviceConfig);
23
- /*********************************************************************
24
- * Callback function called by MideaDevice whenever there is a change to
25
- * any attribute value.
26
- */
27
- protected updateCharacteristics(attributes: Partial<E2Attributes>): Promise<void>;
28
- /*********************************************************************
29
- * Callback functions for each Homebridge/HomeKit service
30
- *
31
- */
32
- getActive(): CharacteristicValue;
33
- setActive(value: CharacteristicValue): Promise<void>;
34
- getCurrentHeaterCoolerState(): CharacteristicValue;
35
- getTargetHeaterCoolerState(): CharacteristicValue;
36
- setTargetHeaterCoolerState(value: CharacteristicValue): Promise<void>;
37
- getCurrentTemperature(): CharacteristicValue;
38
- getTargetTemperature(): CharacteristicValue;
39
- setTargetTemperature(value: CharacteristicValue): Promise<void>;
40
- getVariableHeating(): CharacteristicValue;
41
- setVariableHeating(value: CharacteristicValue): Promise<void>;
42
- getWholeTankHeating(): CharacteristicValue;
43
- setWholeTankHeating(value: CharacteristicValue): Promise<void>;
44
- }
1
+ /***********************************************************************
2
+ * Midea Platform Electric 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 MideaE2Device, { E2Attributes } from '../devices/e2/MideaE2Device';
13
+ import BaseAccessory from './BaseAccessory';
14
+ import { MideaAccessory, MideaPlatform } from '../platform';
15
+ import { DeviceConfig } from '../platformUtils';
16
+ export default class ElectricWaterHeaterAccessory extends BaseAccessory<MideaE2Device> {
17
+ protected readonly device: MideaE2Device;
18
+ protected readonly configDev: DeviceConfig;
19
+ private service;
20
+ private variableHeatingService?;
21
+ private wholeTankHeatingService?;
22
+ constructor(platform: MideaPlatform, accessory: MideaAccessory, device: MideaE2Device, configDev: DeviceConfig);
23
+ /*********************************************************************
24
+ * Callback function called by MideaDevice whenever there is a change to
25
+ * any attribute value.
26
+ */
27
+ protected updateCharacteristics(attributes: Partial<E2Attributes>): Promise<void>;
28
+ /*********************************************************************
29
+ * Callback functions for each Homebridge/HomeKit service
30
+ *
31
+ */
32
+ getActive(): CharacteristicValue;
33
+ setActive(value: CharacteristicValue): Promise<void>;
34
+ getCurrentHeaterCoolerState(): CharacteristicValue;
35
+ getTargetHeaterCoolerState(): CharacteristicValue;
36
+ setTargetHeaterCoolerState(value: CharacteristicValue): Promise<void>;
37
+ getCurrentTemperature(): CharacteristicValue;
38
+ getTargetTemperature(): CharacteristicValue;
39
+ setTargetTemperature(value: CharacteristicValue): Promise<void>;
40
+ getVariableHeating(): CharacteristicValue;
41
+ setVariableHeating(value: CharacteristicValue): Promise<void>;
42
+ getWholeTankHeating(): CharacteristicValue;
43
+ setWholeTankHeating(value: CharacteristicValue): Promise<void>;
44
+ }
45
45
  //# sourceMappingURL=ElectricWaterHeaterAccessory.d.ts.map
@@ -1,177 +1,177 @@
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
- }
67
- /*********************************************************************
68
- * Callback function called by MideaDevice whenever there is a change to
69
- * any attribute value.
70
- */
71
- async updateCharacteristics(attributes) {
72
- var _a, _b;
73
- for (const [k, v] of Object.entries(attributes)) {
74
- this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
75
- let updateState = false;
76
- switch (k.toLowerCase()) {
77
- case 'power':
78
- this.service.updateCharacteristic(this.platform.Characteristic.Active, v ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
79
- updateState = true;
80
- break;
81
- case 'heating':
82
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, v ? this.platform.Characteristic.CurrentHeaterCoolerState.HEATING : this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
83
- updateState = true;
84
- break;
85
- // case 'keep_warm':
86
- // this.platform.log.debug(`[${this.device.name}] Keep warm: ${v}`);
87
- // break;
88
- // case 'protection':
89
- // this.platform.log.debug(`[${this.device.name}] Protection: ${v}`);
90
- // break;
91
- case 'current_temperature':
92
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, v);
93
- updateState = true;
94
- break;
95
- case 'target_temperature':
96
- this.service.updateCharacteristic(this.platform.Characteristic.TargetTemperature, v);
97
- updateState = true;
98
- break;
99
- case 'whole_tank_heating':
100
- (_a = this.wholeTankHeatingService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.On, v);
101
- break;
102
- case 'variable_heating':
103
- (_b = this.variableHeatingService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.On, v);
104
- break;
105
- // case 'heating_time_remaining':
106
- // this.platform.log.debug(`[${this.device.name}] Heating time remaining: ${v}`);
107
- // break;
108
- // case 'water_consumption':
109
- // this.platform.log.debug(`[${this.device.name}] Water consumption: ${v}`);
110
- // break;
111
- // case 'heating_power':
112
- // this.platform.log.debug(`[${this.device.name}] Heating power: ${v}`);
113
- // break;
114
- default:
115
- this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
116
- }
117
- if (updateState) {
118
- this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.getTargetHeaterCoolerState());
119
- this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.getCurrentHeaterCoolerState());
120
- }
121
- }
122
- }
123
- /*********************************************************************
124
- * Callback functions for each Homebridge/HomeKit service
125
- *
126
- */
127
- getActive() {
128
- return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
129
- }
130
- async setActive(value) {
131
- await this.device.set_attribute({ POWER: !!value });
132
- }
133
- getCurrentHeaterCoolerState() {
134
- if (this.device.attributes.POWER) {
135
- return this.device.attributes.HEATING
136
- ? this.platform.Characteristic.CurrentHeaterCoolerState.HEATING
137
- : this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
138
- }
139
- return this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
140
- }
141
- getTargetHeaterCoolerState() {
142
- return this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
143
- }
144
- async setTargetHeaterCoolerState(value) {
145
- if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
146
- await this.device.set_attribute({ POWER: true });
147
- }
148
- else {
149
- await this.device.set_attribute({ POWER: false });
150
- }
151
- }
152
- getCurrentTemperature() {
153
- var _a;
154
- return (_a = this.device.attributes.CURRENT_TEMPERATURE) !== null && _a !== void 0 ? _a : this.configDev.E2_options.minTemp;
155
- }
156
- getTargetTemperature() {
157
- return Math.max(this.configDev.E2_options.minTemp, Math.min(this.configDev.E2_options.maxTemp, this.device.attributes.TARGET_TEMPERATURE));
158
- }
159
- async setTargetTemperature(value) {
160
- value = Math.max(this.configDev.E2_options.minTemp, Math.min(this.configDev.E2_options.maxTemp, value));
161
- await this.device.set_attribute({ TARGET_TEMPERATURE: value });
162
- }
163
- getVariableHeating() {
164
- return this.device.attributes.VARIABLE_HEATING;
165
- }
166
- async setVariableHeating(value) {
167
- await this.device.set_attribute({ VARIABLE_HEATING: !!value });
168
- }
169
- getWholeTankHeating() {
170
- return this.device.attributes.WHOLE_TANK_HEATING;
171
- }
172
- async setWholeTankHeating(value) {
173
- await this.device.set_attribute({ WHOLE_TANK_HEATING: !!value });
174
- }
175
- }
176
- exports.default = ElectricWaterHeaterAccessory;
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
+ }
67
+ /*********************************************************************
68
+ * Callback function called by MideaDevice whenever there is a change to
69
+ * any attribute value.
70
+ */
71
+ async updateCharacteristics(attributes) {
72
+ var _a, _b;
73
+ for (const [k, v] of Object.entries(attributes)) {
74
+ this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
75
+ let updateState = false;
76
+ switch (k.toLowerCase()) {
77
+ case 'power':
78
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, v ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
79
+ updateState = true;
80
+ break;
81
+ case 'heating':
82
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, v ? this.platform.Characteristic.CurrentHeaterCoolerState.HEATING : this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
83
+ updateState = true;
84
+ break;
85
+ // case 'keep_warm':
86
+ // this.platform.log.debug(`[${this.device.name}] Keep warm: ${v}`);
87
+ // break;
88
+ // case 'protection':
89
+ // this.platform.log.debug(`[${this.device.name}] Protection: ${v}`);
90
+ // break;
91
+ case 'current_temperature':
92
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, v);
93
+ updateState = true;
94
+ break;
95
+ case 'target_temperature':
96
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetTemperature, v);
97
+ updateState = true;
98
+ break;
99
+ case 'whole_tank_heating':
100
+ (_a = this.wholeTankHeatingService) === null || _a === void 0 ? void 0 : _a.updateCharacteristic(this.platform.Characteristic.On, v);
101
+ break;
102
+ case 'variable_heating':
103
+ (_b = this.variableHeatingService) === null || _b === void 0 ? void 0 : _b.updateCharacteristic(this.platform.Characteristic.On, v);
104
+ break;
105
+ // case 'heating_time_remaining':
106
+ // this.platform.log.debug(`[${this.device.name}] Heating time remaining: ${v}`);
107
+ // break;
108
+ // case 'water_consumption':
109
+ // this.platform.log.debug(`[${this.device.name}] Water consumption: ${v}`);
110
+ // break;
111
+ // case 'heating_power':
112
+ // this.platform.log.debug(`[${this.device.name}] Heating power: ${v}`);
113
+ // break;
114
+ default:
115
+ this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
116
+ }
117
+ if (updateState) {
118
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.getTargetHeaterCoolerState());
119
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.getCurrentHeaterCoolerState());
120
+ }
121
+ }
122
+ }
123
+ /*********************************************************************
124
+ * Callback functions for each Homebridge/HomeKit service
125
+ *
126
+ */
127
+ getActive() {
128
+ return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
129
+ }
130
+ async setActive(value) {
131
+ await this.device.set_attribute({ POWER: !!value });
132
+ }
133
+ getCurrentHeaterCoolerState() {
134
+ if (this.device.attributes.POWER) {
135
+ return this.device.attributes.HEATING
136
+ ? this.platform.Characteristic.CurrentHeaterCoolerState.HEATING
137
+ : this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
138
+ }
139
+ return this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
140
+ }
141
+ getTargetHeaterCoolerState() {
142
+ return this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
143
+ }
144
+ async setTargetHeaterCoolerState(value) {
145
+ if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
146
+ await this.device.set_attribute({ POWER: true });
147
+ }
148
+ else {
149
+ await this.device.set_attribute({ POWER: false });
150
+ }
151
+ }
152
+ getCurrentTemperature() {
153
+ var _a;
154
+ return (_a = this.device.attributes.CURRENT_TEMPERATURE) !== null && _a !== void 0 ? _a : this.configDev.E2_options.minTemp;
155
+ }
156
+ getTargetTemperature() {
157
+ return Math.max(this.configDev.E2_options.minTemp, Math.min(this.configDev.E2_options.maxTemp, this.device.attributes.TARGET_TEMPERATURE));
158
+ }
159
+ async setTargetTemperature(value) {
160
+ value = Math.max(this.configDev.E2_options.minTemp, Math.min(this.configDev.E2_options.maxTemp, value));
161
+ await this.device.set_attribute({ TARGET_TEMPERATURE: value });
162
+ }
163
+ getVariableHeating() {
164
+ return this.device.attributes.VARIABLE_HEATING;
165
+ }
166
+ async setVariableHeating(value) {
167
+ await this.device.set_attribute({ VARIABLE_HEATING: !!value });
168
+ }
169
+ getWholeTankHeating() {
170
+ return this.device.attributes.WHOLE_TANK_HEATING;
171
+ }
172
+ async setWholeTankHeating(value) {
173
+ await this.device.set_attribute({ WHOLE_TANK_HEATING: !!value });
174
+ }
175
+ }
176
+ exports.default = ElectricWaterHeaterAccessory;
177
177
  //# sourceMappingURL=ElectricWaterHeaterAccessory.js.map
@@ -1,40 +1,40 @@
1
- /***********************************************************************
2
- * Midea Platform Fan 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 { MideaAccessory, MideaPlatform } from '../platform';
13
- import BaseAccessory from './BaseAccessory';
14
- import { DeviceConfig } from '../platformUtils';
15
- import MideaFADevice, { FAAttributes } from '../devices/fa/MideaFADevice';
16
- export default class FanAccessory extends BaseAccessory<MideaFADevice> {
17
- protected readonly device: MideaFADevice;
18
- protected readonly configDev: DeviceConfig;
19
- private service;
20
- /*********************************************************************
21
- * Constructor registers all the service types with Homebridge, registers
22
- * a callback function with the MideaDevice class, and requests device status.
23
- */
24
- constructor(platform: MideaPlatform, accessory: MideaAccessory, device: MideaFADevice, configDev: DeviceConfig);
25
- updateCharacteristics(attributes: Partial<FAAttributes>): Promise<void>;
26
- getActive(): CharacteristicValue;
27
- setActive(value: CharacteristicValue): Promise<void>;
28
- getTargetFanState(): CharacteristicValue;
29
- setTargetFanState(value: CharacteristicValue): Promise<void>;
30
- getCurrentFanState(): CharacteristicValue;
31
- getRotationSpeed(): CharacteristicValue;
32
- setRotationSpeed(value: CharacteristicValue): Promise<void>;
33
- getRotationDirection(): CharacteristicValue;
34
- setRotationDirection(value: CharacteristicValue): Promise<void>;
35
- getSwingMode(): CharacteristicValue;
36
- setSwingMode(value: CharacteristicValue): Promise<void>;
37
- getLockPhysicalControls(): CharacteristicValue;
38
- setLockPhysicalControls(value: CharacteristicValue): Promise<void>;
39
- }
1
+ /***********************************************************************
2
+ * Midea Platform Fan 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 { MideaAccessory, MideaPlatform } from '../platform';
13
+ import BaseAccessory from './BaseAccessory';
14
+ import { DeviceConfig } from '../platformUtils';
15
+ import MideaFADevice, { FAAttributes } from '../devices/fa/MideaFADevice';
16
+ export default class FanAccessory extends BaseAccessory<MideaFADevice> {
17
+ protected readonly device: MideaFADevice;
18
+ protected readonly configDev: DeviceConfig;
19
+ private service;
20
+ /*********************************************************************
21
+ * Constructor registers all the service types with Homebridge, registers
22
+ * a callback function with the MideaDevice class, and requests device status.
23
+ */
24
+ constructor(platform: MideaPlatform, accessory: MideaAccessory, device: MideaFADevice, configDev: DeviceConfig);
25
+ updateCharacteristics(attributes: Partial<FAAttributes>): Promise<void>;
26
+ getActive(): CharacteristicValue;
27
+ setActive(value: CharacteristicValue): Promise<void>;
28
+ getTargetFanState(): CharacteristicValue;
29
+ setTargetFanState(value: CharacteristicValue): Promise<void>;
30
+ getCurrentFanState(): CharacteristicValue;
31
+ getRotationSpeed(): CharacteristicValue;
32
+ setRotationSpeed(value: CharacteristicValue): Promise<void>;
33
+ getRotationDirection(): CharacteristicValue;
34
+ setRotationDirection(value: CharacteristicValue): Promise<void>;
35
+ getSwingMode(): CharacteristicValue;
36
+ setSwingMode(value: CharacteristicValue): Promise<void>;
37
+ getLockPhysicalControls(): CharacteristicValue;
38
+ setLockPhysicalControls(value: CharacteristicValue): Promise<void>;
39
+ }
40
40
  //# sourceMappingURL=FanAccessory.d.ts.map