homebridge-melcloud-control 4.3.10 → 4.3.11-beta.1

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.3.10",
4
+ "version": "4.3.11-beta.1",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -39,7 +39,7 @@
39
39
  "async-mqtt": "^2.6.3",
40
40
  "axios": "^1.13.2",
41
41
  "express": "^5.2.1",
42
- "puppeteer": "^24.31.0",
42
+ "puppeteer": "^24.32.0",
43
43
  "ws": "^8.18.3"
44
44
  },
45
45
  "keywords": [
package/src/constants.js CHANGED
@@ -58,8 +58,8 @@ export const TemperatureDisplayUnits = ["°C", "°F"];
58
58
 
59
59
  export const AirConditioner = {
60
60
  SystemMapEnumToString: { 0: "Air Conditioner Off", 1: "Air Conditioner On", 2: "Air Conditioner Offline" },
61
- OperationModeMapStringToEnum: { "0": 0, "Heat": 1, "Dry": 2, "Cool": 3, "4": 4, "5": 5, "6": 6, "Fan": 7, "Automatic": 8, "Isee Heat": 9, "Isee Dry": 10, "Isee Cool": 11 },
62
- OperationModeMapEnumToString: { 0: "0", 1: "Heat", 2: "Dry", 3: "Cool", 4: "4", 5: "5", 6: "6", 7: "Fan", 8: "Automatic", 9: "Isee Heat", 10: "Isee Dry", 11: "Isee Cool" },
61
+ OperationModeMapStringToEnum: { "0": 0, "Heat": 1, "Dry": 2, "Cool": 3, "4": 4, "5": 5, "6": 6, "Fan": 7, "Automatic": 8, "Heat Isee": 9, "Dry Isee": 10, "Cool Isee": 11 },
62
+ OperationModeMapEnumToString: { 0: "0", 1: "Heat", 2: "Dry", 3: "Cool", 4: "4", 5: "5", 6: "6", 7: "Fan", 8: "Automatic", 9: "Heat Isee", 10: "Dry Isee", 11: "Cool Isee" },
63
63
  OperationModeMapEnumToEnumWs: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 7, 5: 8, 6: 9, 7: 10, 8: 11 },
64
64
  FanSpeedMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5 },
65
65
  FanSpeedMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five" },
package/src/melcloud.js CHANGED
@@ -163,6 +163,7 @@ class MelCloud extends EventEmitter {
163
163
  'X-MitsContextKey': contextKey,
164
164
  'Content-Type': 'application/json'
165
165
  };
166
+ this.emit('headers', headers);
166
167
  this.headers = headers;
