mqttClient = mqtt.Client(...) -- Events: "connect", "connfail", "suback", "unsuback", "puback", "message", "overflow", or "offline" mqttClient:on("message", function(client, topic, data) if data == comparedValue then -- to do else -- to do end end