homebridge-midea-platform 1.2.0-beta.8 → 1.2.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/CHANGELOG.md +5 -2
- package/README.md +2 -2
- package/dist/accessory/AccessoryFactory.d.ts +14 -15
- package/dist/accessory/AccessoryFactory.js +34 -40
- package/dist/accessory/AccessoryFactory.js.map +1 -1
- package/dist/accessory/AirConditionerAccessory.d.ts +98 -99
- package/dist/accessory/AirConditionerAccessory.js +666 -662
- package/dist/accessory/AirConditionerAccessory.js.map +1 -1
- package/dist/accessory/BaseAccessory.d.ts +11 -12
- package/dist/accessory/BaseAccessory.js +21 -21
- package/dist/accessory/BaseAccessory.js.map +1 -1
- package/dist/accessory/DehumidifierAccessory.d.ts +45 -46
- package/dist/accessory/DehumidifierAccessory.js +343 -344
- package/dist/accessory/DehumidifierAccessory.js.map +1 -1
- package/dist/accessory/DishwasherAccessory.d.ts +30 -31
- package/dist/accessory/DishwasherAccessory.js +59 -63
- package/dist/accessory/DishwasherAccessory.js.map +1 -1
- package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -45
- package/dist/accessory/ElectricWaterHeaterAccessory.js +172 -176
- package/dist/accessory/ElectricWaterHeaterAccessory.js.map +1 -1
- package/dist/accessory/FanAccessory.d.ts +39 -40
- package/dist/accessory/FanAccessory.js +120 -123
- package/dist/accessory/FanAccessory.js.map +1 -1
- package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -31
- package/dist/accessory/FrontLoadWasherAccessory.js +63 -66
- package/dist/accessory/FrontLoadWasherAccessory.js.map +1 -1
- package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -52
- package/dist/accessory/GasWaterHeaterAccessory.js +217 -216
- package/dist/accessory/GasWaterHeaterAccessory.js.map +1 -1
- package/dist/accessory/{HeatPumpWifiControllerAccessory.d.ts → HeatPumpWiFiControllerAccessory.d.ts} +34 -35
- package/dist/accessory/{HeatPumpWifiControllerAccessory.js → HeatPumpWiFiControllerAccessory.js} +55 -36
- package/dist/accessory/HeatPumpWiFiControllerAccessory.js.map +1 -0
- package/dist/core/MideaCloud.d.ts +34 -36
- package/dist/core/MideaCloud.js +349 -350
- package/dist/core/MideaCloud.js.map +1 -1
- package/dist/core/MideaConstants.d.ts +51 -52
- package/dist/core/MideaConstants.js +56 -59
- package/dist/core/MideaConstants.js.map +1 -1
- package/dist/core/MideaDevice.d.ts +75 -78
- package/dist/core/MideaDevice.js +430 -420
- package/dist/core/MideaDevice.js.map +1 -1
- package/dist/core/MideaDiscover.d.ts +34 -36
- package/dist/core/MideaDiscover.js +208 -212
- package/dist/core/MideaDiscover.js.map +1 -1
- package/dist/core/MideaMessage.d.ts +75 -76
- package/dist/core/MideaMessage.js +185 -184
- package/dist/core/MideaMessage.js.map +1 -1
- package/dist/core/MideaPacketBuilder.d.ts +9 -11
- package/dist/core/MideaPacketBuilder.js +60 -60
- package/dist/core/MideaPacketBuilder.js.map +1 -1
- package/dist/core/MideaSecurity.d.ts +62 -64
- package/dist/core/MideaSecurity.js +241 -251
- package/dist/core/MideaSecurity.js.map +1 -1
- package/dist/core/MideaUtils.d.ts +31 -33
- package/dist/core/MideaUtils.js +178 -181
- package/dist/core/MideaUtils.js.map +1 -1
- package/dist/devices/DeviceFactory.d.ts +14 -15
- package/dist/devices/DeviceFactory.js +34 -40
- package/dist/devices/DeviceFactory.js.map +1 -1
- package/dist/devices/a1/MideaA1Device.d.ts +75 -77
- package/dist/devices/a1/MideaA1Device.js +142 -145
- package/dist/devices/a1/MideaA1Device.js.map +1 -1
- package/dist/devices/a1/MideaA1Message.d.ts +39 -41
- package/dist/devices/a1/MideaA1Message.js +219 -198
- package/dist/devices/a1/MideaA1Message.js.map +1 -1
- package/dist/devices/ac/MideaACDevice.d.ts +105 -107
- package/dist/devices/ac/MideaACDevice.js +417 -400
- package/dist/devices/ac/MideaACDevice.js.map +1 -1
- package/dist/devices/ac/MideaACMessage.d.ts +97 -96
- package/dist/devices/ac/MideaACMessage.js +724 -621
- package/dist/devices/ac/MideaACMessage.js.map +1 -1
- package/dist/devices/c3/MideaC3Device.d.ts +73 -75
- package/dist/devices/c3/MideaC3Device.js +249 -255
- package/dist/devices/c3/MideaC3Device.js.map +1 -1
- package/dist/devices/c3/MideaC3Message.d.ts +81 -80
- package/dist/devices/c3/MideaC3Message.js +190 -152
- package/dist/devices/c3/MideaC3Message.js.map +1 -1
- package/dist/devices/db/MideaDBDevice.d.ts +28 -30
- package/dist/devices/db/MideaDBDevice.js +94 -100
- package/dist/devices/db/MideaDBDevice.js.map +1 -1
- package/dist/devices/db/MideaDBMessage.d.ts +31 -33
- package/dist/devices/db/MideaDBMessage.js +101 -101
- package/dist/devices/db/MideaDBMessage.js.map +1 -1
- package/dist/devices/e1/MideaE1Device.d.ts +55 -57
- package/dist/devices/e1/MideaE1Device.js +122 -128
- package/dist/devices/e1/MideaE1Device.js.map +1 -1
- package/dist/devices/e1/MideaE1Message.d.ts +27 -29
- package/dist/devices/e1/MideaE1Message.js +128 -107
- package/dist/devices/e1/MideaE1Message.js.map +1 -1
- package/dist/devices/e2/MideaE2Device.d.ts +43 -45
- package/dist/devices/e2/MideaE2Device.js +124 -129
- package/dist/devices/e2/MideaE2Device.js.map +1 -1
- package/dist/devices/e2/MideaE2Message.d.ts +34 -34
- package/dist/devices/e2/MideaE2Message.js +143 -132
- package/dist/devices/e2/MideaE2Message.js.map +1 -1
- package/dist/devices/e3/MideaE3Device.d.ts +42 -44
- package/dist/devices/e3/MideaE3Device.js +132 -137
- package/dist/devices/e3/MideaE3Device.js.map +1 -1
- package/dist/devices/e3/MideaE3Message.d.ts +51 -52
- package/dist/devices/e3/MideaE3Message.js +144 -136
- package/dist/devices/e3/MideaE3Message.js.map +1 -1
- package/dist/devices/fa/MideaFADevice.d.ts +35 -37
- package/dist/devices/fa/MideaFADevice.js +102 -106
- package/dist/devices/fa/MideaFADevice.js.map +1 -1
- package/dist/devices/fa/MideaFAMessage.d.ts +38 -39
- package/dist/devices/fa/MideaFAMessage.js +108 -98
- package/dist/devices/fa/MideaFAMessage.js.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/platform.d.ts +61 -61
- package/dist/platform.js +232 -212
- package/dist/platform.js.map +1 -1
- package/dist/platformUtils.d.ts +116 -117
- package/dist/platformUtils.js +107 -110
- package/dist/platformUtils.js.map +1 -1
- package/dist/settings.d.ts +8 -9
- package/dist/settings.js +8 -11
- package/dist/settings.js.map +1 -1
- package/docs/download_lua.md +9 -0
- package/eslint.config.js +43 -0
- package/homebridge-ui/public/js/bootstrap.min.js +1179 -1
- package/homebridge-ui/server.js +157 -84
- package/package.json +21 -31
- package/.eslintignore +0 -3
- package/.husky/pre-commit +0 -5
- package/.prettierrc +0 -19
- package/dist/accessory/AccessoryFactory.d.ts.map +0 -1
- package/dist/accessory/AirConditionerAccessory.d.ts.map +0 -1
- package/dist/accessory/BaseAccessory.d.ts.map +0 -1
- package/dist/accessory/DehumidifierAccessory.d.ts.map +0 -1
- package/dist/accessory/DishwasherAccessory.d.ts.map +0 -1
- package/dist/accessory/ElectricWaterHeaterAccessory.d.ts.map +0 -1
- package/dist/accessory/FanAccessory.d.ts.map +0 -1
- package/dist/accessory/FrontLoadWasherAccessory.d.ts.map +0 -1
- package/dist/accessory/GasWaterHeaterAccessory.d.ts.map +0 -1
- package/dist/accessory/HeatPumpWifiControllerAccessory.d.ts.map +0 -1
- package/dist/accessory/HeatPumpWifiControllerAccessory.js.map +0 -1
- package/dist/core/MideaCloud.d.ts.map +0 -1
- package/dist/core/MideaConstants.d.ts.map +0 -1
- package/dist/core/MideaDevice.d.ts.map +0 -1
- package/dist/core/MideaDiscover.d.ts.map +0 -1
- package/dist/core/MideaMessage.d.ts.map +0 -1
- package/dist/core/MideaPacketBuilder.d.ts.map +0 -1
- package/dist/core/MideaSecurity.d.ts.map +0 -1
- package/dist/core/MideaUtils.d.ts.map +0 -1
- package/dist/devices/DeviceFactory.d.ts.map +0 -1
- package/dist/devices/a1/MideaA1Device.d.ts.map +0 -1
- package/dist/devices/a1/MideaA1Message.d.ts.map +0 -1
- package/dist/devices/ac/MideaACDevice.d.ts.map +0 -1
- package/dist/devices/ac/MideaACMessage.d.ts.map +0 -1
- package/dist/devices/c3/MideaC3Device.d.ts.map +0 -1
- package/dist/devices/c3/MideaC3Message.d.ts.map +0 -1
- package/dist/devices/db/MideaDBDevice.d.ts.map +0 -1
- package/dist/devices/db/MideaDBMessage.d.ts.map +0 -1
- package/dist/devices/e1/MideaE1Device.d.ts.map +0 -1
- package/dist/devices/e1/MideaE1Message.d.ts.map +0 -1
- package/dist/devices/e2/MideaE2Device.d.ts.map +0 -1
- package/dist/devices/e2/MideaE2Message.d.ts.map +0 -1
- package/dist/devices/e3/MideaE3Device.d.ts.map +0 -1
- package/dist/devices/e3/MideaE3Message.d.ts.map +0 -1
- package/dist/devices/fa/MideaFADevice.d.ts.map +0 -1
- package/dist/devices/fa/MideaFAMessage.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/platform.d.ts.map +0 -1
- package/dist/platformUtils.d.ts.map +0 -1
- package/dist/settings.d.ts.map +0 -1
|
@@ -1,347 +1,346 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import BaseAccessory from './BaseAccessory.js';
|
|
2
|
+
import { WaterTankSensor } from '../platformUtils.js';
|
|
3
|
+
export default class DehumidifierAccessory extends BaseAccessory {
|
|
4
|
+
device;
|
|
5
|
+
configDev;
|
|
6
|
+
service;
|
|
7
|
+
temperatureService;
|
|
8
|
+
fanService;
|
|
9
|
+
humiditySensorService;
|
|
10
|
+
pumpService;
|
|
11
|
+
waterTankService;
|
|
12
|
+
// Increment this every time we make a change to accessory that requires
|
|
13
|
+
// previously cached Homebridge service to be deleted/replaced.
|
|
14
|
+
serviceVersion = 1;
|
|
15
|
+
/*********************************************************************
|
|
16
|
+
* Constructor registers all the service types with Homebridge, registers
|
|
17
|
+
* a callback function with the MideaDevice class, and requests device status.
|
|
18
|
+
*/
|
|
19
|
+
constructor(platform, accessory, device, configDev) {
|
|
20
|
+
super(platform, accessory, device, configDev);
|
|
21
|
+
this.device = device;
|
|
22
|
+
this.configDev = configDev;
|
|
23
|
+
this.platform.log.debug(`[${device.name}] Dehumidifier serviceVersion: ${this.serviceVersion}, currentVersion: ${this.accessory.context.serviceVersion}`);
|
|
24
|
+
const service = this.accessory.getService(this.platform.Service.HumidifierDehumidifier);
|
|
25
|
+
if (service && this.accessory.context.serviceVersion !== this.serviceVersion) {
|
|
24
26
|
this.platform.log.info(`[${this.device.name}] New dehumidifier service version.\
|
|
25
|
-
Upgrade from v${this.accessory.context.serviceVersion} to v${this.serviceVersion}.`);
|
|
26
|
-
this.accessory.removeService(service);
|
|
27
|
-
this.service = this.accessory.addService(this.platform.Service.HumidifierDehumidifier);
|
|
28
|
-
this.accessory.context.serviceVersion = this.serviceVersion;
|
|
29
|
-
}
|
|
30
|
-
else if (service) {
|
|
31
|
-
this.platform.log.debug(`[${this.device.name}] Existing dehumidifier service version.`);
|
|
32
|
-
this.service = service;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this.platform.log.debug(`[${this.device.name}] Creating new dehumidifier service.`);
|
|
36
|
-
this.service = this.accessory.addService(this.platform.Service.HumidifierDehumidifier);
|
|
37
|
-
this.accessory.context.serviceVersion = this.serviceVersion;
|
|
38
|
-
}
|
|
39
|
-
this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
|
|
40
|
-
this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
|
|
41
|
-
this.service
|
|
42
|
-
.getCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState)
|
|
43
|
-
.onGet(this.getCurrentHumidifierDehumidifierState.bind(this));
|
|
44
|
-
// need to set as dehumidifier before setting validValues as defult of 0 will
|
|
45
|
-
// throw error when we state that only valid value is dehumidifier (2).
|
|
46
|
-
this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER);
|
|
47
|
-
this.service
|
|
48
|
-
.getCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState)
|
|
49
|
-
.onGet(this.getTargetHumidifierDehumidifierState.bind(this))
|
|
50
|
-
.onSet(this.setTargetHumidifierDehumidifierState.bind(this))
|
|
51
|
-
.setProps({
|
|
52
|
-
validValues: [this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER],
|
|
53
|
-
});
|
|
54
|
-
this.service
|
|
55
|
-
.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
|
|
56
|
-
.onGet(this.getCurrentRelativeHumidity.bind(this))
|
|
57
|
-
.setProps({
|
|
58
|
-
minValue: 0,
|
|
59
|
-
maxValue: 100,
|
|
60
|
-
minStep: 1,
|
|
61
|
-
});
|
|
62
|
-
this.service
|
|
63
|
-
.getCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold)
|
|
64
|
-
.onGet(this.getRelativeHumidityDehumidifierThreshold.bind(this))
|
|
65
|
-
.onSet(this.setRelativeHumidityDehumidifierThreshold.bind(this))
|
|
66
|
-
.setProps({
|
|
67
|
-
minValue: 0,
|
|
68
|
-
maxValue: 100,
|
|
69
|
-
minStep: 5,
|
|
70
|
-
});
|
|
71
|
-
this.service
|
|
72
|
-
.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
73
|
-
.onGet(this.getRotationSpeed.bind(this))
|
|
74
|
-
.onSet(this.setRotationSpeed.bind(this));
|
|
75
|
-
this.service.getCharacteristic(this.platform.Characteristic.WaterLevel).onGet(this.getWaterLevel.bind(this));
|
|
76
|
-
// Temperature sensor
|
|
77
|
-
this.temperatureService = this.accessory.getServiceById(this.platform.Service.TemperatureSensor, 'Temperature');
|
|
78
|
-
if (this.configDev.A1_options.temperatureSensor) {
|
|
79
|
-
|
|
80
|
-
this.temperatureService.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getTemperature.bind(this));
|
|
81
|
-
}
|
|
82
|
-
else if (this.temperatureService) {
|
|
83
|
-
this.accessory.removeService(this.temperatureService);
|
|
84
|
-
}
|
|
85
|
-
// Fan
|
|
86
|
-
this.fanService = this.accessory.getServiceById(this.platform.Service.Fanv2, 'Fan');
|
|
87
|
-
if (this.configDev.A1_options.fanAccessory) {
|
|
88
|
-
|
|
89
|
-
this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Fan`);
|
|
90
|
-
this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Fan`);
|
|
91
|
-
this.fanService
|
|
92
|
-
.getCharacteristic(this.platform.Characteristic.Active)
|
|
93
|
-
.onGet(this.getActive.bind(this))
|
|
94
|
-
.onSet(this.setActive.bind(this));
|
|
95
|
-
this.fanService
|
|
96
|
-
.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
97
|
-
.onGet(this.getRotationSpeed.bind(this))
|
|
98
|
-
.onSet(this.setRotationSpeed.bind(this));
|
|
99
|
-
}
|
|
100
|
-
else if (this.fanService) {
|
|
101
|
-
this.accessory.removeService(this.fanService);
|
|
102
|
-
}
|
|
103
|
-
// Humidity sensor
|
|
104
|
-
this.humiditySensorService = this.accessory.getServiceById(this.platform.Service.HumiditySensor, 'Humidity');
|
|
105
|
-
if (this.configDev.A1_options.humiditySensor) {
|
|
106
|
-
|
|
107
|
-
this.humiditySensorService
|
|
108
|
-
.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
|
|
109
|
-
.onGet(this.getCurrentRelativeHumidity.bind(this));
|
|
110
|
-
}
|
|
111
|
-
else if (this.humiditySensorService) {
|
|
112
|
-
this.accessory.removeService(this.humiditySensorService);
|
|
113
|
-
}
|
|
114
|
-
// Pump switch
|
|
115
|
-
this.pumpService = this.accessory.getServiceById(this.platform.Service.Switch, 'Pump');
|
|
116
|
-
if (this.configDev.A1_options.pumpSwitch) {
|
|
117
|
-
|
|
118
|
-
this.pumpService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Pump`);
|
|
119
|
-
this.pumpService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Pump`);
|
|
120
|
-
this.pumpService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getPump.bind(this)).onSet(this.setPump.bind(this));
|
|
121
|
-
}
|
|
122
|
-
else if (this.pumpService) {
|
|
123
|
-
this.accessory.removeService(this.pumpService);
|
|
124
|
-
}
|
|
125
|
-
this.waterTankService =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.waterTankService.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.waterTankService.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.waterTankService.setCharacteristic(this.platform.Characteristic.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
for (const [k, v] of Object.entries(attributes)) {
|
|
150
|
-
this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
|
|
151
|
-
let updateState = false;
|
|
152
|
-
switch (k.toLowerCase()) {
|
|
153
|
-
case 'power':
|
|
154
|
-
updateState = true;
|
|
155
|
-
break;
|
|
156
|
-
case 'target_humidity':
|
|
157
|
-
this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold, v);
|
|
158
|
-
updateState = true;
|
|
159
|
-
break;
|
|
160
|
-
case 'fan_speed':
|
|
161
|
-
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, v);
|
|
162
|
-
|
|
163
|
-
updateState = true;
|
|
164
|
-
break;
|
|
165
|
-
case 'current_humidity':
|
|
166
|
-
this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, v);
|
|
167
|
-
|
|
168
|
-
updateState = true;
|
|
169
|
-
break;
|
|
170
|
-
case 'mode':
|
|
171
|
-
updateState = true;
|
|
172
|
-
break;
|
|
173
|
-
case 'current_temperature':
|
|
174
|
-
|
|
175
|
-
break;
|
|
176
|
-
case 'tank_level':
|
|
177
|
-
this.service.updateCharacteristic(this.platform.Characteristic.WaterLevel, v);
|
|
178
|
-
break;
|
|
179
|
-
case 'pump':
|
|
180
|
-
|
|
181
|
-
break;
|
|
182
|
-
case 'tank_full':
|
|
183
|
-
if (this.configDev.A1_options.waterTankSensor ===
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
else if (this.configDev.A1_options.waterTankSensor ===
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
break;
|
|
190
|
-
case 'water_level_set':
|
|
191
|
-
// No HomeKit characteristic
|
|
192
|
-
break;
|
|
193
|
-
case 'swing':
|
|
194
|
-
// No HomeKit characteristic
|
|
195
|
-
break;
|
|
196
|
-
case 'child_lock':
|
|
197
|
-
// No HomeKit characteristic
|
|
198
|
-
break;
|
|
199
|
-
default:
|
|
200
|
-
this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
|
|
201
|
-
}
|
|
202
|
-
if (updateState) {
|
|
203
|
-
this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
|
|
204
|
-
this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER);
|
|
205
|
-
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, this.currentHumidifierDehumidifierState());
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/*********************************************************************
|
|
211
|
-
* Callback functions for each Homebridge/HomeKit service
|
|
212
|
-
*
|
|
213
|
-
*/
|
|
214
|
-
getActive() {
|
|
215
|
-
this.platform.log.debug(`[${this.device.name}] GET Active, value: ${this.device.attributes.POWER}`);
|
|
216
|
-
return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
|
|
217
|
-
}
|
|
218
|
-
async setActive(value) {
|
|
219
|
-
this.platform.log.debug(`[${this.device.name}] SET Active to: ${value}`);
|
|
220
|
-
await this.device.set_attribute({ POWER: !!value });
|
|
221
|
-
}
|
|
222
|
-
// Handle requests to get the current value of the "HumidifierDehumidifierState" characteristic
|
|
223
|
-
getCurrentHumidifierDehumidifierState() {
|
|
224
|
-
this.platform.log.debug(`[${this.device.name}] GET CurrentHumidifierDehumidifierState, value: ${this.device.attributes.POWER},${this.device.attributes.MODE}`);
|
|
225
|
-
return this.currentHumidifierDehumidifierState();
|
|
226
|
-
}
|
|
227
|
-
currentHumidifierDehumidifierState() {
|
|
228
|
-
if (!this.device.attributes.POWER) {
|
|
229
|
-
// Powered off, must be inactive
|
|
230
|
-
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
// Powered on, check mode
|
|
234
|
-
if (this.device.attributes.MODE >= 2) {
|
|
235
|
-
// Dehumidifying
|
|
236
|
-
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.DEHUMIDIFYING;
|
|
237
|
-
}
|
|
238
|
-
else if (this.device.attributes.MODE === 1) {
|
|
239
|
-
// Whether deumidifying depends on whether we have reached target. This is not
|
|
240
|
-
// always accurate, but is best we can do to signal whether actively dehumidifing or not.
|
|
241
|
-
if (this.device.attributes.CURRENT_HUMIDITY < this.device.attributes.TARGET_HUMIDITY) {
|
|
242
|
-
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.DEHUMIDIFYING;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
// Handle requests to get the target value of the "HumidifierDehumidifierState" characteristic
|
|
252
|
-
getTargetHumidifierDehumidifierState() {
|
|
253
|
-
this.platform.log.debug(
|
|
254
|
-
//
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
// Handle requests to get the current value of the "RelativeHumidity" characteristic
|
|
267
|
-
getCurrentRelativeHumidity() {
|
|
27
|
+
Upgrade from v${this.accessory.context.serviceVersion} to v${this.serviceVersion}.`);
|
|
28
|
+
this.accessory.removeService(service);
|
|
29
|
+
this.service = this.accessory.addService(this.platform.Service.HumidifierDehumidifier);
|
|
30
|
+
this.accessory.context.serviceVersion = this.serviceVersion;
|
|
31
|
+
}
|
|
32
|
+
else if (service) {
|
|
33
|
+
this.platform.log.debug(`[${this.device.name}] Existing dehumidifier service version.`);
|
|
34
|
+
this.service = service;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.platform.log.debug(`[${this.device.name}] Creating new dehumidifier service.`);
|
|
38
|
+
this.service = this.accessory.addService(this.platform.Service.HumidifierDehumidifier);
|
|
39
|
+
this.accessory.context.serviceVersion = this.serviceVersion;
|
|
40
|
+
}
|
|
41
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
|
|
42
|
+
this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
|
|
43
|
+
this.service
|
|
44
|
+
.getCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState)
|
|
45
|
+
.onGet(this.getCurrentHumidifierDehumidifierState.bind(this));
|
|
46
|
+
// need to set as dehumidifier before setting validValues as defult of 0 will
|
|
47
|
+
// throw error when we state that only valid value is dehumidifier (2).
|
|
48
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER);
|
|
49
|
+
this.service
|
|
50
|
+
.getCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState)
|
|
51
|
+
.onGet(this.getTargetHumidifierDehumidifierState.bind(this))
|
|
52
|
+
.onSet(this.setTargetHumidifierDehumidifierState.bind(this))
|
|
53
|
+
.setProps({
|
|
54
|
+
validValues: [this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER],
|
|
55
|
+
});
|
|
56
|
+
this.service
|
|
57
|
+
.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
|
|
58
|
+
.onGet(this.getCurrentRelativeHumidity.bind(this))
|
|
59
|
+
.setProps({
|
|
60
|
+
minValue: 0,
|
|
61
|
+
maxValue: 100,
|
|
62
|
+
minStep: 1,
|
|
63
|
+
});
|
|
64
|
+
this.service
|
|
65
|
+
.getCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold)
|
|
66
|
+
.onGet(this.getRelativeHumidityDehumidifierThreshold.bind(this))
|
|
67
|
+
.onSet(this.setRelativeHumidityDehumidifierThreshold.bind(this))
|
|
68
|
+
.setProps({
|
|
69
|
+
minValue: 0, // need this to be 0..100 so that Apple Home User Inteface humidity percent matched
|
|
70
|
+
maxValue: 100, // what we set to the himdifier. If we have this as 35..85 then Apple Home UI will not match.
|
|
71
|
+
minStep: 5,
|
|
72
|
+
});
|
|
73
|
+
this.service
|
|
74
|
+
.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
75
|
+
.onGet(this.getRotationSpeed.bind(this))
|
|
76
|
+
.onSet(this.setRotationSpeed.bind(this));
|
|
77
|
+
this.service.getCharacteristic(this.platform.Characteristic.WaterLevel).onGet(this.getWaterLevel.bind(this));
|
|
78
|
+
// Temperature sensor
|
|
79
|
+
this.temperatureService = this.accessory.getServiceById(this.platform.Service.TemperatureSensor, 'Temperature');
|
|
80
|
+
if (this.configDev.A1_options.temperatureSensor) {
|
|
81
|
+
this.temperatureService ??= this.accessory.addService(this.platform.Service.TemperatureSensor, 'Temperature', 'Temperature');
|
|
82
|
+
this.temperatureService.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getTemperature.bind(this));
|
|
83
|
+
}
|
|
84
|
+
else if (this.temperatureService) {
|
|
85
|
+
this.accessory.removeService(this.temperatureService);
|
|
86
|
+
}
|
|
87
|
+
// Fan
|
|
88
|
+
this.fanService = this.accessory.getServiceById(this.platform.Service.Fanv2, 'Fan');
|
|
89
|
+
if (this.configDev.A1_options.fanAccessory) {
|
|
90
|
+
this.fanService ??= this.accessory.addService(this.platform.Service.Fanv2, 'Fan', 'Fan');
|
|
91
|
+
this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Fan`);
|
|
92
|
+
this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Fan`);
|
|
93
|
+
this.fanService
|
|
94
|
+
.getCharacteristic(this.platform.Characteristic.Active)
|
|
95
|
+
.onGet(this.getActive.bind(this))
|
|
96
|
+
.onSet(this.setActive.bind(this));
|
|
97
|
+
this.fanService
|
|
98
|
+
.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
99
|
+
.onGet(this.getRotationSpeed.bind(this))
|
|
100
|
+
.onSet(this.setRotationSpeed.bind(this));
|
|
101
|
+
}
|
|
102
|
+
else if (this.fanService) {
|
|
103
|
+
this.accessory.removeService(this.fanService);
|
|
104
|
+
}
|
|
105
|
+
// Humidity sensor
|
|
106
|
+
this.humiditySensorService = this.accessory.getServiceById(this.platform.Service.HumiditySensor, 'Humidity');
|
|
107
|
+
if (this.configDev.A1_options.humiditySensor) {
|
|
108
|
+
this.humiditySensorService ??= this.accessory.addService(this.platform.Service.HumiditySensor, 'Humidity', 'Humidity');
|
|
109
|
+
this.humiditySensorService
|
|
110
|
+
.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
|
|
111
|
+
.onGet(this.getCurrentRelativeHumidity.bind(this));
|
|
112
|
+
}
|
|
113
|
+
else if (this.humiditySensorService) {
|
|
114
|
+
this.accessory.removeService(this.humiditySensorService);
|
|
115
|
+
}
|
|
116
|
+
// Pump switch
|
|
117
|
+
this.pumpService = this.accessory.getServiceById(this.platform.Service.Switch, 'Pump');
|
|
118
|
+
if (this.configDev.A1_options.pumpSwitch) {
|
|
119
|
+
this.pumpService ??= this.accessory.addService(this.platform.Service.Switch, 'Pump', 'Pump');
|
|
120
|
+
this.pumpService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Pump`);
|
|
121
|
+
this.pumpService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Pump`);
|
|
122
|
+
this.pumpService.getCharacteristic(this.platform.Characteristic.On).onGet(this.getPump.bind(this)).onSet(this.setPump.bind(this));
|
|
123
|
+
}
|
|
124
|
+
else if (this.pumpService) {
|
|
125
|
+
this.accessory.removeService(this.pumpService);
|
|
126
|
+
}
|
|
127
|
+
this.waterTankService =
|
|
128
|
+
this.accessory.getServiceById(this.platform.Service.ContactSensor, 'WaterTankContact') ??
|
|
129
|
+
this.accessory.getServiceById(this.platform.Service.LeakSensor, 'WaterTankLeak');
|
|
130
|
+
if (this.configDev.A1_options.waterTankSensor !== WaterTankSensor.NONE) {
|
|
131
|
+
if (this.configDev.A1_options.waterTankSensor === WaterTankSensor.CONTACT_SENSOR) {
|
|
132
|
+
this.waterTankService ??= this.accessory.addService(this.platform.Service.ContactSensor, `${this.device.name} Water Tank Sensor`, 'WaterTankContact');
|
|
133
|
+
this.waterTankService.getCharacteristic(this.platform.Characteristic.ContactSensorState).onGet(this.getWaterTankFull.bind(this));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.waterTankService ??= this.accessory.addService(this.platform.Service.LeakSensor, `${this.device.name} Water Tank Sensor`, 'WaterTankLeak');
|
|
137
|
+
this.waterTankService.getCharacteristic(this.platform.Characteristic.LeakDetected).onGet(this.getWaterTankFull.bind(this));
|
|
138
|
+
}
|
|
139
|
+
this.waterTankService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Water Tank Sensor`);
|
|
140
|
+
this.waterTankService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${this.device.name} Water Tank Sensor`);
|
|
141
|
+
}
|
|
142
|
+
else if (this.waterTankService) {
|
|
143
|
+
this.accessory.removeService(this.waterTankService);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/*********************************************************************
|
|
147
|
+
* Callback function called by MideaDevice whenever there is a change to
|
|
148
|
+
* any attribute value.
|
|
149
|
+
*/
|
|
150
|
+
async updateCharacteristics(attributes) {
|
|
151
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
152
|
+
this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
|
|
153
|
+
let updateState = false;
|
|
154
|
+
switch (k.toLowerCase()) {
|
|
155
|
+
case 'power':
|
|
156
|
+
updateState = true;
|
|
157
|
+
break;
|
|
158
|
+
case 'target_humidity':
|
|
159
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold, v);
|
|
160
|
+
updateState = true;
|
|
161
|
+
break;
|
|
162
|
+
case 'fan_speed':
|
|
163
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, v);
|
|
164
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, v);
|
|
165
|
+
updateState = true;
|
|
166
|
+
break;
|
|
167
|
+
case 'current_humidity':
|
|
168
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, v);
|
|
169
|
+
this.humiditySensorService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, v);
|
|
170
|
+
updateState = true;
|
|
171
|
+
break;
|
|
172
|
+
case 'mode':
|
|
173
|
+
updateState = true;
|
|
174
|
+
break;
|
|
175
|
+
case 'current_temperature':
|
|
176
|
+
this.temperatureService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, v);
|
|
177
|
+
break;
|
|
178
|
+
case 'tank_level':
|
|
179
|
+
this.service.updateCharacteristic(this.platform.Characteristic.WaterLevel, v);
|
|
180
|
+
break;
|
|
181
|
+
case 'pump':
|
|
182
|
+
this.pumpService?.updateCharacteristic(this.platform.Characteristic.On, v);
|
|
183
|
+
break;
|
|
184
|
+
case 'tank_full':
|
|
185
|
+
if (this.configDev.A1_options.waterTankSensor === WaterTankSensor.LEAK_SENSOR) {
|
|
186
|
+
this.waterTankService?.updateCharacteristic(this.platform.Characteristic.LeakDetected, v);
|
|
187
|
+
}
|
|
188
|
+
else if (this.configDev.A1_options.waterTankSensor === WaterTankSensor.CONTACT_SENSOR) {
|
|
189
|
+
this.waterTankService?.updateCharacteristic(this.platform.Characteristic.ContactSensorState, v);
|
|
190
|
+
}
|
|
191
|
+
break;
|
|
192
|
+
case 'water_level_set':
|
|
193
|
+
// No HomeKit characteristic
|
|
194
|
+
break;
|
|
195
|
+
case 'swing':
|
|
196
|
+
// No HomeKit characteristic
|
|
197
|
+
break;
|
|
198
|
+
case 'child_lock':
|
|
199
|
+
// No HomeKit characteristic
|
|
200
|
+
break;
|
|
201
|
+
default:
|
|
202
|
+
this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
|
|
203
|
+
}
|
|
204
|
+
if (updateState) {
|
|
205
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
|
|
206
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER);
|
|
207
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, this.currentHumidifierDehumidifierState());
|
|
208
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/*********************************************************************
|
|
213
|
+
* Callback functions for each Homebridge/HomeKit service
|
|
214
|
+
*
|
|
215
|
+
*/
|
|
216
|
+
getActive() {
|
|
217
|
+
this.platform.log.debug(`[${this.device.name}] GET Active, value: ${this.device.attributes.POWER}`);
|
|
218
|
+
return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
|
|
219
|
+
}
|
|
220
|
+
async setActive(value) {
|
|
221
|
+
this.platform.log.debug(`[${this.device.name}] SET Active to: ${value}`);
|
|
222
|
+
await this.device.set_attribute({ POWER: !!value });
|
|
223
|
+
}
|
|
224
|
+
// Handle requests to get the current value of the "HumidifierDehumidifierState" characteristic
|
|
225
|
+
getCurrentHumidifierDehumidifierState() {
|
|
226
|
+
this.platform.log.debug(`[${this.device.name}] GET CurrentHumidifierDehumidifierState, value: ${this.device.attributes.POWER},${this.device.attributes.MODE}`);
|
|
227
|
+
return this.currentHumidifierDehumidifierState();
|
|
228
|
+
}
|
|
229
|
+
currentHumidifierDehumidifierState() {
|
|
230
|
+
if (!this.device.attributes.POWER) {
|
|
231
|
+
// Powered off, must be inactive
|
|
232
|
+
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
// Powered on, check mode
|
|
236
|
+
if (this.device.attributes.MODE >= 2) {
|
|
237
|
+
// Dehumidifying
|
|
238
|
+
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.DEHUMIDIFYING;
|
|
239
|
+
}
|
|
240
|
+
else if (this.device.attributes.MODE === 1) {
|
|
241
|
+
// Whether deumidifying depends on whether we have reached target. This is not
|
|
242
|
+
// always accurate, but is best we can do to signal whether actively dehumidifing or not.
|
|
243
|
+
if (this.device.attributes.CURRENT_HUMIDITY < this.device.attributes.TARGET_HUMIDITY) {
|
|
244
|
+
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.DEHUMIDIFYING;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// Handle requests to get the target value of the "HumidifierDehumidifierState" characteristic
|
|
254
|
+
getTargetHumidifierDehumidifierState() {
|
|
255
|
+
this.platform.log.debug(`[${this.device.name}] GET TargetHumidifierDehumidifierState, value: ${this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER}`);
|
|
256
|
+
// Always return that we are a dehumidifier, other states not supported.
|
|
257
|
+
return this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER;
|
|
258
|
+
}
|
|
259
|
+
// Handle requests to set the target value of the "HumidifierDehumidifierState" characteristic
|
|
260
|
+
async setTargetHumidifierDehumidifierState(value) {
|
|
261
|
+
this.platform.log.debug(`[${this.device.name}] SET TargetHumidifierDehumidifierState to: ${value}`);
|
|
262
|
+
if (value !== this.platform.Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER) {
|
|
263
|
+
throw new Error(`Device ${this.device.name} (${this.device.id}) can only be a Dehumidifier, illegal value: ${value}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Handle requests to get the current value of the "RelativeHumidity" characteristic
|
|
267
|
+
getCurrentRelativeHumidity() {
|
|
268
268
|
this.platform.log.debug(`[${this.device.name}] GET CurrentRelativeHumidity, value: ${this.device.attributes.CURRENT_HUMIDITY},\
|
|
269
|
-
custom offset: ${this.configDev.A1_options.humidityOffset}`);
|
|
270
|
-
// Adding custom offset to the humidity value
|
|
271
|
-
return this.device.attributes.CURRENT_HUMIDITY + this.configDev.A1_options.humidityOffset;
|
|
272
|
-
}
|
|
273
|
-
// Handle requests to get the Relative value of the "HumidityDehumidifierThreshold" characteristic
|
|
274
|
-
getRelativeHumidityDehumidifierThreshold() {
|
|
275
|
-
this.platform.log.debug(`[${this.device.name}] GET RelativeHumidityDehumidifierThreshold, value: ${this.device.attributes.TARGET_HUMIDITY}`);
|
|
276
|
-
return this.device.attributes.TARGET_HUMIDITY;
|
|
277
|
-
}
|
|
278
|
-
// Handle requests to set the Relative value of the "HumidityDehumidifierThreshold" characteristic
|
|
279
|
-
async setRelativeHumidityDehumidifierThreshold(value) {
|
|
280
|
-
let RequestedHumidity = value;
|
|
281
|
-
// valid humidity has to be between min and max values
|
|
282
|
-
RequestedHumidity =
|
|
283
|
-
RequestedHumidity < this.device.MIN_HUMIDITY
|
|
284
|
-
? this.device.MIN_HUMIDITY
|
|
285
|
-
: RequestedHumidity > this.device.MAX_HUMIDITY
|
|
286
|
-
? this.device.MAX_HUMIDITY
|
|
287
|
-
: RequestedHumidity;
|
|
288
|
-
this.platform.log.debug(`[${this.device.name}] SET RelativeHumidityDehumidifierThreshold to: ${RequestedHumidity} (${value})`);
|
|
289
|
-
await this.device.set_attribute({ TARGET_HUMIDITY: RequestedHumidity });
|
|
290
|
-
// Update HomeKit in case we adjusted the value outside of min and max values
|
|
291
|
-
if (RequestedHumidity !== value) {
|
|
292
|
-
// We had to adjust the requested value to within permitted range... Update homekit to actual value set.
|
|
293
|
-
// Calling updateCharacteristic within set handler seems to fail, new value is not accepted. Workaround is
|
|
294
|
-
// to request the update after short delay (say 50ms) to allow homebridge/homekit to complete the set handler.
|
|
295
|
-
setTimeout(() => {
|
|
296
|
-
this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold, RequestedHumidity);
|
|
297
|
-
}, 50);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
// Handle requests to get the current value of the "RotationSpeed" characteristic
|
|
301
|
-
getRotationSpeed() {
|
|
302
|
-
this.platform.log.debug(`[${this.device.name}] GET RotationSpeed, value: ${this.device.attributes.FAN_SPEED}`);
|
|
303
|
-
return this.device.attributes.FAN_SPEED;
|
|
304
|
-
}
|
|
305
|
-
// Handle requests to set the "RotationSpeed" characteristic
|
|
306
|
-
async setRotationSpeed(value) {
|
|
307
|
-
let speed = value;
|
|
308
|
-
speed = speed <= 40 ? 40 : speed > 40 && speed <= 60 ? 60 : 80;
|
|
309
|
-
this.platform.log.debug(`[${this.device.name}] SET RotationSpeed to: ${speed} (${value})`);
|
|
310
|
-
await this.device.set_attribute({ FAN_SPEED: speed });
|
|
311
|
-
if (speed !== value) {
|
|
312
|
-
// We had to adjust the requested value to within permitted range... Update homekit to actual value set.
|
|
313
|
-
// Calling updateCharacteristic within set handler seems to fail, new value is not accepted. Workaround is
|
|
314
|
-
// to request the update after short delay (say 50ms) to allow homebridge/homekit to complete the set handler.
|
|
315
|
-
setTimeout(() => {
|
|
316
|
-
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, speed);
|
|
317
|
-
}, 50);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
// Handle requests to get the current value of the "WaterLevel" characteristic
|
|
321
|
-
getWaterLevel() {
|
|
322
|
-
this.platform.log.debug(`[${this.device.name}] GET WaterLevel, value: ${this.device.attributes.TANK_LEVEL}`);
|
|
323
|
-
return this.device.attributes.TANK_LEVEL;
|
|
324
|
-
}
|
|
325
|
-
// Handle requests to get the current value of the "Pump" characteristic
|
|
326
|
-
getTemperature() {
|
|
327
|
-
this.platform.log.debug(`[${this.device.name}] GET Temperature, value: ${this.device.attributes.CURRENT_TEMPERATURE}`);
|
|
328
|
-
return this.device.attributes.CURRENT_TEMPERATURE;
|
|
329
|
-
}
|
|
330
|
-
// Handle requests to get the current value of the "Pump" characteristic
|
|
331
|
-
getPump() {
|
|
332
|
-
this.platform.log.debug(`[${this.device.name}] GET Pump, value: ${this.device.attributes.PUMP}`);
|
|
333
|
-
return this.device.attributes.POWER === true && this.device.attributes.PUMP;
|
|
334
|
-
}
|
|
335
|
-
// Handle requests to set the "Pump" characteristic
|
|
336
|
-
async setPump(value) {
|
|
337
|
-
this.platform.log.debug(`[${this.device.name}] SET Pump to: ${value}`);
|
|
338
|
-
await this.device.set_attribute({ PUMP: !!value });
|
|
339
|
-
}
|
|
340
|
-
// Handle requests to get the current value of the "WaterTankFull" characteristic
|
|
341
|
-
getWaterTankFull() {
|
|
342
|
-
this.platform.log.debug(`[${this.device.name}] GET WaterTankFull, value: ${this.device.attributes.TANK_FULL}`);
|
|
343
|
-
return this.device.attributes.TANK_FULL;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
exports.default = DehumidifierAccessory;
|
|
269
|
+
custom offset: ${this.configDev.A1_options.humidityOffset}`);
|
|
270
|
+
// Adding custom offset to the humidity value
|
|
271
|
+
return this.device.attributes.CURRENT_HUMIDITY + this.configDev.A1_options.humidityOffset;
|
|
272
|
+
}
|
|
273
|
+
// Handle requests to get the Relative value of the "HumidityDehumidifierThreshold" characteristic
|
|
274
|
+
getRelativeHumidityDehumidifierThreshold() {
|
|
275
|
+
this.platform.log.debug(`[${this.device.name}] GET RelativeHumidityDehumidifierThreshold, value: ${this.device.attributes.TARGET_HUMIDITY}`);
|
|
276
|
+
return this.device.attributes.TARGET_HUMIDITY;
|
|
277
|
+
}
|
|
278
|
+
// Handle requests to set the Relative value of the "HumidityDehumidifierThreshold" characteristic
|
|
279
|
+
async setRelativeHumidityDehumidifierThreshold(value) {
|
|
280
|
+
let RequestedHumidity = value;
|
|
281
|
+
// valid humidity has to be between min and max values
|
|
282
|
+
RequestedHumidity =
|
|
283
|
+
RequestedHumidity < this.device.MIN_HUMIDITY
|
|
284
|
+
? this.device.MIN_HUMIDITY
|
|
285
|
+
: RequestedHumidity > this.device.MAX_HUMIDITY
|
|
286
|
+
? this.device.MAX_HUMIDITY
|
|
287
|
+
: RequestedHumidity;
|
|
288
|
+
this.platform.log.debug(`[${this.device.name}] SET RelativeHumidityDehumidifierThreshold to: ${RequestedHumidity} (${value})`);
|
|
289
|
+
await this.device.set_attribute({ TARGET_HUMIDITY: RequestedHumidity });
|
|
290
|
+
// Update HomeKit in case we adjusted the value outside of min and max values
|
|
291
|
+
if (RequestedHumidity !== value) {
|
|
292
|
+
// We had to adjust the requested value to within permitted range... Update homekit to actual value set.
|
|
293
|
+
// Calling updateCharacteristic within set handler seems to fail, new value is not accepted. Workaround is
|
|
294
|
+
// to request the update after short delay (say 50ms) to allow homebridge/homekit to complete the set handler.
|
|
295
|
+
setTimeout(() => {
|
|
296
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityDehumidifierThreshold, RequestedHumidity);
|
|
297
|
+
}, 50);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Handle requests to get the current value of the "RotationSpeed" characteristic
|
|
301
|
+
getRotationSpeed() {
|
|
302
|
+
this.platform.log.debug(`[${this.device.name}] GET RotationSpeed, value: ${this.device.attributes.FAN_SPEED}`);
|
|
303
|
+
return this.device.attributes.FAN_SPEED;
|
|
304
|
+
}
|
|
305
|
+
// Handle requests to set the "RotationSpeed" characteristic
|
|
306
|
+
async setRotationSpeed(value) {
|
|
307
|
+
let speed = value;
|
|
308
|
+
speed = speed <= 40 ? 40 : speed > 40 && speed <= 60 ? 60 : 80;
|
|
309
|
+
this.platform.log.debug(`[${this.device.name}] SET RotationSpeed to: ${speed} (${value})`);
|
|
310
|
+
await this.device.set_attribute({ FAN_SPEED: speed });
|
|
311
|
+
if (speed !== value) {
|
|
312
|
+
// We had to adjust the requested value to within permitted range... Update homekit to actual value set.
|
|
313
|
+
// Calling updateCharacteristic within set handler seems to fail, new value is not accepted. Workaround is
|
|
314
|
+
// to request the update after short delay (say 50ms) to allow homebridge/homekit to complete the set handler.
|
|
315
|
+
setTimeout(() => {
|
|
316
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, speed);
|
|
317
|
+
}, 50);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
// Handle requests to get the current value of the "WaterLevel" characteristic
|
|
321
|
+
getWaterLevel() {
|
|
322
|
+
this.platform.log.debug(`[${this.device.name}] GET WaterLevel, value: ${this.device.attributes.TANK_LEVEL}`);
|
|
323
|
+
return this.device.attributes.TANK_LEVEL;
|
|
324
|
+
}
|
|
325
|
+
// Handle requests to get the current value of the "Pump" characteristic
|
|
326
|
+
getTemperature() {
|
|
327
|
+
this.platform.log.debug(`[${this.device.name}] GET Temperature, value: ${this.device.attributes.CURRENT_TEMPERATURE}`);
|
|
328
|
+
return this.device.attributes.CURRENT_TEMPERATURE;
|
|
329
|
+
}
|
|
330
|
+
// Handle requests to get the current value of the "Pump" characteristic
|
|
331
|
+
getPump() {
|
|
332
|
+
this.platform.log.debug(`[${this.device.name}] GET Pump, value: ${this.device.attributes.PUMP}`);
|
|
333
|
+
return this.device.attributes.POWER === true && this.device.attributes.PUMP;
|
|
334
|
+
}
|
|
335
|
+
// Handle requests to set the "Pump" characteristic
|
|
336
|
+
async setPump(value) {
|
|
337
|
+
this.platform.log.debug(`[${this.device.name}] SET Pump to: ${value}`);
|
|
338
|
+
await this.device.set_attribute({ PUMP: !!value });
|
|
339
|
+
}
|
|
340
|
+
// Handle requests to get the current value of the "WaterTankFull" characteristic
|
|
341
|
+
getWaterTankFull() {
|
|
342
|
+
this.platform.log.debug(`[${this.device.name}] GET WaterTankFull, value: ${this.device.attributes.TANK_FULL}`);
|
|
343
|
+
return this.device.attributes.TANK_FULL;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
347
346
|
//# sourceMappingURL=DehumidifierAccessory.js.map
|