homebridge-melcloud-control 3.6.5 → 3.6.7

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/CHANGELOG.md CHANGED
@@ -16,6 +16,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
16
  - do not configure it manually, always using Config UI X
17
17
  - required Homebridge v2.0.0 and above
18
18
 
19
+ ## [3.6.7] - (26.02.2025)
20
+
21
+ ## Changes
22
+
23
+ - bump dependencies
24
+ - cleanup
25
+ - redme update
26
+
27
+ ## [3.6.6] - (25.02.2025)
28
+
29
+ ## Changes
30
+
31
+ - fix [#190](https://github.com/grzegorz914/homebridge-melcloud-control/issues/190)
32
+
19
33
  ## [3.6.4] - (09.02.2025)
20
34
 
21
35
  ## Changes
package/README.md CHANGED
@@ -281,7 +281,6 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
281
281
  | `enableDebugMode` | If enabled, deep log will be present in homebridge console. |
282
282
  | `restFul` | This is RSTful server. |
283
283
  | `restFul.enable` | If enabled, RESTful server will start automatically and respond to any path request. |
284
- | `restFul.port` | Here set the listening `Port` for RESTful server. |
285
284
  | `restFul.debug` | If enabled, deep log will be present in homebridge console for RESTFul server. |
286
285
  | `mqtt` | This is MQTT Broker. |
287
286
  | `mqtt.enable` | If enabled, MQTT Broker will start automatically and publish all awailable PV data. |
@@ -1600,16 +1600,6 @@
1600
1600
  "functionBody": "return model.accounts[arrayIndices].restFul.enable === true;"
1601
1601
  },
1602
1602
  "required": false
1603
- },
1604
- "port": {
1605
- "title": "Port",
1606
- "type": "integer",
1607
- "placeholder": 3000,
1608
- "description": "Here set the listening Port for RESTful server.",
1609
- "condition": {
1610
- "functionBody": "return model.accounts[arrayIndices].restFul.enable === true;"
1611
- },
1612
- "required": false
1613
1603
  }
1614
1604
  }
1615
1605
  },
package/index.js CHANGED
@@ -48,6 +48,10 @@ class MelCloudPlatform {
48
48
  }
49
49
  accountsName.push(accountName);
50
50
 
51
+ //external integrations
52
+ const restFul = account.restFul ?? {};
53
+ const mqtt = account.mqtt ?? {};
54
+
51
55
  //log config
52
56
  const enableDebugMode = account.enableDebugMode || false;
53
57
  const disableLogDeviceInfo = account.disableLogDeviceInfo || false;
