homebridge-melcloud-control 3.8.5-beta.3 → 3.8.5-beta.5

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": "3.8.5-beta.3",
4
+ "version": "3.8.5-beta.5",
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/deviceata.js CHANGED
@@ -1396,8 +1396,8 @@ class DeviceAta extends EventEmitter {
1396
1396
  .on('restFul', (path, data) => {
1397
1397
  const restFul = this.restFulConnected ? this.restFul1.update(path, data) : false;
1398
1398
  })
1399
- .on('mqtt', async (topic, message) => {
1400
- const mqtt = this.mqttConnected ? await this.mqtt1.publish(topic, message) : false;
1399
+ .on('mqtt', (topic, message) => {
1400
+ const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', topic, message) : false;
1401
1401
  });
1402
1402
 
1403
1403
  //start external integrations
@@ -333,14 +333,6 @@ class MelCloudAta extends EventEmitter {
333
333
  HideDryModeControl: hideDryModeControl
334
334
  }
335
335
 
336
- //check state changes
337
- const deviceDataHasNotChanged = JSON.stringify(deviceState) === JSON.stringify(this.deviceState);
338
- if (deviceDataHasNotChanged) {
339
- const debug = this.enableDebugMode ? this.emit('debug', `Device state not changed`) : false;
340
- return;
341
- }
342
- this.deviceState = deviceState;
343
-
344
336
  //restFul
345
337
  this.emit('restFul', 'info', deviceData);
346
338
  this.emit('restFul', 'state', deviceData.Device);
@@ -349,6 +341,14 @@ class MelCloudAta extends EventEmitter {
349
341
  this.emit('mqtt', 'Info', deviceData);
350
342
  this.emit('mqtt', 'State', deviceData.Device);
351
343
 
344
+ //check state changes
345
+ const deviceDataHasNotChanged = JSON.stringify(deviceState) === JSON.stringify(this.deviceState);
346
+ if (deviceDataHasNotChanged) {
347
+ const debug = this.enableDebugMode ? this.emit('debug', `Device state not changed`) : false;
348
+ return;
349
+ }
350
+ this.deviceState = deviceState;
351
+
352
352
  //emit info
353
353
  this.emit('deviceInfo', manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion);
354
354
 
package/src/mqtt.js CHANGED
@@ -12,7 +12,6 @@ class Mqtt extends EventEmitter {
12
12
  }
13
13
  const url = `mqtt://${config.host}:${config.port}`;
14
14
  const subscribeTopic = `${config.prefix}/Set`;
15
- this.topic = config.prefix;
16
15
 
17
16
  this.on('connect', async () => {
18
17
  try {
@@ -52,17 +51,5 @@ class Mqtt extends EventEmitter {
52
51
 
53
52
  this.emit('connect');
54
53
  };
55
-
56
- async publish(topic, message) {
57
- try {
58
- const fullTopic = `${this.topic}/${topic}`;
59
- const publishMessage = JSON.stringify(message, null, 2);
60
- await this.mqttClient.publish(fullTopic, publishMessage);
61
- const emitDebug = config.debug ? this.emit('debug', `MQTT Publish topic: ${fullTopic}, message: ${publishMessage}`) : false;
62
- return;
63
- } catch (error) {
64
- this.emit('warn', `MQTT Publish error: ${error}`);
65
- };
66
- }
67
54
  };
68
55
  export default Mqtt;