diff --git a/CHANGELOG.md b/CHANGELOG.md index 0417ff3..78399d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - do not configure it manually, always using Config UI X - required Homebridge v2.0.0 and above +## [3.1.2] - (31.08.2024) + +## Changes + +- fix presets configured array + ## [3.1.0] - (31.08.2024) ## Changes diff --git a/package.json b/package.json index 8cf5dc1..71fe81c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "MELCloud Control", "name": "homebridge-melcloud-control", - "version": "3.1.1", + "version": "3.1.2", "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.", "license": "MIT", "author": "grzegorz914", diff --git a/src/deviceata.js b/src/deviceata.js index 53baa9e..2d63cbe 100644 --- a/src/deviceata.js +++ b/src/deviceata.js @@ -20,7 +20,6 @@ class DeviceAta extends EventEmitter { this.displayMode = device.displayMode; this.temperatureSensor = device.temperatureSensor || false; this.temperatureSensorOutdoor = device.temperatureSensorOutdoor || false; - this.presetsEnabled = device.presets || false; this.heatDryFanMode = device.heatDryFanMode || 1; //NONE, HEAT, DRY, FAN this.coolDryFanMode = device.coolDryFanMode || 1; //NONE, COOL, DRY, FAN this.autoDryFanMode = device.autoDryFanMode || 1; //NONE, AUTO, DRY, FAN @@ -46,13 +45,13 @@ class DeviceAta extends EventEmitter { const presetDisplayType = preset.displayType ?? 0; const presetNamePrefix = preset.namePrefix ?? false; if (presetName && presetDisplayType > 0) { - const buttonServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][presetDisplayType]; - const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][presetDisplayType]; + const presetyServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][presetDisplayType]; + const presetCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][presetDisplayType]; preset.namePrefix = presetNamePrefix; - preset.serviceType = buttonServiceType; - preset.characteristicType = buttonCharacteristicType; + preset.serviceType = presetyServiceType; + preset.characteristicType = presetCharacteristicType; preset.state = false; - this.buttonsConfigured.push(preset); + this.presetsConfigured.push(preset); } else { const log = presetDisplayType === 0 ? false : this.emit('message', `Preset Name: ${preset ? preset : 'Missing'}.`); }; diff --git a/src/deviceatw.js b/src/deviceatw.js index df4b58b..8bff9d7 100644 --- a/src/deviceatw.js +++ b/src/deviceatw.js @@ -42,25 +42,25 @@ class DeviceAtw extends EventEmitter { //function this.melCloud = melCloud; //function - //presets configured - this.presetsConfigured = []; - for (const preset of this.presets) { - const presetName = preset.name ?? false; - const presetDisplayType = preset.displayType ?? 0; - const presetNamePrefix = preset.namePrefix ?? false; - if (presetName && presetDisplayType > 0) { - const buttonServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][presetDisplayType]; - const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][presetDisplayType]; - preset.namePrefix = presetNamePrefix; - preset.serviceType = buttonServiceType; - preset.characteristicType = buttonCharacteristicType; - preset.state = false; - this.buttonsConfigured.push(preset); - } else { - const log = presetDisplayType === 0 ? false : this.emit('message', `Preset Name: ${preset ? preset : 'Missing'}.`); - }; - } - this.presetsConfiguredCount = this.presetsConfigured.length || 0; + //presets configured + this.presetsConfigured = []; + for (const preset of this.presets) { + const presetName = preset.name ?? false; + const presetDisplayType = preset.displayType ?? 0; + const presetNamePrefix = preset.namePrefix ?? false; + if (presetName && presetDisplayType > 0) { + const presetyServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][presetDisplayType]; + const presetCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][presetDisplayType]; + preset.namePrefix = presetNamePrefix; + preset.serviceType = presetyServiceType; + preset.characteristicType = presetCharacteristicType; + preset.state = false; + this.presetsConfigured.push(preset); + } else { + const log = presetDisplayType === 0 ? false : this.emit('message', `Preset Name: ${preset ? preset : 'Missing'}.`); + }; + } + this.presetsConfiguredCount = this.presetsConfigured.length || 0; //buttons configured this.buttonsConfigured = []; diff --git a/src/deviceerv.js b/src/deviceerv.js index 15ca979..ee95dbc 100644 --- a/src/deviceerv.js +++ b/src/deviceerv.js @@ -43,13 +43,13 @@ class DeviceErv extends EventEmitter { const presetDisplayType = preset.displayType ?? 0; const presetNamePrefix = preset.namePrefix ?? false; if (presetName && presetDisplayType > 0) { - const buttonServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][presetDisplayType]; - const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][presetDisplayType]; + const presetyServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][presetDisplayType]; + const presetCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][presetDisplayType]; preset.namePrefix = presetNamePrefix; - preset.serviceType = buttonServiceType; - preset.characteristicType = buttonCharacteristicType; + preset.serviceType = presetyServiceType; + preset.characteristicType = presetCharacteristicType; preset.state = false; - this.buttonsConfigured.push(preset); + this.presetsConfigured.push(preset); } else { const log = presetDisplayType === 0 ? false : this.emit('message', `Preset Name: ${preset ? preset : 'Missing'}.`); };