This should work, if it's the last thing you do before going to sleep.
Outside of combat, we typically don't account for actions, but this invocation would require keeping track of whether you do something that would be an action. For example, you can eat during a rest, but that would use an action if done in combat, so it would break the invisibility (because the magic doesn't care whether you call it an action).
However, if the warlock goes into an enclosed, dark space, lies down, invokes the magic, and then goes to sleep, yeah, they can be invisible until waking up.
A caveat about doing this during a short rest
(not actually the question, but it seems relevant)
The short rest rules mention "tending to wounds" as a possible activity, and allow regaining hit points by spending Hit Dice, but don't actually say that you have to tend to your wounds to regain hit points. I would argue that the rules imply that wound care is an expected part of resting, and if you insist on spending the entire rest invisible instead of caring for your wounds, you can't spend Hit Dice. But depending on how your table treats the rules, and on how you interpret hit points, this could go either way.
Turning Invisible should not make a character automatically Hidden
There's a couple reasons why.
What did they roll for Stealth?
If a character is "automatically hidden", then as DM, you need to come up with a way to adjudicate any potential attempts an opposing character might make to detect their presence. You can't just have them roll a D20, because if they roll poorly, then they'd be automatically detected by the passive perception of their enemies, and wouldn't be "Automatically hidden"; that's a paradox.
And you can't necessarily just take their passive Stealth score either, since that might not be high enough to pass the passive Perception score of their enemy. And if you base it on the perception scores of their enemy, then it becomes a weird mechanical consequence where the better a creature's perception is, the better Invisibility becomes against them, which cannot be right.
It makes Stealth too easy
Assuming you resolve the previous issue, this change also makes invisibility too powerful in a combat scenario.
Under the normal rules:
- A Wizard casts Invisibility on themselves
- They then run away their maximum movement speed
- No Opportunity Attacks are triggered because Opportunity attacks require the reacting creature to be able to see their target
- The creature (and maybe some of their allies) immediately run to the Wizard's new location and attack them (with disadvantage, because unseen)
- The Wizard may or may not lose concentration if some of the attacks land
- If they kept the spell up, they take the Hide action, rolling Stealth, and then continuing to run away
- If the Stealth Score beats the enemy creatures' Passive Perception scores, they begin using the Search action to try to find the Wizard. If it doesn't, the last few steps happen again.
- Once the Wizard finally beats the Passive Perceptions of their enemies, they Search like before.
- On success, they run up to the Wizard but do not make any attacks
- On failure, they simply cannot find the Wizard
Conversely, under this rule:
- A Wizard casts Invisibility on themselves
- They run away at max speed
- No Opportunity Attacks
- The enemy creatures take the Search action (they cannot possibly succeed on their Passive Perception checks)
- On success, they run up to the Wizard but make no attacks
- On failure, they are unable to find the Wizard
Two of the most critical chances the enemy creatures had to take down the Wizard has been removed. Under the normal rules, an Invisible Wizard can be thwarted by attacks made against them, and a failed Stealth check.
Under your modified rules, neither of those are credible threats. The only thing an enemy creature has is to either succeed at their Perception checks (probably more than once before it works!) or target a random spot and hope they land a hit. That is a very significant increase in power.
"Okay, so what if turning invisible instead means they make an automatic /attempt/ to hide?"
This is a lot less overpowered, but still potentially problematic. It represents a middle ground between the normal rules and the scenario with your rule:
- A Wizard casts Invisibility on themselves
- They then run away their maximum movement speed
- No Opportunity Attacks are triggered because Opportunity attacks require the reacting creature to be able to see their target
- The Wizard gets an automatic attempt to Hide, rolling Stealth.
- If the Stealth Score beats the enemy creatures' Passive Perception scores, they begin using the Search action to try to find the Wizard. If it doesn't, they run up and make their (with disadvantage) attacks, Concentration, Hide Action, blah blah blah.
- Once the Wizard finally beats the Passive Perceptions of their enemies, they Search like before.
- On success, they run up to the Wizard but do not make any attacks
- On failure, they simply cannot find the Wizard
So it's less extreme, but it still means a lowered chance of successfully shutting down the retreating Wizard. In particular, it means that the enemy creatures probably won't get to make any attacks against them, and therefore no attempts to break concentration. That still makes Invisibility a lot more powerful.
This also steps on the toes of the Rogue, especially Arcane Trickster, class
The advantage that Rogues (and certain other classes like Ranger) gain is the ability to, among other things, take the Hide action as a Bonus Action in addition to a regular Action. So if an Arcane Trickster were to cast Invisibility during their turn, they'd then be easily able to Hide afterwards, doing as part of the features granted to them by their class/archetype something that you're now going to give for free to everyone.
Conversely, this could also make Arcane Tricksters very powerful: if they no longer need to use the Hide [Bonus-]Action, then they could do something else, like Dash or do something with their Mage Hand Legerdemain feature. No longer requiring an action to use their Stealth would free up their Action Economy significantly, and for a Rogue, that can be a dangerous thing to do.
Conclusion
The stealth rules are written the way they are for a reason, and if you're planning to change those rules, you need to have a clear conception of why you're changing them and what the consequences of that change will be. The rules for Hiding (PHB, pg. 177) specifically call out Invisibility as a condition under which hiding is "always allowed", which implies as a consequence that being Invisible does not make a creature automatically hidden:
You can't hide from a creature that can see you clearly, and if you make noise (such as shouting a warning or knocking over a vase), you give away your position. An invisible creature can't be seen, so it can always try to hide. Signs of its passage might still be noticed, however, and it still has to stay quiet.
—Hiding, PHB, pg. 177
So in general, I would not advise this change. Don't turn Invisibility into an automatic "Get out of Combat Free" card. Specializing in Stealth will already make most Invisibility uses very powerful; it's not necessary to go any further.
Best Answer
Stealth and hidden are currently very much in the court of the DM. To some degree this ability takes some of the shakiness out of the current rules and gives you a measure of certainty.
Right now, at least to me, the stealth, invisible and hidden rules indicate the following:
However, depending on the creature, and the DM's digestion, he could rule that an invisible creature's position is not known if they are being particularly quiet. To me (and in my games), this act of being quiet is the stealth check, but since making that stealth check costs an action, not all DMs may agree. A DM who disagrees and simply allows a character to "be quiet" with no stealth role or action is one for whom this ability was written (in part).
What the Ranger's power does is twofold. First it removes the disadvantage from the first case. Second it removes the ambiguity of the DM discretion. I would argue that the first thing it does is the primary element of this ability, removing disadvantage is pretty darn huge. However, the second one should not be overlooked. By putting Stealth and hidden firmly in the hands of the DM, 5e has opened itself up to this kind of interpretation. Giving a player a high level ability to negate this is an important element of that.