homebridge-melcloud-control 4.2.3-beta.37 → 4.2.3-beta.39

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.2.3-beta.37",
4
+ "version": "4.2.3-beta.39",
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/melcloud.js CHANGED
@@ -55,7 +55,7 @@ class MelCloud extends EventEmitter {
55
55
  // MELCloud
56
56
  async checkDevicesList() {
57
57
  try {
58
- const devicesList = { State: false, Info: null, Devices: [] }
58
+ const devicesList = { State: false, Info: null, Devices: [], Scenes: [] }
59
59
  if (this.logDebug) this.emit('debug', `Scanning for devices...`);
60
60
  const listDevicesData = await axios(ApiUrls.ListDevices, {
61
61
  method: 'GET',
@@ -75,33 +75,24 @@ class MelCloud extends EventEmitter {
75
75
  const scenesList = listScenesData.data;
76
76
  if (this.logDebug) this.emit('debug', `Scenes: ${JSON.stringify(scenesList, null, 2)}`);
77
77
 
78
- const scenes = scenesList.flatMap(scene => {
79
- const capitalizeKeysDeep = obj => {
80
- if (Array.isArray(obj)) {
81
- return obj.map(item => capitalizeKeysDeep(item));
82
- }
83
-
84
- if (obj && typeof obj === 'object') {
85
- return Object.fromEntries(
86
- Object.entries(obj).map(([key, value]) => [
87
- key.charAt(0).toUpperCase() + key.slice(1),
88
- capitalizeKeysDeep(value)
89
- ])
90
- );
91
- }
78
+ const capitalizeKeysDeep = obj => {
79
+ if (Array.isArray(obj)) {
80
+ return obj.map(item => capitalizeKeysDeep(item));
81
+ }
92
82
 
93
- return obj;
94
- };
83
+ if (obj && typeof obj === 'object') {
84
+ return Object.fromEntries(
85
+ Object.entries(obj).map(([key, value]) => [
86
+ key.charAt(0).toUpperCase() + key.slice(1),
87
+ capitalizeKeysDeep(value)
88
+ ])
89
+ );
90
+ }
95
91
 
96
- const allSettings = [
97
- ...(scene.ataSceneSettings || []),
98
- ...(scene.ervSceneSettings || []),
99
- ...(scene.atwSceneSettings || [])
100
- ];
92
+ return obj;
93
+ };
101
94
 
102
- return allSettings.map(setting => capitalizeKeysDeep(setting));
103
- });
104
- return scenes;
95
+ return scenesList.map(scene => capitalizeKeysDeep(scene));
105
96
  } catch (error) {
106
97
  throw new Error(`Check scenes list error: ${error.message}`);
107
98
  }
@@ -215,7 +206,7 @@ class MelCloud extends EventEmitter {
215
206
  return devicesList;
216
207
  }
217
208
 
218
- const scenes = this.checkScenesList();
209
+ const scenes = await this.checkScenesList();
219
210
 
220
211
  devicesList.State = true;
221
212
  devicesList.Info = `Found ${devicesCount} devices`;