homebridge-melcloud-control 3.5.3-beta.0 → 3.6.1-beta.0
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 +11 -0
- package/index.js +46 -3
- package/package.json +2 -2
- package/src/deviceata.js +101 -77
- package/src/deviceatw.js +126 -116
- package/src/deviceerv.js +50 -113
- package/src/melcloudata.js +9 -4
- package/src/melcloudatw.js +9 -4
- package/src/melclouderv.js +9 -4
- package/src/mqtt.js +3 -3
- package/src/restful.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -16,6 +16,17 @@ 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.0] - (29.01.2025)
|
|
20
|
+
|
|
21
|
+
## Changes
|
|
22
|
+
|
|
23
|
+
- added possibility to disable/enable log success, info, warn, error
|
|
24
|
+
- refactor cnnect code
|
|
25
|
+
- bump dependencies
|
|
26
|
+
- config schema updated
|
|
27
|
+
- redme updated
|
|
28
|
+
- cleanup
|
|
29
|
+
|
|
19
30
|
## [3.5.0] - (06.12.2024)
|
|
20
31
|
|
|
21
32
|
## Changes
|
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import MelCloud from './src/melcloud.js';
|
|
|
4
4
|
import DeviceAta from './src/deviceata.js';
|
|
5
5
|
import DeviceAtw from './src/deviceatw.js';
|
|
6
6
|
import DeviceErv from './src/deviceerv.js';
|
|
7
|
+
import ImpulseGenerator from './src/impulsegenerator.js';
|
|
7
8
|
import { PluginName, PlatformName } from './src/constants.js';
|
|
8
9
|
|
|
9
10
|
class MelCloudPlatform {
|
|
@@ -154,7 +155,21 @@ class MelCloudPlatform {
|
|
|
154
155
|
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}`);
|
|
155
156
|
});
|
|
156
157
|
|
|
157
|
-
|
|
158
|
+
//create impulse generator
|
|
159
|
+
const impulseGenerator = new ImpulseGenerator();
|
|
160
|
+
impulseGenerator.on('start', async () => {
|
|
161
|
+
try {
|
|
162
|
+
const startDone = await airConditioner.start();
|
|
163
|
+
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
164
|
+
} catch (error) {
|
|
165
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}, trying again.`);
|
|
166
|
+
};
|
|
167
|
+
}).on('state', (state) => {
|
|
168
|
+
const emitLog = !enableDebugMode ? false : state ? log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator started.`) : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator stopped.`);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
//start impulse generator
|
|
172
|
+
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
158
173
|
};
|
|
159
174
|
} catch (error) {
|
|
160
175
|
throw new Error(`${accountName}, ATA did finish launching error: ${error}.`);
|
|
@@ -200,7 +215,21 @@ class MelCloudPlatform {
|
|
|
200
215
|
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}`);
|
|
201
216
|
});
|
|
202
217
|
|
|
203
|
-
|
|
218
|
+
//create impulse generator
|
|
219
|
+
const impulseGenerator = new ImpulseGenerator();
|
|
220
|
+
impulseGenerator.on('start', async () => {
|
|
221
|
+
try {
|
|
222
|
+
const startDone = await heatPump.start();
|
|
223
|
+
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
224
|
+
} catch (error) {
|
|
225
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}, trying again.`);
|
|
226
|
+
};
|
|
227
|
+
}).on('state', (state) => {
|
|
228
|
+
const emitLog = !enableDebugMode ? false : state ? log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator started.`) : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator stopped.`);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
//start impulse generator
|
|
232
|
+
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
204
233
|
};
|
|
205
234
|
} catch (error) {
|
|
206
235
|
throw new Error(`${accountName}, ATE did finish launching error: ${error}.`);
|
|
@@ -246,7 +275,21 @@ class MelCloudPlatform {
|
|
|
246
275
|
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}`);
|
|
247
276
|
});
|
|
248
277
|
|
|
249
|
-
|
|
278
|
+
//create impulse generator
|
|
279
|
+
const impulseGenerator = new ImpulseGenerator();
|
|
280
|
+
impulseGenerator.on('start', async () => {
|
|
281
|
+
try {
|
|
282
|
+
const startDone = await energyRecoveryVentilation.start();
|
|
283
|
+
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
284
|
+
} catch (error) {
|
|
285
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}, trying again.`);
|
|
286
|
+
};
|
|
287
|
+
}).on('state', (state) => {
|
|
288
|
+
const emitLog = !enableDebugMode ? false : state ? log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator started.`) : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator stopped.`);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
//start impulse generator
|
|
292
|
+
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
250
293
|
};
|
|
251
294
|
} catch (error) {
|
|
252
295
|
throw new Error(`${accountName}, ERV did finish launching error: ${error}.`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.6.1-beta.0",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"LICENSE"
|
|
32
32
|
],
|
|
33
33
|
"engines": {
|
|
34
|
-
"homebridge": "^1.
|
|
34
|
+
"homebridge": "^1.8.5 || ^2.0.0-beta.0",
|
|
35
35
|
"node": "^18.20.4 || ^20.15.1 || ^22.7.0 || ^23.2.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
package/src/deviceata.js
CHANGED
|
@@ -90,6 +90,9 @@ class DeviceAta extends EventEmitter {
|
|
|
90
90
|
}
|
|
91
91
|
this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
|
|
92
92
|
|
|
93
|
+
//device data
|
|
94
|
+
this.deviceData = {};
|
|
95
|
+
|
|
93
96
|
//accessory
|
|
94
97
|
this.accessory = {};
|
|
95
98
|
this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
@@ -175,6 +178,78 @@ class DeviceAta extends EventEmitter {
|
|
|
175
178
|
};
|
|
176
179
|
}
|
|
177
180
|
|
|
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
|
+
|
|
178
253
|
//prepare accessory
|
|
179
254
|
async prepareAccessory(accountInfo, deviceData, deviceId, deviceTypeText, deviceName, accountName) {
|
|
180
255
|
try {
|
|
@@ -859,84 +934,11 @@ class DeviceAta extends EventEmitter {
|
|
|
859
934
|
contextKey: this.contextKey,
|
|
860
935
|
devicesFile: this.devicesFile,
|
|
861
936
|
deviceId: this.deviceId,
|
|
862
|
-
|
|
937
|
+
enableDebugMode: this.enableDebugMode
|
|
863
938
|
});
|
|
864
939
|
|
|
865
940
|
this.melCloudAta.on('externalIntegrations', (deviceData) => {
|
|
866
|
-
try {
|
|
867
|
-
//RESTFul server
|
|
868
|
-
const restFulEnabled = this.restFul.enable || false;
|
|
869
|
-
if (restFulEnabled) {
|
|
870
|
-
if (!this.restFulConnected) {
|
|
871
|
-
this.restFul1 = new RestFul({
|
|
872
|
-
port: this.deviceId.slice(-4),
|
|
873
|
-
debug: this.restFul.debug || false
|
|
874
|
-
});
|
|
875
941
|
|
|
876
|
-
this.restFul1.on('connected', (message) => {
|
|
877
|
-
this.restFulConnected = true;
|
|
878
|
-
this.emit('success', message);
|
|
879
|
-
})
|
|
880
|
-
.on('set', async (key, value) => {
|
|
881
|
-
try {
|
|
882
|
-
await this.setOverExternalIntegration('RESTFul', deviceData, key, value);
|
|
883
|
-
} catch (error) {
|
|
884
|
-
this.emit('warn', error);
|
|
885
|
-
};
|
|
886
|
-
})
|
|
887
|
-
.on('debug', (debug) => {
|
|
888
|
-
this.emit('debug', debug);
|
|
889
|
-
})
|
|
890
|
-
.on('error', (error) => {
|
|
891
|
-
this.emit('warn', error);
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
const restFul0 = this.restFulConnected ? this.restFul1.update('info', deviceData) : false;
|
|
895
|
-
const restFul1 = this.restFulConnected ? this.restFul1.update('state', deviceData.Device) : false;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
//MQTT client
|
|
899
|
-
const mqttEnabled = this.mqtt.enable || false;
|
|
900
|
-
if (mqttEnabled) {
|
|
901
|
-
if (!this.mqttConnected) {
|
|
902
|
-
this.mqtt1 = new Mqtt({
|
|
903
|
-
host: this.mqtt.host,
|
|
904
|
-
port: this.mqtt.port || 1883,
|
|
905
|
-
clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
|
|
906
|
-
prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
|
|
907
|
-
user: this.mqtt.user,
|
|
908
|
-
passwd: this.mqtt.pass,
|
|
909
|
-
debug: this.mqtt.debug || false
|
|
910
|
-
});
|
|
911
|
-
|
|
912
|
-
this.mqtt1.on('connected', (message) => {
|
|
913
|
-
this.mqttConnected = true;
|
|
914
|
-
this.emit('success', message);
|
|
915
|
-
})
|
|
916
|
-
.on('subscribed', (message) => {
|
|
917
|
-
this.emit('success', message);
|
|
918
|
-
})
|
|
919
|
-
.on('set', async (key, value) => {
|
|
920
|
-
try {
|
|
921
|
-
await this.setOverExternalIntegration('MQTT', deviceData, key, value);
|
|
922
|
-
} catch (error) {
|
|
923
|
-
this.emit('warn', error);
|
|
924
|
-
};
|
|
925
|
-
})
|
|
926
|
-
.on('debug', (debug) => {
|
|
927
|
-
this.emit('debug', debug);
|
|
928
|
-
})
|
|
929
|
-
.on('error', (error) => {
|
|
930
|
-
this.emit('warn', error);
|
|
931
|
-
});
|
|
932
|
-
}
|
|
933
|
-
const mqtt0 = this.mqttConnected ? this.mqtt1.emit('publish', `Info`, deviceData) : false;
|
|
934
|
-
const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`, deviceData.Device) : false;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
} catch (error) {
|
|
938
|
-
this.emit('warn', `External integration start error: ${error}.`);
|
|
939
|
-
};
|
|
940
942
|
})
|
|
941
943
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
942
944
|
if (!this.displayDeviceInfo) {
|
|
@@ -962,6 +964,8 @@ class DeviceAta extends EventEmitter {
|
|
|
962
964
|
this.displayDeviceInfo = false;
|
|
963
965
|
})
|
|
964
966
|
.on('deviceState', async (deviceData) => {
|
|
967
|
+
this.deviceData = deviceData;
|
|
968
|
+
|
|
965
969
|
//presets
|
|
966
970
|
const presetsOnServer = deviceData.Presets ?? [];
|
|
967
971
|
|
|
@@ -1384,13 +1388,33 @@ class DeviceAta extends EventEmitter {
|
|
|
1384
1388
|
})
|
|
1385
1389
|
.on('error', (error) => {
|
|
1386
1390
|
this.emit('error', error);
|
|
1391
|
+
})
|
|
1392
|
+
.on('restFul', (path, data) => {
|
|
1393
|
+
const restFul = this.restFulConnected ? this.restFul1.update(path, data) : false;
|
|
1394
|
+
})
|
|
1395
|
+
.on('mqtt', (topic, message) => {
|
|
1396
|
+
const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', topic, message) : false;
|
|
1387
1397
|
});
|
|
1388
1398
|
|
|
1399
|
+
//start external integrations
|
|
1400
|
+
const startExternalIntegrations = this.restFul.enable || this.mqtt.enable ? await this.externalIntegrations() : false;
|
|
1401
|
+
|
|
1389
1402
|
//check state
|
|
1390
|
-
await this.melCloudAta.checkState();
|
|
1403
|
+
const deviceData = await this.melCloudAta.checkState();
|
|
1404
|
+
|
|
1405
|
+
if (deviceData === false) {
|
|
1406
|
+
return false;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
//prepare accessory
|
|
1410
|
+
if (this.startPrepareAccessory) {
|
|
1411
|
+
const accessory = await this.prepareAccessory(this.accountInfo, deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
1412
|
+
this.emit('publishAccessory', accessory);
|
|
1413
|
+
this.startPrepareAccessory = false;
|
|
1391
1414
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1415
|
+
//start impule generator
|
|
1416
|
+
await this.melCloudAta.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
1417
|
+
}
|
|
1394
1418
|
|
|
1395
1419
|
return true;
|
|
1396
1420
|
} catch (error) {
|
package/src/deviceatw.js
CHANGED
|
@@ -94,6 +94,9 @@ class DeviceAtw extends EventEmitter {
|
|
|
94
94
|
}
|
|
95
95
|
this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
|
|
96
96
|
|
|
97
|
+
//device data
|
|
98
|
+
this.deviceData = {};
|
|
99
|
+
|
|
97
100
|
//accessory
|
|
98
101
|
this.accessory = { zones: [{}, {}, {}, {}] };
|
|
99
102
|
this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
@@ -198,6 +201,79 @@ class DeviceAtw extends EventEmitter {
|
|
|
198
201
|
throw new Error(`${integration} set key: ${key}, value: ${value}, error: ${error.message ?? error}`);
|
|
199
202
|
};
|
|
200
203
|
}
|
|
204
|
+
|
|
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
|
+
|
|
201
277
|
//prepare accessory
|
|
202
278
|
async prepareAccessory(accountInfo, deviceData, deviceId, deviceTypeText, deviceName, accountName) {
|
|
203
279
|
try {
|
|
@@ -1215,111 +1291,38 @@ class DeviceAtw extends EventEmitter {
|
|
|
1215
1291
|
contextKey: this.contextKey,
|
|
1216
1292
|
devicesFile: this.devicesFile,
|
|
1217
1293
|
deviceId: this.deviceId,
|
|
1218
|
-
|
|
1294
|
+
enableDebugMode: this.enableDebugMode
|
|
1219
1295
|
});
|
|
1220
1296
|
|
|
1221
|
-
this.melCloudAtw.on('
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
await this.setOverExternalIntegration('RESTFul', deviceData, key, value);
|
|
1239
|
-
} catch (error) {
|
|
1240
|
-
this.emit('warn', error);
|
|
1241
|
-
};
|
|
1242
|
-
})
|
|
1243
|
-
.on('debug', (debug) => {
|
|
1244
|
-
this.emit('debug', debug);
|
|
1245
|
-
})
|
|
1246
|
-
.on('error', (error) => {
|
|
1247
|
-
this.emit('warn', error);
|
|
1248
|
-
});
|
|
1249
|
-
}
|
|
1250
|
-
const restFul0 = this.restFulConnected ? this.restFul1.update('info', deviceData) : false;
|
|
1251
|
-
const restFul1 = this.restFulConnected ? this.restFul1.update('state', deviceData.Device) : false;
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
//MQTT client
|
|
1255
|
-
const mqttEnabled = this.mqtt.enable || false;
|
|
1256
|
-
if (mqttEnabled) {
|
|
1257
|
-
if (!this.mqttConnected) {
|
|
1258
|
-
this.mqtt1 = new Mqtt({
|
|
1259
|
-
host: this.mqtt.host,
|
|
1260
|
-
port: this.mqtt.port || 1883,
|
|
1261
|
-
clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
|
|
1262
|
-
prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
|
|
1263
|
-
user: this.mqtt.user,
|
|
1264
|
-
passwd: this.mqtt.pass,
|
|
1265
|
-
debug: this.mqtt.debug || false
|
|
1266
|
-
});
|
|
1267
|
-
|
|
1268
|
-
this.mqtt1.on('connected', (message) => {
|
|
1269
|
-
this.mqttConnected = true;
|
|
1270
|
-
this.emit('success', message);
|
|
1271
|
-
})
|
|
1272
|
-
.on('subscribed', (message) => {
|
|
1273
|
-
this.emit('success', message);
|
|
1274
|
-
})
|
|
1275
|
-
.on('set', async (key, value) => {
|
|
1276
|
-
try {
|
|
1277
|
-
await this.setOverExternalIntegration('MQTT', deviceData, key, value);
|
|
1278
|
-
} catch (error) {
|
|
1279
|
-
this.emit('warn', error);
|
|
1280
|
-
};
|
|
1281
|
-
})
|
|
1282
|
-
.on('debug', (debug) => {
|
|
1283
|
-
this.emit('debug', debug);
|
|
1284
|
-
})
|
|
1285
|
-
.on('error', (error) => {
|
|
1286
|
-
this.emit('warn', error);
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
const mqtt0 = this.mqttConnected ? this.mqtt1.emit('publish', `Info`, deviceData) : false;
|
|
1290
|
-
const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`, deviceData.Device) : false;
|
|
1291
|
-
}
|
|
1292
|
-
} catch (error) {
|
|
1293
|
-
this.emit('warn', `External integration start error: ${error}.`);
|
|
1297
|
+
this.melCloudAtw.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, hasHotWaterTank, hasZone2) => {
|
|
1298
|
+
if (!this.displayDeviceInfo) {
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
if (!this.disableLogDeviceInfo) {
|
|
1303
|
+
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
1304
|
+
this.emit('devInfo', `Account: ${this.accountName}`);
|
|
1305
|
+
const indoor = modelIndoor ? this.emit('devInfo', `Indoor: ${modelIndoor}`) : false;
|
|
1306
|
+
const outdoor = modelOutdoor ? this.emit('devInfo', `Outdoor: ${modelOutdoor}`) : false
|
|
1307
|
+
this.emit('devInfo', `Serial: ${serialNumber}`)
|
|
1308
|
+
this.emit('devInfo', `Firmware: ${firmwareAppVersion}`);
|
|
1309
|
+
this.emit('devInfo', `Manufacturer: ${manufacturer}`);
|
|
1310
|
+
this.emit('devInfo', '----------------------------------');
|
|
1311
|
+
this.emit('devInfo', `Hot Water Tank: ${hasHotWaterTank ? 'Yes' : 'No'}`);
|
|
1312
|
+
this.emit('devInfo', `Zone 2: ${hasZone2 ? 'Yes' : 'No'}`);
|
|
1313
|
+
this.emit('devInfo', '----------------------------------');
|
|
1294
1314
|
};
|
|
1295
|
-
})
|
|
1296
|
-
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, hasHotWaterTank, hasZone2) => {
|
|
1297
|
-
if (!this.displayDeviceInfo) {
|
|
1298
|
-
return;
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
if (!this.disableLogDeviceInfo) {
|
|
1302
|
-
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
1303
|
-
this.emit('devInfo', `Account: ${this.accountName}`);
|
|
1304
|
-
const indoor = modelIndoor ? this.emit('devInfo', `Indoor: ${modelIndoor}`) : false;
|
|
1305
|
-
const outdoor = modelOutdoor ? this.emit('devInfo', `Outdoor: ${modelOutdoor}`) : false
|
|
1306
|
-
this.emit('devInfo', `Serial: ${serialNumber}`)
|
|
1307
|
-
this.emit('devInfo', `Firmware: ${firmwareAppVersion}`);
|
|
1308
|
-
this.emit('devInfo', `Manufacturer: ${manufacturer}`);
|
|
1309
|
-
this.emit('devInfo', '----------------------------------');
|
|
1310
|
-
this.emit('devInfo', `Hot Water Tank: ${hasHotWaterTank ? 'Yes' : 'No'}`);
|
|
1311
|
-
this.emit('devInfo', `Zone 2: ${hasZone2 ? 'Yes' : 'No'}`);
|
|
1312
|
-
this.emit('devInfo', '----------------------------------');
|
|
1313
|
-
};
|
|
1314
1315
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1316
|
+
//accessory info
|
|
1317
|
+
this.manufacturer = manufacturer;
|
|
1318
|
+
this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${this.deviceTypeText} ${this.deviceId}`;
|
|
1319
|
+
this.serialNumber = serialNumber;
|
|
1320
|
+
this.firmwareRevision = firmwareAppVersion;
|
|
1321
|
+
this.displayDeviceInfo = false;
|
|
1322
|
+
})
|
|
1322
1323
|
.on('deviceState', async (deviceData) => {
|
|
1324
|
+
this.deviceData = deviceData;
|
|
1325
|
+
|
|
1323
1326
|
//presets
|
|
1324
1327
|
const presetsOnServer = deviceData.Presets ?? [];
|
|
1325
1328
|
|
|
@@ -1900,19 +1903,6 @@ class DeviceAtw extends EventEmitter {
|
|
|
1900
1903
|
};
|
|
1901
1904
|
};
|
|
1902
1905
|
};
|
|
1903
|
-
|
|
1904
|
-
//start prepare accessory
|
|
1905
|
-
if (!this.startPrepareAccessory) {
|
|
1906
|
-
return;
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
try {
|
|
1910
|
-
const accessory = await this.prepareAccessory(this.accountInfo, deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
1911
|
-
this.emit('publishAccessory', accessory);
|
|
1912
|
-
this.startPrepareAccessory = false;
|
|
1913
|
-
} catch (error) {
|
|
1914
|
-
this.emit('error', error);
|
|
1915
|
-
};
|
|
1916
1906
|
})
|
|
1917
1907
|
.on('success', (success) => {
|
|
1918
1908
|
this.emit('success', success);
|
|
@@ -1928,13 +1918,33 @@ class DeviceAtw extends EventEmitter {
|
|
|
1928
1918
|
})
|
|
1929
1919
|
.on('error', (error) => {
|
|
1930
1920
|
this.emit('error', error);
|
|
1921
|
+
})
|
|
1922
|
+
.on('restFul', (path, data) => {
|
|
1923
|
+
const restFul = this.restFulConnected ? this.restFul1.update(path, data) : false;
|
|
1924
|
+
})
|
|
1925
|
+
.on('mqtt', (topic, message) => {
|
|
1926
|
+
const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', topic, message) : false;
|
|
1931
1927
|
});
|
|
1932
1928
|
|
|
1929
|
+
//start external integrations
|
|
1930
|
+
const startExternalIntegrations = this.restFul.enable || this.mqtt.enable ? await this.externalIntegrations() : false;
|
|
1931
|
+
|
|
1933
1932
|
//check state
|
|
1934
|
-
await this.melCloudAtw.checkState();
|
|
1933
|
+
const deviceData = await this.melCloudAtw.checkState();
|
|
1934
|
+
|
|
1935
|
+
if (deviceData === false) {
|
|
1936
|
+
return false;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
//prepare accessory
|
|
1940
|
+
if (this.startPrepareAccessory) {
|
|
1941
|
+
const accessory = await this.prepareAccessory(this.accountInfo, deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
1942
|
+
this.emit('publishAccessory', accessory);
|
|
1943
|
+
this.startPrepareAccessory = false;
|
|
1935
1944
|
|
|
1936
|
-
|
|
1937
|
-
|
|
1945
|
+
//start impule generator
|
|
1946
|
+
await this.melCloudAtw.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
1947
|
+
}
|
|
1938
1948
|
|
|
1939
1949
|
return true;
|
|
1940
1950
|
} catch (error) {
|
package/src/deviceerv.js
CHANGED
|
@@ -88,6 +88,9 @@ class DeviceErv extends EventEmitter {
|
|
|
88
88
|
}
|
|
89
89
|
this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
|
|
90
90
|
|
|
91
|
+
//device data
|
|
92
|
+
this.deviceData = {};
|
|
93
|
+
|
|
91
94
|
//accessory
|
|
92
95
|
this.accessory = {};
|
|
93
96
|
this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
@@ -780,108 +783,35 @@ class DeviceErv extends EventEmitter {
|
|
|
780
783
|
contextKey: this.contextKey,
|
|
781
784
|
devicesFile: this.devicesFile,
|
|
782
785
|
deviceId: this.deviceId,
|
|
783
|
-
|
|
786
|
+
enableDebugMode: this.enableDebugMode
|
|
784
787
|
});
|
|
785
788
|
|
|
786
|
-
this.melCloudErv.on('
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
})
|
|
801
|
-
.on('set', async (key, value) => {
|
|
802
|
-
try {
|
|
803
|
-
await this.setOverExternalIntegration('RESTFul', deviceData, key, value);
|
|
804
|
-
} catch (error) {
|
|
805
|
-
this.emit('warn', error);
|
|
806
|
-
};
|
|
807
|
-
})
|
|
808
|
-
.on('debug', (debug) => {
|
|
809
|
-
this.emit('debug', debug);
|
|
810
|
-
})
|
|
811
|
-
.on('error', (error) => {
|
|
812
|
-
this.emit('warn', error);
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
const restFul0 = this.restFulConnected ? this.restFul1.update('info', deviceData) : false;
|
|
816
|
-
const restFul1 = this.restFulConnected ? this.restFul1.update('state', deviceData.Device) : false;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
//MQTT client
|
|
820
|
-
const mqttEnabled = this.mqtt.enable || false;
|
|
821
|
-
if (mqttEnabled) {
|
|
822
|
-
if (!this.mqttConnected) {
|
|
823
|
-
this.mqtt1 = new Mqtt({
|
|
824
|
-
host: this.mqtt.host,
|
|
825
|
-
port: this.mqtt.port || 1883,
|
|
826
|
-
clientId: `${this.mqtt.clientId}_${this.deviceId}` || `${this.deviceTypeText}_${this.deviceName}_${this.deviceId}`,
|
|
827
|
-
prefix: `${this.mqtt.prefix}/${this.deviceTypeText}/${this.deviceName}`,
|
|
828
|
-
user: this.mqtt.user,
|
|
829
|
-
passwd: this.mqtt.pass,
|
|
830
|
-
debug: this.mqtt.debug || false
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
this.mqtt1.on('connected', (message) => {
|
|
834
|
-
this.mqttConnected = true;
|
|
835
|
-
this.emit('success', message);
|
|
836
|
-
})
|
|
837
|
-
.on('subscribed', (message) => {
|
|
838
|
-
this.emit('success', message);
|
|
839
|
-
})
|
|
840
|
-
.on('set', async (key, value) => {
|
|
841
|
-
try {
|
|
842
|
-
await this.setOverExternalIntegration('MQTT', deviceData, key, value);
|
|
843
|
-
} catch (error) {
|
|
844
|
-
this.emit('warn', error);
|
|
845
|
-
};
|
|
846
|
-
})
|
|
847
|
-
.on('debug', (debug) => {
|
|
848
|
-
this.emit('debug', debug);
|
|
849
|
-
})
|
|
850
|
-
.on('error', (error) => {
|
|
851
|
-
this.emit('warn', error);
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
const mqtt0 = this.mqttConnected ? this.mqtt1.emit('publish', `Info`, deviceData) : false;
|
|
855
|
-
const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`, deviceData.Device) : false;
|
|
856
|
-
}
|
|
857
|
-
} catch (error) {
|
|
858
|
-
this.emit('warn', `External integration start error: ${error}.`);
|
|
789
|
+
this.melCloudErv.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
790
|
+
if (!this.displayDeviceInfo) {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
if (!this.disableLogDeviceInfo) {
|
|
795
|
+
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
796
|
+
this.emit('devInfo', `Account: ${this.accountName}`);
|
|
797
|
+
const indoor = modelIndoor ? this.emit('devInfo', `Indoor: ${modelIndoor}`) : false;
|
|
798
|
+
const outdoor = modelOutdoor ? this.emit('devInfo', `Outdoor: ${modelOutdoor}`) : false;
|
|
799
|
+
this.emit('devInfo', `Serial: ${serialNumber}`);
|
|
800
|
+
this.emit('devInfo', `Firmware: ${firmwareAppVersion}`);
|
|
801
|
+
this.emit('devInfo', `Manufacturer: ${manufacturer}`);
|
|
802
|
+
this.emit('devInfo', '----------------------------------');
|
|
859
803
|
};
|
|
860
|
-
})
|
|
861
|
-
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
862
|
-
if (!this.displayDeviceInfo) {
|
|
863
|
-
return;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
if (!this.disableLogDeviceInfo) {
|
|
867
|
-
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
868
|
-
this.emit('devInfo', `Account: ${this.accountName}`);
|
|
869
|
-
const indoor = modelIndoor ? this.emit('devInfo', `Indoor: ${modelIndoor}`) : false;
|
|
870
|
-
const outdoor = modelOutdoor ? this.emit('devInfo', `Outdoor: ${modelOutdoor}`) : false;
|
|
871
|
-
this.emit('devInfo', `Serial: ${serialNumber}`);
|
|
872
|
-
this.emit('devInfo', `Firmware: ${firmwareAppVersion}`);
|
|
873
|
-
this.emit('devInfo', `Manufacturer: ${manufacturer}`);
|
|
874
|
-
this.emit('devInfo', '----------------------------------');
|
|
875
|
-
};
|
|
876
804
|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
805
|
+
//accessory info
|
|
806
|
+
this.manufacturer = manufacturer;
|
|
807
|
+
this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${this.deviceTypeText} ${this.deviceId}`;
|
|
808
|
+
this.serialNumber = serialNumber;
|
|
809
|
+
this.firmwareRevision = firmwareAppVersion;
|
|
810
|
+
this.displayDeviceInfo = false;
|
|
811
|
+
})
|
|
884
812
|
.on('deviceState', async (deviceData) => {
|
|
813
|
+
this.deviceData = deviceData;
|
|
814
|
+
|
|
885
815
|
//presets
|
|
886
816
|
const presetsOnServer = deviceData.Presets ?? [];
|
|
887
817
|
|
|
@@ -1224,19 +1154,6 @@ class DeviceErv extends EventEmitter {
|
|
|
1224
1154
|
const info7 = hasPM25Sensor ? this.emit('message', `PM2.5 air quality: ${Ventilation.PM25AirQuality[pM25AirQuality]}`) : false;
|
|
1225
1155
|
const info8 = hasPM25Sensor ? this.emit('message', `PM2.5 level: ${pM25Level} µg/m`) : false;
|
|
1226
1156
|
};
|
|
1227
|
-
|
|
1228
|
-
//start prepare accessory
|
|
1229
|
-
if (!this.startPrepareAccessory) {
|
|
1230
|
-
return;
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
try {
|
|
1234
|
-
const accessory = await this.prepareAccessory(this.accountInfo, deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
1235
|
-
this.emit('publishAccessory', accessory);
|
|
1236
|
-
this.startPrepareAccessory = false;
|
|
1237
|
-
} catch (error) {
|
|
1238
|
-
this.emit('error', error);
|
|
1239
|
-
};
|
|
1240
1157
|
})
|
|
1241
1158
|
.on('success', (success) => {
|
|
1242
1159
|
this.emit('success', success);
|
|
@@ -1252,13 +1169,33 @@ class DeviceErv extends EventEmitter {
|
|
|
1252
1169
|
})
|
|
1253
1170
|
.on('error', (error) => {
|
|
1254
1171
|
this.emit('error', error);
|
|
1172
|
+
})
|
|
1173
|
+
.on('restFul', (path, data) => {
|
|
1174
|
+
const restFul = this.restFulConnected ? this.restFul1.update(path, data) : false;
|
|
1175
|
+
})
|
|
1176
|
+
.on('mqtt', (topic, message) => {
|
|
1177
|
+
const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', topic, message) : false;
|
|
1255
1178
|
});
|
|
1256
1179
|
|
|
1180
|
+
//start external integrations
|
|
1181
|
+
const startExternalIntegrations = this.restFul.enable || this.mqtt.enable ? await this.externalIntegrations() : false;
|
|
1182
|
+
|
|
1257
1183
|
//check state
|
|
1258
|
-
await this.melCloudErv.checkState();
|
|
1184
|
+
const deviceData = await this.melCloudErv.checkState();
|
|
1259
1185
|
|
|
1260
|
-
|
|
1261
|
-
|
|
1186
|
+
if (deviceData === false) {
|
|
1187
|
+
return false;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
//prepare accessory
|
|
1191
|
+
if (this.startPrepareAccessory) {
|
|
1192
|
+
const accessory = await this.prepareAccessory(this.accountInfo, deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
1193
|
+
this.emit('publishAccessory', accessory);
|
|
1194
|
+
this.startPrepareAccessory = false;
|
|
1195
|
+
|
|
1196
|
+
//start impule generator
|
|
1197
|
+
await this.melCloudErv.impulseGenerator.start([{ name: 'checkState', sampling: this.refreshInterval }]);
|
|
1198
|
+
}
|
|
1262
1199
|
|
|
1263
1200
|
return true;
|
|
1264
1201
|
} catch (error) {
|
package/src/melcloudata.js
CHANGED
|
@@ -49,7 +49,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
49
49
|
|
|
50
50
|
if (!Array.isArray(devicesData)) {
|
|
51
51
|
this.emit('warn', `Device data not found.`);
|
|
52
|
-
return;
|
|
52
|
+
return false;
|
|
53
53
|
}
|
|
54
54
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
55
55
|
const debug = this.enableDebugMode ? this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`) : false;
|
|
@@ -340,8 +340,13 @@ class MelCloudAta extends EventEmitter {
|
|
|
340
340
|
}
|
|
341
341
|
this.deviceState = deviceState;
|
|
342
342
|
|
|
343
|
-
//
|
|
344
|
-
this.emit('
|
|
343
|
+
//restFul
|
|
344
|
+
this.emit('restFul', 'info', deviceData);
|
|
345
|
+
this.emit('restFul', 'state', deviceData.Device);
|
|
346
|
+
|
|
347
|
+
//mqtt
|
|
348
|
+
this.emit('mqtt', 'Info', deviceData);
|
|
349
|
+
this.emit('mqtt', 'State', deviceData.Device);
|
|
345
350
|
|
|
346
351
|
//emit info
|
|
347
352
|
this.emit('deviceInfo', manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion);
|
|
@@ -349,7 +354,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
349
354
|
//emit state
|
|
350
355
|
this.emit('deviceState', deviceData);
|
|
351
356
|
|
|
352
|
-
return
|
|
357
|
+
return deviceData;
|
|
353
358
|
} catch (error) {
|
|
354
359
|
throw new Error(`Check state error: ${error.message || error}`);
|
|
355
360
|
};
|
package/src/melcloudatw.js
CHANGED
|
@@ -49,7 +49,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
49
49
|
|
|
50
50
|
if (!Array.isArray(devicesData)) {
|
|
51
51
|
this.emit('warn', `Device data not found.`);
|
|
52
|
-
return;
|
|
52
|
+
return false;
|
|
53
53
|
}
|
|
54
54
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
55
55
|
const debug = this.enableDebugMode ? this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`) : false;
|
|
@@ -404,8 +404,13 @@ class MelCloudAtw extends EventEmitter {
|
|
|
404
404
|
}
|
|
405
405
|
this.deviceState = deviceState;
|
|
406
406
|
|
|
407
|
-
//
|
|
408
|
-
this.emit('
|
|
407
|
+
//restFul
|
|
408
|
+
this.emit('restFul', 'info', deviceData);
|
|
409
|
+
this.emit('restFul', 'state', deviceData.Device);
|
|
410
|
+
|
|
411
|
+
//mqtt
|
|
412
|
+
this.emit('mqtt', 'Info', deviceData);
|
|
413
|
+
this.emit('mqtt', 'State', deviceData.Device);
|
|
409
414
|
|
|
410
415
|
//emit info
|
|
411
416
|
this.emit('deviceInfo', manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, hasHotWaterTank, hasZone2);
|
|
@@ -413,7 +418,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
413
418
|
//emit state
|
|
414
419
|
this.emit('deviceState', deviceData);
|
|
415
420
|
|
|
416
|
-
return
|
|
421
|
+
return deviceData;
|
|
417
422
|
} catch (error) {
|
|
418
423
|
throw new Error(`Check state error: ${error.message || error}`);
|
|
419
424
|
};
|
package/src/melclouderv.js
CHANGED
|
@@ -49,7 +49,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
49
49
|
|
|
50
50
|
if (!Array.isArray(devicesData)) {
|
|
51
51
|
this.emit('warn', `Device data not found.`);
|
|
52
|
-
return;
|
|
52
|
+
return false;
|
|
53
53
|
}
|
|
54
54
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
55
55
|
const debug = this.enableDebugMode ? this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`) : false;
|
|
@@ -328,8 +328,13 @@ class MelCloudErv extends EventEmitter {
|
|
|
328
328
|
}
|
|
329
329
|
this.deviceState = deviceState;
|
|
330
330
|
|
|
331
|
-
//
|
|
332
|
-
this.emit('
|
|
331
|
+
//restFul
|
|
332
|
+
this.emit('restFul', 'info', deviceData);
|
|
333
|
+
this.emit('restFul', 'state', deviceData.Device);
|
|
334
|
+
|
|
335
|
+
//mqtt
|
|
336
|
+
this.emit('mqtt', 'Info', deviceData);
|
|
337
|
+
this.emit('mqtt', 'State', deviceData.Device);
|
|
333
338
|
|
|
334
339
|
//emit info
|
|
335
340
|
this.emit('deviceInfo', manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion);
|
|
@@ -337,7 +342,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
337
342
|
//emit state
|
|
338
343
|
this.emit('deviceState', deviceData);
|
|
339
344
|
|
|
340
|
-
return
|
|
345
|
+
return deviceData;
|
|
341
346
|
} catch (error) {
|
|
342
347
|
throw new Error(`Check state error: ${error.message || error}`);
|
|
343
348
|
};
|
package/src/mqtt.js
CHANGED
|
@@ -32,11 +32,11 @@ class Mqtt extends EventEmitter {
|
|
|
32
32
|
const value = Object.values(obj)[0];
|
|
33
33
|
this.emit('set', key, value);
|
|
34
34
|
} catch (error) {
|
|
35
|
-
this.emit('
|
|
35
|
+
this.emit('warn', `MQTT Parse object error: ${error}`);
|
|
36
36
|
};
|
|
37
37
|
});
|
|
38
38
|
} catch (error) {
|
|
39
|
-
this.emit('
|
|
39
|
+
this.emit('warn', `MQTT Connect error: ${error}`);
|
|
40
40
|
};
|
|
41
41
|
}).on('publish', async (topic, message) => {
|
|
42
42
|
try {
|
|
@@ -45,7 +45,7 @@ class Mqtt extends EventEmitter {
|
|
|
45
45
|
await this.mqttClient.publish(fullTopic, publishMessage);
|
|
46
46
|
const emitDebug = config.debug ? this.emit('debug', `MQTT Publish topic: ${fullTopic}, message: ${publishMessage}`) : false;
|
|
47
47
|
} catch (error) {
|
|
48
|
-
this.emit('
|
|
48
|
+
this.emit('warn', `MQTT Publish error: ${error}`);
|
|
49
49
|
};
|
|
50
50
|
});
|
|
51
51
|
|
package/src/restful.js
CHANGED
|
@@ -33,7 +33,7 @@ class RestFul extends EventEmitter {
|
|
|
33
33
|
this.emit('set', key, value);
|
|
34
34
|
res.send('OK');
|
|
35
35
|
} catch (error) {
|
|
36
|
-
this.emit('
|
|
36
|
+
this.emit('warn', `RESTFul Parse object error: ${error}`);
|
|
37
37
|
};
|
|
38
38
|
});
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ class RestFul extends EventEmitter {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
} catch (error) {
|
|
45
|
-
this.emit('
|
|
45
|
+
this.emit('warn', `RESTful Connect error: ${error}`)
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
|
|
@@ -55,7 +55,7 @@ class RestFul extends EventEmitter {
|
|
|
55
55
|
this.restFulData.state = data;
|
|
56
56
|
break;
|
|
57
57
|
default:
|
|
58
|
-
this.emit('
|
|
58
|
+
this.emit('warn', `Unknown RESTFul update path: ${path}, data: ${data}`)
|
|
59
59
|
break;
|
|
60
60
|
};
|
|
61
61
|
const emitDebug = this.restFulDebug ? this.emit('debug', `RESTFul update path: ${path}, data: ${data}`) : false;
|