homebridge-melcloud-control 3.8.4 → 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.
@@ -1764,7 +1764,7 @@
1764
1764
  "prefix": {
1765
1765
  "title": "Prefix",
1766
1766
  "type": "string",
1767
- "placeholder": "home/envoy",
1767
+ "placeholder": "home/melcloud",
1768
1768
  "description": "Here set the prefix.",
1769
1769
  "condition": {
1770
1770
  "functionBody": "return model.accounts[arrayIndices].mqtt.enable === true;"
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.4",
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/deviceata.js CHANGED
@@ -114,8 +114,11 @@ class DeviceAta extends EventEmitter {
114
114
  .on('debug', (debug) => {
115
115
  this.emit('debug', debug);
116
116
  })
117
+ .on('warn', (warn) => {
118
+ this.emit('warn', warn);
119
+ })
117
120
  .on('error', (error) => {
118
- this.emit('warn', error);
121
+ this.emit('error', error);
119
122
  });
120
123
  }
121
124
  }
@@ -127,8 +130,8 @@ class DeviceAta extends EventEmitter {
127
130
  this.mqtt1 = new Mqtt({
128
131
  host: this.mqtt.host,
129
132
  port: this.mqtt.port || 1883,
130
- clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
131
- prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
133
+ clientId: this.mqtt.clientId ? `${this.mqtt.clientId}_${this.deviceId}` : `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
134
+ prefix: this.mqtt.prefix ? `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}` : `melcloud/${this.deviceTypeText}/${this.deviceName}`,
132
135
  user: this.mqtt.user,
133
136
  passwd: this.mqtt.pass,
134
137
  debug: this.mqtt.debug || false
@@ -151,8 +154,11 @@ class DeviceAta extends EventEmitter {
151
154
  .on('debug', (debug) => {
152
155
  this.emit('debug', debug);
153
156
  })
157
+ .on('warn', (warn) => {
158
+ this.emit('warn', warn);
159
+ })
154
160
  .on('error', (error) => {
155
- this.emit('warn', error);
161
+ this.emit('error', error);
156
162
  });
157
163
  }
158
164
  }
package/src/deviceatw.js CHANGED
@@ -120,8 +120,11 @@ class DeviceAtw extends EventEmitter {
120
120
  .on('debug', (debug) => {
121
121
  this.emit('debug', debug);
122
122
  })
123
+ .on('warn', (warn) => {
124
+ this.emit('warn', warn);
125
+ })
123
126
  .on('error', (error) => {
124
- this.emit('warn', error);
127
+ this.emit('error', error);
125
128
  });
126
129
  }
127
130
  }
@@ -133,8 +136,8 @@ class DeviceAtw extends EventEmitter {
133
136
  this.mqtt1 = new Mqtt({
134
137
  host: this.mqtt.host,
135
138
  port: this.mqtt.port || 1883,
136
- clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
137
- prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
139
+ clientId: this.mqtt.clientId ? `${this.mqtt.clientId}_${this.deviceId}` : `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
140
+ prefix: this.mqtt.prefix ? `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}` : `melcloud/${this.deviceTypeText}/${this.deviceName}`,
138
141
  user: this.mqtt.user,
139
142
  passwd: this.mqtt.pass,
140
143
  debug: this.mqtt.debug || false
@@ -157,8 +160,11 @@ class DeviceAtw extends EventEmitter {
157
160
  .on('debug', (debug) => {
158
161
  this.emit('debug', debug);
159
162
  })
163
+ .on('warn', (warn) => {
164
+ this.emit('warn', warn);
165
+ })
160
166
  .on('error', (error) => {
161
- this.emit('warn', error);
167
+ this.emit('error', error);
162
168
  });
163
169
  }
164
170
  }
package/src/deviceerv.js CHANGED
@@ -113,8 +113,11 @@ class DeviceErv extends EventEmitter {
113
113
  .on('debug', (debug) => {
114
114
  this.emit('debug', debug);
115
115
  })
116
+ .on('warn', (warn) => {
117
+ this.emit('warn', warn);
118
+ })
116
119
  .on('error', (error) => {
117
- this.emit('warn', error);
120
+ this.emit('error', error);
118
121
  });
119
122
  }
120
123
  }
@@ -126,8 +129,8 @@ class DeviceErv extends EventEmitter {
126
129
  this.mqtt1 = new Mqtt({
127
130
  host: this.mqtt.host,
128
131
  port: this.mqtt.port || 1883,
129
- clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
130
- prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
132
+ clientId: this.mqtt.clientId ? `${this.mqtt.clientId}_${this.deviceId}` : `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
133
+ prefix: this.mqtt.prefix ? `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}` : `melcloud/${this.deviceTypeText}/${this.deviceName}`,
131
134
  user: this.mqtt.user,
132
135
  passwd: this.mqtt.pass,
133
136
  debug: this.mqtt.debug || false
@@ -150,8 +153,11 @@ class DeviceErv extends EventEmitter {
150
153
  .on('debug', (debug) => {
151
154
  this.emit('debug', debug);
152
155
  })
156
+ .on('warn', (warn) => {
157
+ this.emit('warn', warn);
158
+ })
153
159
  .on('error', (error) => {
154
- this.emit('warn', error);
160
+ this.emit('error', error);
155
161
  });
156
162
  }
157
163
  }
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;