Login About Gallery
How Much Did I Sleep Last Night?
COMMENT
‎Read the HealthKit database to find out how much you slept last night. You can modify the shortcut to customize Siri's response based on how much time you slept.
DOCUMENTS
‎Get text from ‎Shortcut Input
SCRIPTING
‎Count ‎Items ‎in ‎Text
NUMBER
VARIABLES
‎Set variable ‎Asleep Minutes ‎to ‎Number
HEALTH
‎Find ‎All Health Samples ‎where
‎All the following are true
‎[{'class': 'filter-property', 'value': 'Type'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'Sleep'}]
‎[{'class': 'filter-property', 'value': 'Start Date'}, {'class': 'filter-operator', 'value': 'is in the last'}, {'class': 'filter-benchmark', 'value': 1, 'glyph': '', 'UUID': ''}, {'class': 'filter-unit', 'value': 'days', 'glyph': '', 'UUID': ''}]
‎[{'class': 'filter-property', 'value': 'End Date'}, {'class': 'filter-operator', 'value': 'is today'}]
‎[{'class': 'filter-property', 'value': 'Value'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'Asleep'}]
Sort by
‎None
Limit
SCRIPTING
‎Repeat with each item in ‎Health Samples
HEALTH
‎Get ‎End Date ‎from ‎Repeat Item
CALENDAR
‎Get time between ‎Repeat Item ‎and ‎End Date ‎in ‎Minutes
MATHS
‎Time Between Dates ‎+ ‎Asleep Minutes
‎Options Under Construction
VARIABLES
‎Set variable ‎Asleep Minutes ‎to ‎Calculation Result
SCRIPTING
‎End Repeat
MATHS
‎Asleep Minutes ‎รท ‎60.0
‎Options Under Construction
MATHS
‎Round ‎Calculation Result ‎to ‎Tenths
Mode
‎Normal
SCRIPTING
‎If ‎Rounded Number ‎is less than ‎5.0
TEXT
‎You should try and get more sleep.
VARIABLES
‎Set variable ‎Comment ‎to ‎Text
SCRIPTING
‎Otherwise
SCRIPTING
‎If ‎Rounded Number ‎is greater than ‎6.0
TEXT
‎Nicely done.
VARIABLES
‎Set variable ‎Comment ‎to ‎Text
SCRIPTING
‎Otherwise
SCRIPTING
‎End If
SCRIPTING
‎End If
VARIABLES
‎Get ‎Count
SCRIPTING
‎If ‎Count ‎is ‎0
SCRIPTING
‎Show ‎You slept ‎Rounded Number ‎ hours last night. ‎Comment
SCRIPTING
‎Otherwise
TEXT
‎You slept ‎Rounded Number ‎ hours last night. ‎Comment
SCRIPTING
‎End If

Showcuts

Magic Vars

Screenshot

Submitted Anonymously 7 months ago

Visit iCloud (iOS)

Copy iCloud Link

Scan QR Code

0