homebridge-melcloud-control 3.1.0 → 3.1.1-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.
@@ -22,10 +22,10 @@ class PluginUiServer extends HomebridgePluginUiServer {
22
22
  const accountInfoFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Account`;
23
23
  const buildingsFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Buildings`;
24
24
  const deviceFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Device_`;
25
+ const melCloud = new MelCloud(user, passwd, language, accountInfoFile, buildingsFile, deviceFile, false, 0, true);
26
+ let data = {};
25
27
 
26
28
  try {
27
- let data = {};
28
- const melCloud = new MelCloud(user, passwd, language, accountInfoFile, buildingsFile, deviceFile, false, 0, true);
29
29
  const response = await melCloud.connect();
30
30
  const accountInfo = response.accountInfo;
31
31
  const contextKey = response.contextKey;
package/index.js CHANGED
@@ -72,14 +72,22 @@ class MelCloudPlatform {
72
72
  const refreshInterval = account.refreshInterval * 1000 || 120000;
73
73
  const deviceRefreshInterval = account.deviceRefreshInterval * 1000 || 5000;
74
74
 
75
- //melcloud account
76
75
  try {
76
+ //melcloud account
77
77
  const melCloud = new MelCloud(user, passwd, language, accountInfoFile, buildingsFile, deviceFile, enableDebugMode, refreshInterval, false);
78
+
79
+ //connect
78
80
  const response = await melCloud.connect();
79
81
  const accountInfo = response.accountInfo;
80
82
  const contextKey = response.contextKey;
83
+
84
+ //check devices list
81
85
  const devices = await melCloud.chackDevicesList(contextKey);
82
86
 
87
+ //start impulse generator
88
+ const timers = [{ name: 'checkDevicesList', sampling: refreshInterval }];
89
+ melCloud.impulseGenerator.start(timers);
90
+
83
91
  //Air Conditioner
84
92
  for (const device of account.ataDevices) {
85
93
  if (!device.id || device.displayMode === 0) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "3.1.0",
4
+ "version": "3.1.1-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",
package/src/melcloud.js CHANGED
@@ -35,13 +35,11 @@ class MelCloud extends EventEmitter {
35
35
  this.impulseGenerator = new ImpulseGenerator();
36
36
  this.impulseGenerator.on('checkDevicesList', async () => {
37
37
  try {
38
- const devices = await this.chackDevicesList(this.contextKey);
38
+ await this.chackDevicesList(this.contextKey);
39
39
  } catch (error) {
40
40
  this.emit('error', `Check devices list: ${error}.`);
41
41
  };
42
42
  }).on('state', (state) => { });
43
-
44
- this.connect();
45
43
  };
46
44
  };
47
45
 
@@ -90,12 +88,6 @@ class MelCloud extends EventEmitter {
90
88
  //emit connect success
91
89
  this.emit('success', `Connect to MELCloud Success.`)
92
90
 
93
- if (!this.requestConfig) {
94
- //start impulse generator
95
- const timers = [{ name: 'checkDevicesList', sampling: this.refreshInterval }];
96
- this.impulseGenerator.start(timers);
97
- };
98
-
99
91
  const obj = {
100
92
  accountInfo: accountInfo,
101
93
  contextKey: contextKey
@@ -129,7 +121,7 @@ class MelCloud extends EventEmitter {
129
121
  const debug = this.enableDebugMode ? this.emit('debug', `Scanning for devices.`) : false;
130
122
  const listDevicesData = await axiosInstanceGet(CONSTANTS.ApiUrls.ListDevices);
131
123
  const buildingsList = listDevicesData.data;
132
- const debug1 = this.enableDebugMode ? this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`) : false;
124
+ const debug1 = !this.enableDebugMode ? this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`) : false;
133
125
 
134
126
  if (!buildingsList) {
135
127
  this.emit('warn', `No building found.`);