167
168
  this.axiosInstance = axios.create({
168
169
  baseURL: ApiUrls.BaseURL,
@@ -28,16 +28,17 @@ class MelCloudAta extends EventEmitter {
28
28
 
29
29
  //handle melcloud events
30
30
  let deviceData = null;
31
- melcloud.on('devicesList', async (devicesData) => {
31
+ melcloud.on('headers', (headers) => {
32
+ this.headers = headers;
33
+ }).on('devicesList', async (devicesData) => {
32
34
  try {
33
- this.headers = devicesData.Headers;
34
35
  deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
35
36
  if (!deviceData) return;
36
37
  deviceData.Scenes = devicesData.Scenes ?? [];
37
38
 
38
39
  //update state
39
40
  if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
40
- await this.updateState(deviceData);
41
+ await this.updateState('request', deviceData);
41
42
  } catch (error) {
42
43
  if (this.logError) this.emit('error', `Request process message error: ${error}`);
43
44
  }
@@ -95,14 +96,14 @@ class MelCloudAta extends EventEmitter {
95
96
  }
96
97
 
97
98
  //update state
98
- if (updateState) await this.updateState(deviceData, 'ws');
99
+ if (updateState) await this.updateState('ws', deviceData);
99
100
  } catch (error) {
100
101
  if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
101
102
  }
102
103
  });
103
104
  }
104
105
 
105
- async updateState(deviceData, type) {
106
+ async updateState(type, deviceData) {
106
107
  try {
107
108
  if (this.accountType === 'melcloudhome') {
108
109
 
@@ -187,7 +188,7 @@ class MelCloudAta extends EventEmitter {
187
188
  this.headers = devicesData.Headers;
188
189
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
189
190
  deviceData.Scenes = devicesData.Scenes ?? [];
190
- await this.updateState(deviceData);
191
+ await this.updateState('request', deviceData);
191
192
 
192
193
  return true;
193
194
  } catch (error) {
@@ -28,16 +28,17 @@ class MelCloudAtw extends EventEmitter {
28
28
 
29
29
  //handle melcloud events
30
30
  let deviceData = null;
31
- melcloud.on('devicesList', async (devicesData) => {
31
+ melcloud.on('headers', (headers) => {
32
+ this.headers = headers;
33
+ }).on('devicesList', async (devicesData) => {
32
34
  try {
33
- this.headers = devicesData.Headers;
34
35
  deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
35
36
  if (!deviceData) return;
36
37
  deviceData.Scenes = devicesData.Scenes ?? [];
37
38
 
38
39
  //update state
39
40
  if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
40
- await this.updateState(deviceData);
41
+ await this.updateState('request', deviceData);
41
42
  } catch (error) {
42
43
  if (this.logError) this.emit('error', `Request process message error: ${error}`);
43
44
  }
@@ -95,14 +96,14 @@ class MelCloudAtw extends EventEmitter {
95
96
  }
96
97
 
97
98
  //update state
98
- if (updateState) await this.updateState(deviceData, 'ws');
99
+ if (updateState) await this.updateState('ws', deviceData);
99
100
  } catch (error) {
100
101
  if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
101
102
  }
102
103
  });
103
104
  }
104
105
 
105
- async updateState(deviceData, type) {
106
+ async updateState(type, deviceData) {
106
107
  try {
107
108
  if (this.accountType === 'melcloudhome') {
108
109
  deviceData.Device.OperationMode = HeatPump.OperationModeMapStringToEnum[deviceData.Device.OperationMode] ?? deviceData.Device.OperationMode;
@@ -174,7 +175,7 @@ class MelCloudAtw extends EventEmitter {
174
175
  this.headers = devicesData.Headers;
175
176
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
176
177
  deviceData.Scenes = devicesData.Scenes ?? [];
177
- await this.updateState(deviceData);
178
+ await this.updateState('request', deviceData);
178
179
 
179
180
  return true;
180
181
  } catch (error) {
@@ -28,16 +28,17 @@ class MelCloudErv extends EventEmitter {
28
28
 
29
29
  //handle melcloud events
30
30
  let deviceData = null;
31
- melcloud.on('devicesList', async (devicesData) => {
31
+ melcloud.on('headers', (headers) => {
32
+ this.headers = headers;
33
+ }).on('devicesList', async (devicesData) => {
32
34
  try {
33
- this.headers = devicesData.Headers;
34
35
  deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
35
36
  if (!deviceData) return;
36
37
  deviceData.Scenes = devicesData.Scenes ?? [];
37
38
 
38
39
  //update state
39
40
  if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
40
- await this.updateState(deviceData);
41
+ await this.updateState('request', deviceData);
41
42
  } catch (error) {
42
43
  if (this.logError) this.emit('error', `Request process message error: ${error}`);
43
44
  }
@@ -95,14 +96,14 @@ class MelCloudErv extends EventEmitter {
95
96
  }
96
97
 
97
98
  //update state
98
- if (updateState) await this.updateState(deviceData, 'ws');
99
+ if (updateState) await this.updateState('ws', deviceData);
99
100
  } catch (error) {
100
101
  if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
101
102
  }
102
103
  });
103
104
  }
104
105
 
105
- async updateState(deviceData, type) {
106
+ async updateState(type, deviceData) {
106
107
  try {
107
108
  if (this.accountType === 'melcloudhome') {
108
109
  //read default temps
@@ -173,7 +174,7 @@ class MelCloudErv extends EventEmitter {
173
174
  this.headers = devicesData.Headers;
174
175
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
175
176
  deviceData.Scenes = devicesData.Scenes ?? [];
176
- await this.updateState(deviceData);
177
+ await this.updateState('request', deviceData);
177
178
 
178
179
  return true;
179
180
  } catch (error) {
@@ -412,6 +412,8 @@ class MelCloudHome extends EventEmitter {
412
412
  'User-Agent': userAgent,
413
413
  'x-csrf': '1'
414
414
  };
415
+ this.emit('headers', headers);
416
+
415
417
  this.headers = headers;
416
418
  this.axiosInstance = axios.create({
417
419
  baseURL: ApiUrlsHome.BaseURL,