I found myself curious recently if I had enough sleep. There are, of course, a variety of ways to track sleep on your devices, including many third-party applications. Apple even added a Bedtime feature that lets you remind when it's time for bed, and when you get up, log in time in the Health app.
After trying it for For a while, there were a few things that frustrated me about the approach. The goal of the Bedtime feature is to get you going to lie down at the same time, and it's not something I can always control. It is very inflexible and prescriptive in a way that I found annoying to the point that I eventually just stopped using it.
What I really wanted was that iOS should be a little more intelligent. For example, it may realize that when I turn off my bedside lamp (which is a HomeKit-compatible Philips Hue bulb), I go to bed. And then, when I pick up my phone in the morning, it may log that I'm awake and store the resulting information in the Health app.
Unfortunately, this functionality does not exist. So I did it myself with a few shortcuts.
The bedtime shortcut, which can be triggered via the shortcut widget or Siri, sets the Good Night scene, turns off my bedroom, and stores the current time in a text file in iCloud Drive.
I'm up shortcut, which I manually trigger when I wake up in the morning, reading bedtime from that text file, getting the current time, and logging into the health program along with calculating the difference between two and giving a notice of how long I slept. (Although Get Time Between Dates actions in shortcuts only lets you select hours or minutes, and in the previous case, it rounds off.)
These shortcuts are pretty simple, but they get the job done. On the chance that others look for something similar, I have included the links above. The only changes you have to make are the HomeKit scene you want to set for Bedtime, if any. (You can also change the location or name of the bedtime text file, just remember to change it in both shortcuts.)
[ If you appreciate articles like this, we will continue to make Six Colors (and get some fun benefits) by becoming a Six Colors subscriber. ]