homebridge-melcloud-control 3.8.5-beta.0 → 3.8.5-beta.2

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.0",
4
+ "version": "3.8.5-beta.2",
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
@@ -1397,7 +1397,7 @@ class DeviceAta extends EventEmitter {
1397
1397
  const restFul = this.restFulConnected ? this.restFul1.update(path, data) : false;
1398
1398
  })
1399
1399
  .on('mqtt', (topic, message) => {
1400
- const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', topic, message) : false;
1400
+ const mqtt = this.mqttConnected ? this.mqtt1.publish(topic, message) : false;
1401
1401
  });
1402
1402
 
1403
1403
  //start external integrations
package/src/mqtt.js CHANGED
@@ -12,6 +12,7 @@ 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;
15
16
 
16
17
  this.on('connect', async () => {
17
18
  try {
@@ -51,5 +52,17 @@ class Mqtt extends EventEmitter {
51
52
 
52
53
  this.emit('connect');
53
54
  };
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
+ }
54
67
  };
55
68
  export default Mqtt;