diff --git a/main.js b/main.js index fc2bf3e177e103057199775f14836051cc861266..eef21a7656a4502dd428169a921619ce34cbdf27 100644 --- a/main.js +++ b/main.js @@ -23,9 +23,8 @@ const options = { const client = mqtt.connect(`mqtt://${mqtt_host}:${mqtt_port}`, options); client.on('connect', () => { - console.log('Connected!'); - // Subscribe to a topic - client.subscribe('door/ucc-door/+', () => {}); + console.log(`Connected to MQTT broker ${mqtt_host}!`); + client.subscribe('door/#', () => {}); }); let doorState = null; @@ -33,6 +32,8 @@ let doorOpener = null; // Receive messages client.on('message', (topic, message) => { + console.log(`Received message on topic ${topic}`); + if (topic === 'door/ucc-door/state') { switch (message.toString()) { case "ON": @@ -121,7 +122,7 @@ const server = http.createServer((req, res) => { // Run the server server.listen(web_port, web_host, () => { - console.log(`Server started on http://${web_host}:${web_port}`); + console.log(`HTTP server started on http://${web_host}:${web_port}`); }); // vim: set ts=2 sts=2 sw=2 et: