homebridge-melcloud-control 4.1.3-beta.14 → 4.1.3-beta.15

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/deviceata.js +11 -10
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.1.3-beta.14",
4
+ "version": "4.1.3-beta.15",
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
@@ -798,15 +798,15 @@ class DeviceAta extends EventEmitter {
798
798
  accessory.addService(this.schedulesControlService);
799
799
 
800
800
  if (this.logDebug) this.emit('debug', `Prepare schedule control sensor service`);
801
- this.scheduleSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
802
- this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
803
- this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
804
- this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
801
+ this.schedulesControlSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
802
+ this.schedulesControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
803
+ this.schedulesControlSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
804
+ this.schedulesControlSensorService.getCharacteristic(Characteristic.ContactSensorState)
805
805
  .onGet(async () => {
806
806
  const state = this.accessory.scheduleEnabled;
807
807
  return state;
808
808
  })
809
- accessory.addService(this.scheduleSensorService);
809
+ accessory.addService(this.schedulesControlSensorService);
810
810
  }
811
811
 
812
812
  //sensors
@@ -1104,8 +1104,6 @@ class DeviceAta extends EventEmitter {
1104
1104
  this.deviceData = deviceData;
1105
1105
 
1106
1106
  //keys
1107
- const presetsIdKey = this.accountType === 'melcloud' ? 'ID' : 'Id';
1108
- const setTempKey = this.accountType === 'melcloud' ? 'SetTemperature' : 'SetPoint';
1109
1107
  const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
1110
1108
  const tempStepKey = this.accountType === 'melcloud' ? 'TemperatureIncrement' : 'HasHalfDegreeIncrements';
1111
1109
  const errorKey = this.accountType === 'melcloud' ? 'HasError' : 'IsInError';
@@ -1374,7 +1372,7 @@ class DeviceAta extends EventEmitter {
1374
1372
  //update presets state
1375
1373
  if (this.presets.length > 0) {
1376
1374
  this.presets.forEach((preset, i) => {
1377
- const presetData = presetsOnServer.find(p => p[presetsIdKey] === preset.id);
1375
+ const presetData = presetsOnServer.find(p => p.ID === preset.id);
1378
1376
 
1379
1377
  preset.state = presetData ? (presetData.Power === power
1380
1378
  && presetData.SetTemperature === setTemperature
@@ -1392,10 +1390,13 @@ class DeviceAta extends EventEmitter {
1392
1390
  if (this.schedules.length > 0 && scheduleEnabled !== null) {
1393
1391
  this.schedules.forEach((schedule, i) => {
1394
1392
  //control
1395
- if (i === 0) this.schedulesControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
1393
+ if (i === 0) {
1394
+ this.schedulesControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
1395
+ this.schedulesControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, scheduleEnabled);
1396
+ }
1396
1397
 
1397
1398
  //sensors
1398
- const scheduleData = schedulesOnServer.find(s => s[presetsIdKey] === schedule.id);
1399
+ const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
1399
1400
  schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
1400
1401
 
1401
1402
  const characteristicType = schedule.characteristicType;