I arrived at a relatively simple answer which assumes that one is not "clever" about cutting down the search space with strategic guesses. I'll discuss that a little more at the end.
The probability of choosing a winning combination is:
$( {M \choose M} + {M \choose M-1} )/ {N \choose M}$
i.e. The sum of either choosing all the numbers correctly and choosing all but one correctly. For your little example, this is $(1 + 3)/4 = 1$ - so you're guaranteed to win.
So, to answer the question itself, you would need to exhaust all the non-winning combinations first then the next one wins i.e. : ${N \choose M} - ( {M \choose M} + {M \choose M-1} )+1$ minimum attempts to guarantee unlocking.
Now, your challenge is essentially the game Mastermind where N is the number of colours and M is the length of the code (with no repeats) and a win only requires M-1 (or M) pegs of any colour. The cumulative efforts of the world's minds have not come up with a neat formula for this, but Knuth came up with a 5-move strategy for standard Mastermind.