homebridge-melcloud-control 3.8.5-beta.0 → 3.8.5-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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/mqtt.js +13 -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.8.5-beta.0",
4
+ "version": "3.8.5-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/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.fullTopic = 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() {
57
+ try {
58
+ const fullTopic = this.fullTopic;
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;