mirror of
https://github.com/lehanspb/tuya-mqtt.git
synced 2025-12-16 17:54:36 +00:00
Check that the configuration file exists
Signed-off-by: Gérondal Thibault <contact@tycale.be>
This commit is contained in:
13
tuya-mqtt.js
13
tuya-mqtt.js
@@ -15,8 +15,15 @@ function boolToString(istate) {
|
||||
}
|
||||
|
||||
var connected = undefined;
|
||||
var CONFIG = undefined;
|
||||
|
||||
const CONFIG = require("./config");
|
||||
try {
|
||||
CONFIG = require("./config");
|
||||
} catch (e) {
|
||||
console.error("Configuration file not found")
|
||||
debugError(e)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const mqtt_client = mqtt.connect({
|
||||
host: CONFIG.host,
|
||||
@@ -204,5 +211,5 @@ var tester = new MQTT_Tester();
|
||||
*/
|
||||
function onExit() {
|
||||
TuyaDevice.disconnectAll();
|
||||
tester.destroy();
|
||||
};
|
||||
if(tester) tester.destroy();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user