Sleep Mode

Is there a consensus regarding the best method to determine when to enter and leave a “sleep” mode? I think it would be ideal if the presenceSensor capability type had a 3rd state called “sleeping” in addition to the existing “present” and “not present” states. Lacking that, I intend to write a SmartApp that changes modes only after all of the selected people have indicated that they are sleeping - probably via the Tasker Android app and REST API. Unless anyone knows of an existing solution or better idea… Thoughts?