homebridge-melcloud-control 4.10.20-beta.3 → 4.10.20-beta.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.10.20-beta.3",
4
+ "version": "4.10.20-beta.5",
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
@@ -319,14 +319,6 @@ class DeviceAta extends EventEmitter {
319
319
  const max = numberOfFanSpeeds;
320
320
  const minValue = supportsAutomaticFanSpeed ? 0 : 1;
321
321
  const clampedValue = Math.min(Math.max(value, minValue), max);
322
-
323
- //Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
324
- //Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
325
- if (!this.accessory.power && this.accessory.currentFanSpeed === 0 && clampedValue !== 0) {
326
- if (this.logDebug) this.emit('debug', `Ignore set fan speed while powering on from Auto: ${clampedValue}`);
327
- return;
328
- }
329
-
330
322
  const payload = { setFanSpeed: clampedValue };
331
323
  if (this.logInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeedMapEnumToString[clampedValue]}`);
332
324
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, payload, AirConditioner.EffectiveFlags.SetFanSpeed);
package/src/deviceerv.js CHANGED
@@ -282,14 +282,6 @@ class DeviceErv extends EventEmitter {
282
282
  const max = numberOfFanSpeeds;
283
283
  const minValue = supportsAutomaticFanSpeed ? 0 : 1;
284
284
  const clampedValue = Math.min(Math.max(value, minValue), max);
285
-
286
- //Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
287
- //Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
288
- if (!this.accessory.power && this.accessory.currentFanSpeed === 0 && clampedValue !== 0) {
289
- if (this.logDebug) this.emit('debug', `Ignore set fan speed while powering on from Auto: ${clampedValue}`);
290
- return;
291
- }
292
-
293
285
  const payload = { setFanSpeed: clampedValue };
294
286
  if (this.logInfo) this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeedMapEnumToString[clampedValue]}`);
295
287
  await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, Ventilation.EffectiveFlags.SetFanSpeed);
@@ -210,6 +210,26 @@ class MelCloudAta extends EventEmitter {
210
210
  default: {
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
+
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
+ //Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
223
+ //Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
224
+ if (changes.setFanSpeed !== undefined && changes.setFanSpeed !== 0 && this.deviceData.Device.Power === false && this.deviceData.Device.SetFanSpeed === 0) {
225
+ delete changes.setFanSpeed;
226
+ }
227
+
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
+
213
233
  if (Object.keys(changes).length === 0) {
214
234
  if (this.logDebug) this.emit('debug', `Ignore send, no changes: ${JSON.stringify(payload)}`);
215
235
  return true;
@@ -311,6 +331,26 @@ class MelCloudAta extends EventEmitter {
311
331
  default: {
312
332
  //compare against the API wrapper's own live-polled state, not the caller's closure-captured (possibly stale) deviceData
313
333
  const changes = this.functions.filterChanges(payload, this.deviceData.Device);
334
+
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
+ //Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
344
+ //Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
345
+ if (changes.setFanSpeed !== undefined && changes.setFanSpeed !== 0 && this.deviceData.Device.Power === false && this.deviceData.Device.SetFanSpeed === 0) {
346
+ delete changes.setFanSpeed;
347
+ }
348
+
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
+
314
354
  if (Object.keys(changes).length === 0) {
315
355
  if (this.logDebug) this.emit('debug', `Ignore send, no changes: ${JSON.stringify(payload)}`);
316
356
  return true;
@@ -185,6 +185,26 @@ class MelCloudErv extends EventEmitter {
185
185
  default: {
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
+
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
+ //Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
198
+ //Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
199
+ if (changes.setFanSpeed !== undefined && changes.setFanSpeed !== 0 && this.deviceData.Device.Power === false && this.deviceData.Device.SetFanSpeed === 0) {
200
+ delete changes.setFanSpeed;
201
+ }
202
+
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
+
188
208
  if (Object.keys(changes).length === 0) {
189
209
  if (this.logDebug) this.emit('debug', `Ignore send, no changes: ${JSON.stringify(payload)}`);
190
210
  return true;
@@ -276,6 +296,26 @@ class MelCloudErv extends EventEmitter {
276
296
  default: {
277
297
  //compare against the API wrapper's own live-polled state, not the caller's closure-captured (possibly stale) deviceData
278
298
  const changes = this.functions.filterChanges(payload, this.deviceData.Device);
299
+
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
+ //Apple Home always resends its own remembered (non-zero) fan speed together with Active when powering on from off
309
+ //Auto (0) can't be represented on that dial, so ignore this phantom value while the unit is off and currently in Auto
310
+ if (changes.setFanSpeed !== undefined && changes.setFanSpeed !== 0 && this.deviceData.Device.Power === false && this.deviceData.Device.SetFanSpeed === 0) {
311
+ delete changes.setFanSpeed;
312
+ }
313
+
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
+
279
319
  if (Object.keys(changes).length === 0) {
280
320
  if (this.logDebug) this.emit('debug', `Ignore send, no changes: ${JSON.stringify(payload)}`);
281
321
  return true;