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