I am able to kick off a shortcut from the notification, but I am unable to send the shortcut any data. The documentation says how to send the data, but I can’t figure out how to receive it. Has anybody been able to do this successfully? If so, can you show some screenshots of the Shortcut?
After some additional research, I think you need to include input: text in order to pass anything. I was able to get the Shortcut to receive text, but couldn’t get it to interpret it as a Dictionary like it’s supposed to be doing. Using the following data to send a Notification, I can’t get the startDate, endDate.
shortcut:
name: Quick Look
ignore_result: ignored
input: text
startDate: "2025-04-06 20:00"
endDate: "2025-04-07 06:00"
text: "this text is received"
Solving my own problem, I created the notification like this:
shortcut:
name: Log Sleep Data
ignore_result: ignored
input: text
text: "{\"startDate\": \"2025-04-06 20:00\", \"endDate\": \"2025-04-07 06:00\"}"
And then on the iPhone Shortcuts app, I did:
Get dictionary from Shortcut Input
Log Health Sample
Type: Sleep
Value: Asleep
Start Date: Dictionary value for startDate
End Date: Dictionary value for endDate
While it stinks that I have to click on the text notification for it to process it, it gets the job done.
I’m going crazy.
This works:
shortcut:
name: Log Sleep Data
ignore_result: ignored
input: text
text: "{\"startDate\": \"2025-04-06 20:00\", \"endDate\": \"2025-04-07 06:00\"}"
What I really want is this:
text: "{\"startDate\":\"{{ states( 'sensor.most_recent_sleep_date' ) }} 20:00\",
\"endDate\":\"{{ ( ( states( 'sensor.most_recent_sleep_date' ) + ' 20:00' ) |
as_datetime + timedelta(minutes=int((states('sensor.cpap_usage_minutes')))) ).strftime('%Y-%m-%d %H:%M' ) }}\"}"
That renders correctly in Developer Tools, but when I try to use it in my automation, Shortcuts doesn’t get called.
However, if I mess the json up by adding any character to break it, like adding the letter ‘a’ as the first character of the text, Shortcuts does get called with all of the correct data in there. But, of course, Shortcuts can’t process that as a Dictionary because it’s no longer valid json.
Why can I send in static data in json format, but not put in variables?
Ugh. This is really lame, but it works. If somebody has a better solution, I’m all ears. I’m guessing there is a bug in the iOS app that is causing this, but I have no idea.
shortcut:
name: Log Sleep Data
ignore_result: ignored
input: text
text: "hacked{\"startDate\":\"{{ states( 'sensor.most_recent_sleep_date' ) }} 20:00\",
\"endDate\":\"{{ ( ( states( 'sensor.most_recent_sleep_date' ) + ' 20:00' ) |
as_datetime + timedelta(minutes=int((states('sensor.cpap_usage_minutes')))) ).strftime('%Y-%m-%d %H:%M' ) }}\"}"