homebridge-midea-platform 1.2.0-beta.1 → 1.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +0 -0
- package/config.schema.json +6 -0
- package/dist/accessory/AccessoryFactory.d.ts +12 -12
- package/dist/accessory/AccessoryFactory.js +31 -31
- package/dist/accessory/AirConditionerAccessory.d.ts +92 -89
- package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
- package/dist/accessory/AirConditionerAccessory.js +607 -584
- package/dist/accessory/AirConditionerAccessory.js.map +1 -1
- package/dist/accessory/BaseAccessory.d.ts +11 -11
- package/dist/accessory/BaseAccessory.js +21 -21
- package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
- package/dist/accessory/DehumidifierAccessory.js +344 -344
- package/dist/accessory/DishwasherAccessory.d.ts +30 -28
- package/dist/accessory/DishwasherAccessory.d.ts.map +1 -1
- package/dist/accessory/DishwasherAccessory.js +63 -62
- package/dist/accessory/DishwasherAccessory.js.map +1 -1
- package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
- package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
- package/dist/accessory/FanAccessory.d.ts +39 -39
- package/dist/accessory/FanAccessory.js +123 -123
- package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -30
- package/dist/accessory/FrontLoadWasherAccessory.d.ts.map +1 -1
- package/dist/accessory/FrontLoadWasherAccessory.js +66 -60
- package/dist/accessory/FrontLoadWasherAccessory.js.map +1 -1
- package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
- package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
- package/dist/core/MideaCloud.d.ts +35 -35
- package/dist/core/MideaCloud.js +350 -350
- package/dist/core/MideaConstants.d.ts +50 -50
- package/dist/core/MideaConstants.js +58 -58
- package/dist/core/MideaDevice.d.ts +76 -76
- package/dist/core/MideaDevice.js +409 -409
- package/dist/core/MideaDiscover.d.ts +35 -35
- package/dist/core/MideaDiscover.js +212 -212
- package/dist/core/MideaMessage.d.ts +75 -75
- package/dist/core/MideaMessage.js +184 -184
- package/dist/core/MideaPacketBuilder.d.ts +10 -10
- package/dist/core/MideaPacketBuilder.js +60 -60
- package/dist/core/MideaSecurity.d.ts +63 -63
- package/dist/core/MideaSecurity.js +251 -251
- package/dist/core/MideaUtils.d.ts +32 -32
- package/dist/core/MideaUtils.js +181 -181
- package/dist/devices/DeviceFactory.d.ts +13 -13
- package/dist/devices/DeviceFactory.js +36 -36
- package/dist/devices/a1/MideaA1Device.d.ts +76 -76
- package/dist/devices/a1/MideaA1Device.js +145 -145
- package/dist/devices/a1/MideaA1Device.js.map +1 -1
- package/dist/devices/a1/MideaA1Message.d.ts +40 -40
- package/dist/devices/a1/MideaA1Message.js +198 -198
- package/dist/devices/ac/MideaACDevice.d.ts +104 -100
- package/dist/devices/ac/MideaACDevice.d.ts.map +1 -1
- package/dist/devices/ac/MideaACDevice.js +384 -367
- package/dist/devices/ac/MideaACDevice.js.map +1 -1
- package/dist/devices/ac/MideaACMessage.d.ts +94 -92
- package/dist/devices/ac/MideaACMessage.d.ts.map +1 -1
- package/dist/devices/ac/MideaACMessage.js +611 -589
- package/dist/devices/ac/MideaACMessage.js.map +1 -1
- package/dist/devices/db/MideaDBDevice.d.ts +29 -29
- package/dist/devices/db/MideaDBDevice.js +100 -100
- package/dist/devices/db/MideaDBDevice.js.map +1 -1
- package/dist/devices/db/MideaDBMessage.d.ts +32 -32
- package/dist/devices/db/MideaDBMessage.js +101 -101
- package/dist/devices/e1/MideaE1Device.d.ts +56 -56
- package/dist/devices/e1/MideaE1Device.js +128 -128
- package/dist/devices/e1/MideaE1Device.js.map +1 -1
- package/dist/devices/e1/MideaE1Message.d.ts +28 -28
- package/dist/devices/e1/MideaE1Message.js +107 -107
- package/dist/devices/e2/MideaE2Device.d.ts +44 -44
- package/dist/devices/e2/MideaE2Device.js +129 -129
- package/dist/devices/e2/MideaE2Device.js.map +1 -1
- package/dist/devices/e2/MideaE2Message.d.ts +33 -33
- package/dist/devices/e2/MideaE2Message.js +132 -132
- package/dist/devices/e3/MideaE3Device.d.ts +43 -43
- package/dist/devices/e3/MideaE3Device.js +137 -137
- package/dist/devices/e3/MideaE3Device.js.map +1 -1
- package/dist/devices/e3/MideaE3Message.d.ts +51 -51
- package/dist/devices/e3/MideaE3Message.js +136 -136
- package/dist/devices/fa/MideaFADevice.d.ts +36 -36
- package/dist/devices/fa/MideaFADevice.js +106 -106
- package/dist/devices/fa/MideaFADevice.js.map +1 -1
- package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
- package/dist/devices/fa/MideaFAMessage.js +98 -98
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/platform.d.ts +60 -60
- package/dist/platform.js +212 -212
- package/dist/platformUtils.d.ts +106 -105
- package/dist/platformUtils.d.ts.map +1 -1
- package/dist/platformUtils.js +101 -100
- package/dist/platformUtils.js.map +1 -1
- package/dist/settings.d.ts +8 -8
- package/dist/settings.js +11 -11
- package/package.json +1 -1
- package/AC_ori.lua +0 -5150
|
@@ -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
|