@@ -130,7 +134,7 @@ class MelCloudPlatform {
130
134
  const deviceName = device.name;
131
135
  const deviceTypeText = device.typeString;
132
136
  const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
133
- const airConditioner = new DeviceAta(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit)
137
+ const airConditioner = new DeviceAta(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt)
134
138
  airConditioner.on('publishAccessory', (accessory) => {
135
139
 
136
140
  //publish device
@@ -195,7 +199,7 @@ class MelCloudPlatform {
195
199
  const deviceName = device.name;
196
200
  const deviceTypeText = device.typeString;
197
201
  const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
198
- const heatPump = new DeviceAtw(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit)
202
+ const heatPump = new DeviceAtw(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt)
199
203
  heatPump.on('publishAccessory', (accessory) => {
200
204
 
201
205
  //publish device
@@ -260,7 +264,7 @@ class MelCloudPlatform {
260
264
  const deviceName = device.name;
261
265
  const deviceTypeText = device.typeString;
262
266
  const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
263
- const energyRecoveryVentilation = new DeviceErv(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit)
267
+ const energyRecoveryVentilation = new DeviceErv(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt)
264
268
  energyRecoveryVentilation.on('publishAccessory', (accessory) => {
265
269
 
266
270
  //publish device
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "3.6.5",
4
+ "version": "3.6.7",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@homebridge/plugin-ui-utils": "^2.0.1",
39
39
  "async-mqtt": "^2.6.3",
40
- "axios": "^1.7.9",
40
+ "axios": "^1.8.0",
41
41
  "express": "^4.21.2"
42
42
  },
43
43
  "keywords": [
package/src/deviceata.js CHANGED
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, AirConditioner } from './constants.js';
6
6
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
7
7
 
8
8
  class DeviceAta extends EventEmitter {
9
- constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit) {
9
+ constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit, restFul, mqtt) {
10
10
  super();
11
11
 
12
12
  Accessory = api.platformAccessory;
@@ -39,9 +39,9 @@ class DeviceAta extends EventEmitter {
39
39
  this.displayDeviceInfo = true;
40
40
 
41
41
  //external integrations
42
- this.restFul = account.restFul ?? {};
42
+ this.restFul = restFul;
43
43
  this.restFulConnected = false;
44
- this.mqtt = account.mqtt ?? {};
44
+ this.mqtt = mqtt;
45
45
  this.mqttConnected = false;
46
46
 
47
47
  //function
@@ -99,6 +99,78 @@ class DeviceAta extends EventEmitter {
99
99
  this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
100
100
  };
101
101
 
102
+ async externalIntegrations() {
103
+ try {
104
+ //RESTFul server
105
+ const restFulEnabled = this.restFul.enable || false;
106
+ if (restFulEnabled) {
107
+ if (!this.restFulConnected) {
108
+ this.restFul1 = new RestFul({
109
+ port: this.deviceId.slice(-4),
110
+ debug: this.restFul.debug || false
111
+ });
112
+
113
+ this.restFul1.on('connected', (message) => {
114
+ this.restFulConnected = true;
115
+ this.emit('success', message);
116
+ })
117
+ .on('set', async (key, value) => {
118
+ try {
119
+ await this.setOverExternalIntegration('RESTFul', this.deviceData, key, value);
120
+ } catch (error) {
121
+ this.emit('warn', error);
122
+ };
123
+ })
124
+ .on('debug', (debug) => {
125
+ this.emit('debug', debug);
126
+ })
127
+ .on('error', (error) => {
128
+ this.emit('warn', error);
129
+ });
130
+ }
131
+ }
132
+
133
+ //MQTT client
134
+ const mqttEnabled = this.mqtt.enable || false;
135
+ if (mqttEnabled) {
136
+ if (!this.mqttConnected) {
137
+ this.mqtt1 = new Mqtt({
138
+ host: this.mqtt.host,
139
+ port: this.mqtt.port || 1883,
140
+ clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
141
+ prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
142
+ user: this.mqtt.user,
143
+ passwd: this.mqtt.pass,
144
+ debug: this.mqtt.debug || false
145
+ });
146
+
147
+ this.mqtt1.on('connected', (message) => {
148
+ this.mqttConnected = true;
149
+ this.emit('success', message);
150
+ })
151
+ .on('subscribed', (message) => {
152
+ this.emit('success', message);
153
+ })
154
+ .on('set', async (key, value) => {
155
+ try {
156
+ await this.setOverExternalIntegration('MQTT', this.deviceData, key, value);
157
+ } catch (error) {
158
+ this.emit('warn', error);
159
+ };
160
+ })
161
+ .on('debug', (debug) => {
162
+ this.emit('debug', debug);
163
+ })
164
+ .on('error', (error) => {
165
+ this.emit('warn', error);
166
+ });
167
+ }
168
+ }
169
+ } catch (error) {
170
+ this.emit('warn', `External integration start error: ${error}`);
171
+ };
172
+ }
173
+
102
174
  async setOverExternalIntegration(integration, deviceData, key, value) {
103
175
  try {
104
176
  let set = false
@@ -178,78 +250,6 @@ class DeviceAta extends EventEmitter {
178
250
  };
179
251
  }
180
252
 
181
- async externalIntegrations() {
182
- try {
183
- //RESTFul server
184
- const restFulEnabled = this.restFul.enable || false;
185
- if (restFulEnabled) {
186
- if (!this.restFulConnected) {
187
- this.restFul1 = new RestFul({
188
- port: this.deviceId.slice(-4),
189
- debug: this.restFul.debug || false
190
- });
191
-
192
- this.restFul1.on('connected', (message) => {
193
- this.restFulConnected = true;
194
- this.emit('success', message);
195
- })
196
- .on('set', async (key, value) => {
197
- try {
198
- await this.setOverExternalIntegration('RESTFul', this.deviceData, key, value);
199
- } catch (error) {
200
- this.emit('warn', error);
201
- };
202
- })
203
- .on('debug', (debug) => {
204
- this.emit('debug', debug);
205
- })
206
- .on('error', (error) => {
207
- this.emit('warn', error);
208
- });
209
- }
210
- }
211
-
212
- //MQTT client
213
- const mqttEnabled = this.mqtt.enable || false;
214
- if (mqttEnabled) {
215
- if (!this.mqttConnected) {
216
- this.mqtt1 = new Mqtt({
217
- host: this.mqtt.host,
218
- port: this.mqtt.port || 1883,
219
- clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
220
- prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
221
- user: this.mqtt.user,
222
- passwd: this.mqtt.pass,
223
- debug: this.mqtt.debug || false
224
- });
225
-
226
- this.mqtt1.on('connected', (message) => {
227
- this.mqttConnected = true;
228
- this.emit('success', message);
229
- })
230
- .on('subscribed', (message) => {
231
- this.emit('success', message);
232
- })
233
- .on('set', async (key, value) => {
234
- try {
235
- await this.setOverExternalIntegration('MQTT', this.deviceData, key, value);
236
- } catch (error) {
237
- this.emit('warn', error);
238
- };
239
- })
240
- .on('debug', (debug) => {
241
- this.emit('debug', debug);
242
- })
243
- .on('error', (error) => {
244
- this.emit('warn', error);
245
- });
246
- }
247
- }
248
- } catch (error) {
249
- this.emit('warn', `External integration start error: ${error}`);
250
- };
251
- }
252
-
253
253
  async startImpulseGenerator() {
254
254
  try {
255
255
  //start impule generator
package/src/deviceatw.js CHANGED
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, HeatPump } from './constants.js';
6
6
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
7
7
 
8
8
  class DeviceAtw extends EventEmitter {
9
- constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit) {
9
+ constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit, restFul, mqtt) {
10
10
  super();
11
11
 
12
12
  Accessory = api.platformAccessory;
@@ -43,9 +43,9 @@ class DeviceAtw extends EventEmitter {
43
43
  this.displayDeviceInfo = true;
44
44
 
45
45
  //external integrations
46
- this.restFul = account.restFul ?? {};
46
+ this.restFul = restFul;
47
47
  this.restFulConnected = false;
48
- this.mqtt = account.mqtt ?? {};
48
+ this.mqtt = mqtt;
49
49
  this.mqttConnected = false;
50
50
 
51
51
  //function
@@ -103,6 +103,78 @@ class DeviceAtw extends EventEmitter {
103
103
  this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
104
104
  };
105
105
 
106
+ async externalIntegrations() {
107
+ try {
108
+ //RESTFul server
109
+ const restFulEnabled = this.restFul.enable || false;
110
+ if (restFulEnabled) {
111
+ if (!this.restFulConnected) {
112
+ this.restFul1 = new RestFul({
113
+ port: this.deviceId.slice(-4),
114
+ debug: this.restFul.debug || false
115
+ });
116
+
117
+ this.restFul1.on('connected', (message) => {
118
+ this.restFulConnected = true;
119
+ this.emit('success', message);
120
+ })
121
+ .on('set', async (key, value) => {
122
+ try {
123
+ await this.setOverExternalIntegration('RESTFul', this.deviceData, key, value);
124
+ } catch (error) {
125
+ this.emit('warn', error);
126
+ };
127
+ })
128
+ .on('debug', (debug) => {
129
+ this.emit('debug', debug);
130
+ })
131
+ .on('error', (error) => {
132
+ this.emit('warn', error);
133
+ });
134
+ }
135
+ }
136
+
137
+ //MQTT client
138
+ const mqttEnabled = this.mqtt.enable || false;
139
+ if (mqttEnabled) {
140
+ if (!this.mqttConnected) {
141
+ this.mqtt1 = new Mqtt({
142
+ host: this.mqtt.host,
143
+ port: this.mqtt.port || 1883,
144
+ clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
145
+ prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
146
+ user: this.mqtt.user,
147
+ passwd: this.mqtt.pass,
148
+ debug: this.mqtt.debug || false
149
+ });
150
+
151
+ this.mqtt1.on('connected', (message) => {
152
+ this.mqttConnected = true;
153
+ this.emit('success', message);
154
+ })
155
+ .on('subscribed', (message) => {
156
+ this.emit('success', message);
157
+ })
158
+ .on('set', async (key, value) => {
159
+ try {
160
+ await this.setOverExternalIntegration('MQTT', this.deviceData, key, value);
161
+ } catch (error) {
162
+ this.emit('warn', error);
163
+ };
164
+ })
165
+ .on('debug', (debug) => {
166
+ this.emit('debug', debug);
167
+ })
168
+ .on('error', (error) => {
169
+ this.emit('warn', error);
170
+ });
171
+ }
172
+ }
173
+ } catch (error) {
174
+ this.emit('warn', `External integration start error: ${error}`);
175
+ };
176
+ }
177
+
106
178
  async setOverExternalIntegration(integration, deviceData, key, value) {
107
179
  try {
108
180
  let set = false
@@ -202,77 +274,6 @@ class DeviceAtw extends EventEmitter {
202
274
  };
203
275
  }
204
276
 
205
- async externalIntegrations() {
206
- try {
207
- //RESTFul server
208
- const restFulEnabled = this.restFul.enable || false;
209
- if (restFulEnabled) {
210
- if (!this.restFulConnected) {
211
- this.restFul1 = new RestFul({
212
- port: this.deviceId.slice(-4),
213
- debug: this.restFul.debug || false
214
- });
215
-
216
- this.restFul1.on('connected', (message) => {
217
- this.restFulConnected = true;
218
- this.emit('success', message);
219
- })
220
- .on('set', async (key, value) => {
221
- try {
222
- await this.setOverExternalIntegration('RESTFul', this.deviceData, key, value);
223
- } catch (error) {
224
- this.emit('warn', error);
225
- };
226
- })
227
- .on('debug', (debug) => {
228
- this.emit('debug', debug);
229
- })
230
- .on('error', (error) => {
231
- this.emit('warn', error);
232
- });
233
- }
234
- }
235
-
236
- //MQTT client
237
- const mqttEnabled = this.mqtt.enable || false;
238
- if (mqttEnabled) {
239
- if (!this.mqttConnected) {
240
- this.mqtt1 = new Mqtt({
241
- host: this.mqtt.host,
242
- port: this.mqtt.port || 1883,
243
- clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
244
- prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
245
- user: this.mqtt.user,
246
- passwd: this.mqtt.pass,
247
- debug: this.mqtt.debug || false
248
- });
249
-
250
- this.mqtt1.on('connected', (message) => {
251
- this.mqttConnected = true;
252
- this.emit('success', message);
253
- })
254
- .on('subscribed', (message) => {
255
- this.emit('success', message);
256
- })
257
- .on('set', async (key, value) => {
258
- try {
259
- await this.setOverExternalIntegration('MQTT', this.deviceData, key, value);
260
- } catch (error) {
261
- this.emit('warn', error);
262
- };
263
- })
264
- .on('debug', (debug) => {
265
- this.emit('debug', debug);
266
- })
267
- .on('error', (error) => {
268
- this.emit('warn', error);
269
- });
270
- }
271
- }
272
- } catch (error) {
273
- this.emit('warn', `External integration start error: ${error}`);
274
- };
275
- }
276
277
 
277
278
  async startImpulseGenerator() {
278
279
  try {
package/src/deviceerv.js CHANGED
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, Ventilation } from './constants.js';
6
6
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
7
7
 
8
8
  class DeviceErv extends EventEmitter {
9
- constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit) {
9
+ constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit, restFul, mqtt) {
10
10
  super();
11
11
 
12
12
  Accessory = api.platformAccessory;
@@ -37,9 +37,9 @@ class DeviceErv extends EventEmitter {
37
37
  this.displayDeviceInfo = true;
38
38
 
39
39
  //external integrations
40
- this.restFul = account.restFul ?? {};
40
+ this.restFul = restFul;
41
41
  this.restFulConnected = false;
42
- this.mqtt = account.mqtt ?? {};
42
+ this.mqtt = mqtt;
43
43
  this.mqttConnected = false;
44
44
 
45
45
  //function
@@ -97,6 +97,78 @@ class DeviceErv extends EventEmitter {
97
97
  this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
98
98
  };
99
99
 
100
+ async externalIntegrations() {
101
+ try {
102
+ //RESTFul server
103
+ const restFulEnabled = this.restFul.enable || false;
104
+ if (restFulEnabled) {
105
+ if (!this.restFulConnected) {
106
+ this.restFul1 = new RestFul({
107
+ port: this.deviceId.slice(-4),
108
+ debug: this.restFul.debug || false
109
+ });
110
+
111
+ this.restFul1.on('connected', (message) => {
112
+ this.restFulConnected = true;
113
+ this.emit('success', message);
114
+ })
115
+ .on('set', async (key, value) => {
116
+ try {
117
+ await this.setOverExternalIntegration('RESTFul', this.deviceData, key, value);
118
+ } catch (error) {
119
+ this.emit('warn', error);
120
+ };
121
+ })
122
+ .on('debug', (debug) => {
123
+ this.emit('debug', debug);
124
+ })
125
+ .on('error', (error) => {
126
+ this.emit('warn', error);
127
+ });
128
+ }
129
+ }
130
+
131
+ //MQTT client
132
+ const mqttEnabled = this.mqtt.enable || false;
133
+ if (mqttEnabled) {
134
+ if (!this.mqttConnected) {
135
+ this.mqtt1 = new Mqtt({
136
+ host: this.mqtt.host,
137
+ port: this.mqtt.port || 1883,
138
+ clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
139
+ prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
140
+ user: this.mqtt.user,
141
+ passwd: this.mqtt.pass,
142
+ debug: this.mqtt.debug || false
143
+ });
144
+
145
+ this.mqtt1.on('connected', (message) => {
146
+ this.mqttConnected = true;
147
+ this.emit('success', message);
148
+ })
149
+ .on('subscribed', (message) => {
150
+ this.emit('success', message);
151
+ })
152
+ .on('set', async (key, value) => {
153
+ try {
154
+ await this.setOverExternalIntegration('MQTT', this.deviceData, key, value);
155
+ } catch (error) {
156
+ this.emit('warn', error);
157
+ };
158
+ })
159
+ .on('debug', (debug) => {
160
+ this.emit('debug', debug);
161
+ })
162
+ .on('error', (error) => {
163
+ this.emit('warn', error);
164
+ });
165
+ }
166
+ }
167
+ } catch (error) {
168
+ this.emit('warn', `External integration start error: ${error}`);
169
+ };
170
+ }
171
+
100
172
  async setOverExternalIntegration(integration, deviceData, key, value) {
101
173
  try {
102
174
  let set = false