-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (29 loc) · 864 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
const config = require('./config.json');
const mqtt = require('async-mqtt');
const Ecovacs = require('./src/ecovacs')
const Bridge = require('./src/bridge')
async function main() {
console.log('Starting the Deboot bridge...')
let mqttClient;
try {
mqttClient = await mqtt.connectAsync({
host: config.mqtt.server,
port: config.mqtt.port,
username: config.mqtt.username,
password: config.mqtt.password
});
console.log('Successfully connected to the MQTT server.')
} catch (e) {
console.log('Failed to connect to the MQTT server!', e);
process.exit();
}
let eco = new Ecovacs(config.deboot.username, config.deboot.password, config.deboot.country);
try {
let bridge = new Bridge(eco, mqttClient, config.mqtt.topic);
bridge.link();
} catch (e) {
console.log(e);
}
}
main()