Recording a nap with Siri: napnap and iPhone Shortcuts
There are moments when you cannot get your phone out of your pocket. A Siri shortcut solves that: «Hey Siri, when is the next one due?» and it answers out loud.
First, a key
In napnap's settings there is a section for shortcuts. Create a key and copy it there and then: it is only shown once, because all that is left on the server is its hash.
The key is tied to one home, so a lost key does not hand over your whole account, and it can be revoked from that same screen.
The shortcut that reads the time out loud
Add the «Get contents of» action with the address https://napv2.dcimorra.es/api/v1/say, method GET, and an Authorization header with the value Bearer and your key.
Chain «Speak text» with the result. The answer is a sentence already written —«Aurora is due a nap at 13:10, in 40 minutes»— because the app decides what gets said, not the shortcut: that way a change to the model does not send you back to the iPhone.
The shortcut that records sleep
The same idea with «Get contents of» over /api/v1/babies/<id>/toggle and method POST. One tap records that they have fallen asleep and the next that they have woken; which of the two it is the server works out by looking at whether a sleep is open.
The baby's id comes from /api/v1/me with the same key.
And it can go on the home screen
A shortcut with its own icon next to the app, or in a widget, or fired by an automation: when the phone is plugged into the charger in the bedroom, for instance.
Everything the app does goes through the same public API, so there is nothing the app can do that a shortcut cannot.
Questions
- Does it work with Android?
- The API is the same, so anything that knows how to make an HTTP request with a header will do: Tasker, a widget, a script.
- Is it safe to put the key in a shortcut?
- The key lives on your iPhone and travels in a header, not in the URL, so it does not end up written in a log. If you lose it, you revoke it from Settings and it stops working immediately.