homebridge-melcloud-control 4.10.20-beta.5 → 4.10.20-beta.6
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/package.json +1 -1
- package/src/deviceata.js +15 -12
- package/src/deviceerv.js +15 -12
- package/src/melcloudata.js +0 -26
- package/src/melclouderv.js +0 -26
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.10.20-beta.
|
|
4
|
+
"version": "4.10.20-beta.6",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/deviceata.js
CHANGED
|
@@ -316,9 +316,12 @@ class DeviceAta extends EventEmitter {
|
|
|
316
316
|
})
|
|
317
317
|
.onSet(async (value) => {
|
|
318
318
|
try {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
319
|
+
//0 is the dial's floor, paired by HomeKit itself with Active going false; nothing to send, real speeds start at 1
|
|
320
|
+
if (value === 0) return;
|
|
321
|
+
|
|
322
|
+
//Auto sits at the top slot, past the highest real speed
|
|
323
|
+
const isAutoSlot = supportsAutomaticFanSpeed && value >= numberOfFanSpeeds + 1;
|
|
324
|
+
const clampedValue = isAutoSlot ? 0 : Math.min(Math.max(value, 1), numberOfFanSpeeds);
|
|
322
325
|
const payload = { setFanSpeed: clampedValue };
|
|
323
326
|
if (this.logInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeedMapEnumToString[clampedValue]}`);
|
|
324
327
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, AirConditioner.EffectiveFlags.SetFanSpeed);
|
|
@@ -1568,15 +1571,15 @@ class DeviceAta extends EventEmitter {
|
|
|
1568
1571
|
|
|
1569
1572
|
//fan speed mode
|
|
1570
1573
|
if (supportsFanSpeed) {
|
|
1571
|
-
//
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
obj.fanSpeedSetPropsMinValue =
|
|
1574
|
+
//0 is the dial's floor (paired with off), never sent as a real speed; Auto sits at the top slot past the highest real speed
|
|
1575
|
+
const maxValue = supportsAutomaticFanSpeed ? numberOfFanSpeeds + 1 : numberOfFanSpeeds;
|
|
1576
|
+
//if the device somehow reports Auto (0) while not actually supporting it, fall through to the normal clamp (never display 0, that's reserved for off)
|
|
1577
|
+
const isAuto = setFanSpeed === 0 && supportsAutomaticFanSpeed;
|
|
1578
|
+
|
|
1579
|
+
obj.currentFanSpeed = isAuto
|
|
1580
|
+
? maxValue
|
|
1581
|
+
: Math.min(Math.max(setFanSpeed, 1), numberOfFanSpeeds);
|
|
1582
|
+
obj.fanSpeedSetPropsMinValue = 0;
|
|
1580
1583
|
obj.fanSpeedSetPropsMaxValue = maxValue;
|
|
1581
1584
|
}
|
|
1582
1585
|
|
package/src/deviceerv.js
CHANGED
|
@@ -279,9 +279,12 @@ class DeviceErv extends EventEmitter {
|
|
|
279
279
|
})
|
|
280
280
|
.onSet(async (value) => {
|
|
281
281
|
try {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
282
|
+
//0 is the dial's floor, paired by HomeKit itself with Active going false; nothing to send, real speeds start at 1
|
|
283
|
+
if (value === 0) return;
|
|
284
|
+
|
|
285
|
+
//Auto sits at the top slot, past the highest real speed
|
|
286
|
+
const isAutoSlot = supportsAutomaticFanSpeed && value >= numberOfFanSpeeds + 1;
|
|
287
|
+
const clampedValue = isAutoSlot ? 0 : Math.min(Math.max(value, 1), numberOfFanSpeeds);
|
|
285
288
|
const payload = { setFanSpeed: clampedValue };
|
|
286
289
|
if (this.logInfo) this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeedMapEnumToString[clampedValue]}`);
|
|
287
290
|
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, Ventilation.EffectiveFlags.SetFanSpeed);
|
|
@@ -1191,15 +1194,15 @@ class DeviceErv extends EventEmitter {
|
|
|
1191
1194
|
|
|
1192
1195
|
//fan speed mode
|
|
1193
1196
|
if (supportsFanSpeed) {
|
|
1194
|
-
//
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
obj.fanSpeedSetPropsMinValue =
|
|
1197
|
+
//0 is the dial's floor (paired with off), never sent as a real speed; Auto sits at the top slot past the highest real speed
|
|
1198
|
+
const maxValue = supportsAutomaticFanSpeed ? numberOfFanSpeeds + 1 : numberOfFanSpeeds;
|
|
1199
|
+
//if the device somehow reports Auto (0) while not actually supporting it, fall through to the normal clamp (never display 0, that's reserved for off)
|
|
1200
|
+
const isAuto = setFanSpeed === 0 && supportsAutomaticFanSpeed;
|
|
1201
|
+
|
|
1202
|
+
obj.currentFanSpeed = isAuto
|
|
1203
|
+
? maxValue
|
|
1204
|
+
: Math.min(Math.max(setFanSpeed, 1), numberOfFanSpeeds);
|
|
1205
|
+
obj.fanSpeedSetPropsMinValue = 0;
|
|
1203
1206
|
obj.fanSpeedSetPropsMaxValue = maxValue;
|
|
1204
1207
|
}
|
|
1205
1208
|
|
package/src/melcloudata.js
CHANGED
|
@@ -211,25 +211,12 @@ class MelCloudAta extends EventEmitter {
|
|
|
211
211
|
//compare against the API wrapper's own live-polled state, not the caller's closure-captured (possibly stale) deviceData
|
|
212
212
|
const changes = this.functions.filterChanges(payload, this.deviceData.Device);
|
|
213
213
|
|
|
214
|
-
//the combined HomeKit dial sends a companion power-off whenever RotationSpeed is dragged to 0 (Auto);
|
|
215
|
-
//ignore that companion since setting Auto while the unit is on should not turn it off
|
|
216
|
-
if (this.deviceData.Device.Power === true && changes.power === false && this.ignoreNextPowerOffUntil && Date.now() < this.ignoreNextPowerOffUntil) {
|
|
217
|
-
delete changes.power;
|
|
218
|
-
this.ignoreNextPowerOffUntil = 0;
|
|
219
|
-
if (this.logDebug) this.emit('debug', `Ignore power off, follows Auto fan speed set while unit was on`);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
214
|
//Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
|
|
223
215
|
//Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
|
|
224
216
|
if (changes.setFanSpeed !== undefined && changes.setFanSpeed !== 0 && this.deviceData.Device.Power === false && this.deviceData.Device.SetFanSpeed === 0) {
|
|
225
217
|
delete changes.setFanSpeed;
|
|
226
218
|
}
|
|
227
219
|
|
|
228
|
-
//remember Auto was just selected while the unit was on, so the companion power-off can be recognized above
|
|
229
|
-
if (changes.setFanSpeed === 0 && this.deviceData.Device.Power === true) {
|
|
230
|
-
this.ignoreNextPowerOffUntil = Date.now() + 1000;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
220
|
if (Object.keys(changes).length === 0) {
|
|
234
221
|
if (this.logDebug) this.emit('debug', `Ignore send, no changes: ${JSON.stringify(payload)}`);
|
|
235
222
|
return true;
|
|
@@ -332,25 +319,12 @@ class MelCloudAta extends EventEmitter {
|
|
|
332
319
|
//compare against the API wrapper's own live-polled state, not the caller's closure-captured (possibly stale) deviceData
|
|
333
320
|
const changes = this.functions.filterChanges(payload, this.deviceData.Device);
|
|
334
321
|
|
|
335
|
-
//the combined HomeKit dial sends a companion power-off whenever RotationSpeed is dragged to 0 (Auto);
|
|
336
|
-
//ignore that companion since setting Auto while the unit is on should not turn it off
|
|
337
|
-
if (this.deviceData.Device.Power === true && changes.power === false && this.ignoreNextPowerOffUntil && Date.now() < this.ignoreNextPowerOffUntil) {
|
|
338
|
-
delete changes.power;
|
|
339
|
-
this.ignoreNextPowerOffUntil = 0;
|
|
340
|
-
if (this.logDebug) this.emit('debug', `Ignore power off, follows Auto fan speed set while unit was on`);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
322
|
//Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
|
|
344
323
|
//Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
|
|
345
324
|
if (changes.setFanSpeed !== undefined && changes.setFanSpeed !== 0 && this.deviceData.Device.Power === false && this.deviceData.Device.SetFanSpeed === 0) {
|
|
346
325
|
delete changes.setFanSpeed;
|
|
347
326
|
}
|
|
348
327
|
|
|
349
|
-
//remember Auto was just selected while the unit was on, so the companion power-off can be recognized above
|
|
350
|
-
if (changes.setFanSpeed === 0 && this.deviceData.Device.Power === true) {
|
|
351
|
-
this.ignoreNextPowerOffUntil = Date.now() + 1000;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
328
|
if (Object.keys(changes).length === 0) {
|
|
355
329
|
if (this.logDebug) this.emit('debug', `Ignore send, no changes: ${JSON.stringify(payload)}`);
|
|
356
330
|
return true;
|
package/src/melclouderv.js
CHANGED
|
@@ -186,25 +186,12 @@ class MelCloudErv extends EventEmitter {
|
|
|
186
186
|
//compare against the API wrapper's own live-polled state, not the caller's closure-captured (possibly stale) deviceData
|
|
187
187
|
const changes = this.functions.filterChanges(payload, this.deviceData.Device);
|
|
188
188
|
|
|
189
|
-
//the combined HomeKit dial sends a companion power-off whenever RotationSpeed is dragged to 0 (Auto);
|
|
190
|
-
//ignore that companion since setting Auto while the unit is on should not turn it off
|
|
191
|
-
if (this.deviceData.Device.Power === true && changes.power === false && this.ignoreNextPowerOffUntil && Date.now() < this.ignoreNextPowerOffUntil) {
|
|
192
|
-
delete changes.power;
|
|
193
|
-
this.ignoreNextPowerOffUntil = 0;
|
|
194
|
-
if (this.logDebug) this.emit('debug', `Ignore power off, follows Auto fan speed set while unit was on`);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
189
|
//Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
|
|
198
190
|
//Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
|
|
199
191
|
if (changes.setFanSpeed !== undefined && changes.setFanSpeed !== 0 && this.deviceData.Device.Power === false && this.deviceData.Device.SetFanSpeed === 0) {
|
|
200
192
|
delete changes.setFanSpeed;
|
|
201
193
|
}
|
|
202
194
|
|
|
203
|
-
//remember Auto was just selected while the unit was on, so the companion power-off can be recognized above
|
|
204
|
-
if (changes.setFanSpeed === 0 && this.deviceData.Device.Power === true) {
|
|
205
|
-
this.ignoreNextPowerOffUntil = Date.now() + 1000;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
195
|
if (Object.keys(changes).length === 0) {
|
|
209
196
|
if (this.logDebug) this.emit('debug', `Ignore send, no changes: ${JSON.stringify(payload)}`);
|
|
210
197
|
return true;
|
|
@@ -297,25 +284,12 @@ class MelCloudErv extends EventEmitter {
|
|
|
297
284
|
//compare against the API wrapper's own live-polled state, not the caller's closure-captured (possibly stale) deviceData
|
|
298
285
|
const changes = this.functions.filterChanges(payload, this.deviceData.Device);
|
|
299
286
|
|
|
300
|
-
//the combined HomeKit dial sends a companion power-off whenever RotationSpeed is dragged to 0 (Auto);
|
|
301
|
-
//ignore that companion since setting Auto while the unit is on should not turn it off
|
|
302
|
-
if (this.deviceData.Device.Power === true && changes.power === false && this.ignoreNextPowerOffUntil && Date.now() < this.ignoreNextPowerOffUntil) {
|
|
303
|
-
delete changes.power;
|
|
304
|
-
this.ignoreNextPowerOffUntil = 0;
|
|
305
|
-
if (this.logDebug) this.emit('debug', `Ignore power off, follows Auto fan speed set while unit was on`);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
287
|
//Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
|
|
309
288
|
//Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
|
|
310
289
|
if (changes.setFanSpeed !== undefined && changes.setFanSpeed !== 0 && this.deviceData.Device.Power === false && this.deviceData.Device.SetFanSpeed === 0) {
|
|
311
290
|
delete changes.setFanSpeed;
|
|
312
291
|
}
|
|
313
292
|
|
|
314
|
-
//remember Auto was just selected while the unit was on, so the companion power-off can be recognized above
|
|
315
|
-
if (changes.setFanSpeed === 0 && this.deviceData.Device.Power === true) {
|
|
316
|
-
this.ignoreNextPowerOffUntil = Date.now() + 1000;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
293
|
if (Object.keys(changes).length === 0) {
|
|
320
294
|
if (this.logDebug) this.emit('debug', `Ignore send, no changes: ${JSON.stringify(payload)}`);
|
|
321
295
|
return true;
|