mqttAsync(hostname, topic, options = {}) {
        return new Promise((resolve, reject) => {
            const { port, username, password, interval = 20 } = options;

            // Adds MQTT protocol to the hostname if not already present
            if (!/^(?:http|mqtt|ws)s?:\/\//.test(hostname)) {
                hostname = "mqtt://" + hostname;
            }

            const timeoutID = setTimeout(() => {
                log.debug("mqtt", "MQTT timeout triggered");
                client.end();
                reject(new Error("Timeout, Message not received"));
            }, interval * 1000 * 0.8);

            const mqttUrl = `${hostname}:${port}`;

            log.debug("mqtt", `MQTT connecting to ${mqttUrl}`);

            let client = mqtt.connect(mqttUrl, {
                username,
                password,
                clientId: "uptime-kuma_" + Math.random().toString(16).substr(2, 8)
            });

            client.on("connect", () => {
                log.debug("mqtt", "MQTT connected");

                try {
                    client.subscribe(topic, () => {
                        log.debug("mqtt", "MQTT subscribed to topic");
                    });
                } catch (e) {
                    client.end();
                    clearTimeout(timeoutID);
                    reject(new Error("Cannot subscribe topic"));
                }
            });

            client.on("error", (error) => {
                client.end();
                clearTimeout(timeoutID);
                reject(error);
            });

            client.on("message", (messageTopic, message) => {
                if (messageTopic === topic) {
                    client.end();
                    clearTimeout(timeoutID);
                    resolve(message.toString("utf8"));
                }
            });

        });
    }
Connect to MQTT Broker, subscribe to topic and receive message as String
@param {string} hostname Hostname / address of machine to test
@param {string} topic MQTT topic
@param {object} options MQTT options. Contains port, username,
password and interval (interval defaults to 20)
@returns {Promise<string>} Received MQTT message