homebridge-melcloud-control 4.10.10-beta.0 → 4.10.10

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.10-beta.0",
4
+ "version": "4.10.10",
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
@@ -1647,7 +1647,7 @@ class DeviceAta extends EventEmitter {
1647
1647
  if (supportsFanSpeed) {
1648
1648
  // ograniczamy wartość do zakresu API
1649
1649
  const minValue = supportsAutomaticFanSpeed ? 0 : 1;
1650
- const maxValue = max;
1650
+ const maxValue = numberOfFanSpeeds;
1651
1651
 
1652
1652
  // zabezpieczenie przed out-of-bounds
1653
1653
  const clampedValue = Math.min(Math.max(setFanSpeed, minValue), maxValue);
package/src/deviceerv.js CHANGED
@@ -348,7 +348,7 @@ class DeviceErv extends EventEmitter {
348
348
  .setProps({
349
349
  minValue: this.accessory.fanSpeedSetPropsMinValue,
350
350
  maxValue: this.accessory.fanSpeedSetPropsMaxValue,
351
- minStep: this.accessory.fanSpeedSetPropsMinStep
351
+ minStep: 1
352
352
  })
353
353
  .onGet(async () => {
354
354
  const value = this.accessory.fanSpeed;
@@ -358,12 +358,11 @@ class DeviceErv extends EventEmitter {
358
358
  try {
359
359
  const payload = {};
360
360
  const max = numberOfFanSpeeds;
361
- const minFanSpeed = supportsAutomaticFanSpeed ? 0 : 1;
362
- // Reverse-map from 0-100 HomeKit scale to raw fan speed level
363
- const rawFanSpeed = value === 0 ? 0 : Math.max(minFanSpeed, Math.min(max, Math.round((value / 100) * max)));
361
+ const minValue = supportsAutomaticFanSpeed ? 0 : 1;
362
+ const clampedValue = Math.min(Math.max(value, minValue), max);
364
363
 
365
- payload.setFanSpeed = rawFanSpeed;
366
- if (this.logInfo) this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeedMapEnumToString[rawFanSpeed]}`);
364
+ payload.setFanSpeed = clampedValue;
365
+ if (this.logInfo) this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeedMapEnumToString[clampedValue]}`);
367
366
  await this.melCloudErv.send(this.accountType, this.displayType, deviceData, payload, Ventilation.EffectiveFlags.SetFanSpeed);
368
367
  } catch (error) {
369
368
  if (this.logWarn) this.emit('warn', `Set fan speed mode error: ${error}`);
@@ -1274,16 +1273,16 @@ class DeviceErv extends EventEmitter {
1274
1273
 
1275
1274
  //fan speed mode
1276
1275
  if (supportsFanSpeed) {
1277
- const max = numberOfFanSpeeds;
1278
- const minRaw = supportsAutomaticFanSpeed ? 0 : 1;
1279
- const rawFanSpeed = Math.min(Math.max(setFanSpeed, minRaw), max);
1280
- // Scale raw fan speed to 0-100 HomeKit range
1281
- const scaledFanSpeed = rawFanSpeed === 0 ? 0 : Math.round((rawFanSpeed / max) * 100);
1282
-
1283
- obj.fanSpeed = scaledFanSpeed;
1284
- obj.fanSpeedSetPropsMinValue = 0;
1285
- obj.fanSpeedSetPropsMaxValue = 100;
1286
- obj.fanSpeedSetPropsMinStep = Math.round(100 / max);
1276
+ // ograniczamy wartość do zakresu API
1277
+ const minValue = supportsAutomaticFanSpeed ? 0 : 1;
1278
+ const maxValue = numberOfFanSpeeds;
1279
+
1280
+ // zabezpieczenie przed out-of-bounds
1281
+ const clampedValue = Math.min(Math.max(setFanSpeed, minValue), maxValue);
1282
+
1283
+ obj.currentFanSpeed = clampedValue;
1284
+ obj.fanSpeedSetPropsMinValue = minValue;
1285
+ obj.fanSpeedSetPropsMaxValue = maxValue;
1287
1286
  }
1288
1287
 
1289
1288
  //create characteristics