I'm having the same issue, or one very similar. My HTC One (m7) recently got Lollipop, and I've had this issue ever since.
WiFi will work normally for a few hours, and then at some point I'll wake my phone up and notice that it's not connecting to WiFi. The WiFi toggle in the notification shade...