homebridge-melcloud-control 4.3.0-beta.23 → 4.3.0-beta.24

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/index.js CHANGED
@@ -194,7 +194,7 @@ class MelCloudPlatform {
194
194
 
195
195
  //start impulse generators\
196
196
  await configuredDevice.startStopImpulseGenerator(true, [{ name: 'checkState', sampling: deviceRefreshInterval }]);
197
- const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling: 3600000 }, { name: 'checkDevicesList', sampling: 3000 }] : [{ name: 'checkDevicesList', sampling: refreshInterval }];
197
+ const timmers = accountType === 'melcloudhome' ? [] : [{ name: 'checkDevicesList', sampling: refreshInterval }];
198
198
  await melCloud.impulseGenerator.state(true, timmers, false);
199
199
 
200
200
  //stop impulse generator
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.0-beta.23",
4
+ "version": "4.3.0-beta.24",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -70,7 +70,6 @@ class MelCloudAta extends EventEmitter {
70
70
  if (!devicesData) return;
71
71
 
72
72
  this.headers = devicesData.Headers;
73
- this.hash = devicesData.Hash;
74
73
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
75
74
  if (this.accountType === 'melcloudhome') {
76
75
  deviceData.Scenes = devicesData.Scenes ?? [];
@@ -81,7 +80,7 @@ class MelCloudAta extends EventEmitter {
81
80
  deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapStringToEnum[deviceData.Device.VaneHorizontalDirection] ?? deviceData.Device.VaneHorizontalDirection;
82
81
 
83
82
  if (!this.socketConnected) {
84
- const socket = new WebSocket(`wss://ws.melcloudhome.com/?hash=${devicesData.WsHeaders.hash}`, { headers: WsHeaders.headers })
83
+ const socket = new WebSocket(`wss://ws.melcloudhome.com/?hash=${devicesData.WsHeaders.hash}`, { headers: devicesData.WsHeaders.headers })
85
84
  .on('error', (error) => {
86
85
  if (this.logDebug) this.emit('debug', `Socket error: ${error}`);
87
86
  socket.close();
@@ -109,7 +108,6 @@ class MelCloudAta extends EventEmitter {
109
108
  })
110
109
  .on('message', (message) => {
111
110
  const parsedMessage = JSON.parse(message);
112
- const messageType = parsedMessage[0].messageType;
113
111
  const messageData = parsedMessage[0].Data;
114
112
  const unitId = messageData.id;
115
113
  const unitType = messageData.unitType;
@@ -118,12 +116,23 @@ class MelCloudAta extends EventEmitter {
118
116
 
119
117
  switch (unitId) {
120
118
  case this.deviceId:
121
- const settings = Object.fromEntries(messageData.settings.map(s => [s.name, s.value]));
122
- if (!this.logDebug) this.emit('warn', `Settings:', ${settings}`);
123
- Object.assign(deviceData.Device, settings);
124
-
125
- //emit state
126
- this.emit('deviceState', deviceData);
119
+ const messageType = parsedMessage[0].messageType;
120
+ switch (messageType) {
121
+ case 'unitStateChanged':
122
+ const settings = Object.fromEntries(messageData.settings.map(s => [s.name, s.value]));
123
+ Object.assign(deviceData.Device, settings);
124
+
125
+ //emit state
126
+ this.emit('deviceState', deviceData);
127
+ break;
128
+ case 'unitWiFiChanged':
129
+ const state = Object.fromEntries(messageData.settings.map(s => [s.name, s.value]));
130
+ Object.assign(deviceData.Device, state);
131
+
132
+ //emit state
133
+ this.emit('deviceState', deviceData);
134
+ break;
135
+ }
127
136
  break;
128
137
  }
129
138
  });