homebridge-melcloud-control 4.0.0-beta.200 → 4.0.0-beta.202

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.
@@ -201,7 +201,7 @@
201
201
  }
202
202
  ]
203
203
  },
204
- "displayType": {
204
+ "accountType": {
205
205
  "title": "Account Type",
206
206
  "type": "string",
207
207
  "default": "disabled",
@@ -1844,7 +1844,7 @@
1844
1844
  "type": "password"
1845
1845
  },
1846
1846
  "accounts[].language",
1847
- "accounts[].displayType",
1847
+ "accounts[].accountType",
1848
1848
  {
1849
1849
  "key": "accounts[]",
1850
1850
  "type": "tabarray",
@@ -77,8 +77,8 @@
77
77
  </div>
78
78
 
79
79
  <div class="mb-2">
80
- <label for="displayType" class="form-label">Account Type</label>
81
- <select id="displayType" name="displayType" class="form-control">
80
+ <label for="accountType" class="form-label">Account Type</label>
81
+ <select id="accountType" name="accountType" class="form-control">
82
82
  <option value="disabled">None/Disabled</option>
83
83
  <option value="melcloud">MELCloud</option>
84
84
  <option value="melcloudhome">MELCloud Home</option>
@@ -134,8 +134,8 @@
134
134
  document.getElementById('user').value = acc.user || '';
135
135
  document.getElementById('passwd').value = acc.passwd || '';
136
136
  document.getElementById('language').value = acc.language || '0';
137
- document.getElementById('displayType').value = acc.displayType || 'disabled';
138
- document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language && acc.displayType);
137
+ document.getElementById('accountType').value = acc.accountType || 'disabled';
138
+ document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language && acc.accountType);
139
139
  });
140
140
 
141
141
  if (i === accountsCount - 1 && accountsCount > 0)
@@ -154,9 +154,9 @@
154
154
  acc.user = document.querySelector('#user').value;
155
155
  acc.passwd = document.querySelector('#passwd').value;
156
156
  acc.language = document.querySelector('#language').value;
157
- acc.displayType = document.querySelector('#displayType').value;
157
+ acc.accountType = document.querySelector('#accountType').value;
158
158
 
159
- document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language && acc.displayType);
159
+ document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language && acc.accountType);
160
160
 
161
161
  await homebridge.updatePluginConfig(pluginConfig);
162
162
  await homebridge.savePluginConfig(pluginConfig);
@@ -215,7 +215,7 @@
215
215
 
216
216
  try {
217
217
  const acc = pluginConfig[0].accounts[this.accountIndex];
218
- const payload = { accountName: acc.name, user: acc.user, passwd: acc.passwd, language: acc.language, displayType: acc.displayType };
218
+ const payload = { accountName: acc.name, user: acc.user, passwd: acc.passwd, language: acc.language, accountType: acc.accountType };
219
219
  const devicesInMelCloud = await homebridge.request('/connect', payload);
220
220
 
221
221
  // Initialize devices arrays
@@ -258,7 +258,7 @@
258
258
  const p = structuredClone({
259
259
  id: preset.ID,
260
260
  name: preset.NumberDescription,
261
- displayType: 0,
261
+ accountType: 0,
262
262
  namePrefix: false
263
263
  });
264
264
 
@@ -17,11 +17,11 @@ class PluginUiServer extends HomebridgePluginUiServer {
17
17
  const user = payload.user;
18
18
  const passwd = payload.passwd;
19
19
  const language = payload.language;
20
- const displayType = payload.displayType;
20
+ const accountType = payload.accountType;
21
21
  const accountFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Account`;
22
22
  const buildingsFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Buildings`;
23
23
  const devicesFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Devices`;
24
- const melCloud = new MelCloud(displayType, user, passwd, language, accountFile, buildingsFile, devicesFile, false, true);
24
+ const melCloud = new MelCloud(accountType, user, passwd, language, accountFile, buildingsFile, devicesFile, false, true);
25
25
 
26
26
  try {
27
27
  const accountInfo = await melCloud.connect();
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { join } from 'path';
2
- import { mkdirSync } from 'fs';
2
+ import { mkdirSync, existsSync, writeFileSync } from 'fs';
3
3
  import MelCloud from './src/melcloud.js';
4
4
  import DeviceAta from './src/deviceata.js';
5
5
  import DeviceAtw from './src/deviceatw.js';
@@ -30,7 +30,7 @@ class MelCloudPlatform {
30
30
  api.on('didFinishLaunching', async () => {
31
31
  //loop through accounts
32
32
  for (const account of config.accounts) {
33
- const accountType = account.displayType || 'disabled';
33
+ const accountType = account.accountType || 'disabled';
34
34
  if (accountType === 'disabled') continue;
35
35
 
36
36
  const accountName = account.name;
@@ -143,17 +143,19 @@ class MelCloudPlatform {
143
143
  const deviceRefreshInterval = (device.refreshInterval ?? 5) * 1000;
144
144
  const defaultTempsFile = `${prefDir}/${accountName}_${device.id}_Temps`;
145
145
 
146
- try {
147
- [defaultTempsFile].forEach(file => {
148
- const temps = {
149
- defaultCoolingSetTemperature: 24,
150
- defaultHeatingSetTemperature: 20
151
- };
152
- if (!existsSync(file)) writeFileSync(file, temps);
153
- });
154
- } catch (error) {
155
- if (logLevel.error) log.error(`Device: ${host} ${deviceName}, File init error: ${error}`);
156
- continue;
146
+ if (accountType === 'melcloudhome') {
147
+ try {
148
+ [defaultTempsFile].forEach(file => {
149
+ const temps = JSON.stringify({
150
+ defaultCoolingSetTemperature: 24,
151
+ defaultHeatingSetTemperature: 20
152
+ });
153
+ if (!existsSync(file)) writeFileSync(file, temps);
154
+ });
155
+ } catch (error) {
156
+ if (logLevel.error) log.error(`Device: ${host} ${deviceName}, File init error: ${error}`);
157
+ continue;
158
+ }
157
159
  }
158
160
 
159
161
  let configuredDevice;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.0-beta.200",
4
+ "version": "4.0.0-beta.202",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",