I used the “Sleeptracker” app for iphone for awhile. You put the phone nearby on the bed, and it uses motion sensors to detect your duration and quality of sleep. It gives you a “score” based on sleep efficiency (whatever that means) and duration relative to your goal sleep amount.
You can also set it up to record any snoring or apnea events, which it did reasonably well. It has an alarm function that times the wakeup within a user-selectable window, presumably to wake you at the right time of your sleep cycle, if possible without going over the set wake-up time. My only complaint is that if you snooze the alarm and go back to sleep, it doesn’t include this in your sleep duration.