Notification with shortcut won't pass any data to the shortcut
iOS device model, version and app version
Model Name: iPhone 13 mini Software Version: iOS 16.4.1 (a) App version: Home Assistant Companion 2023.4 (2023.460)
Home Assistant Core Version Home Assistant 2023.5.3
Describe the bug When I pass data to an iOS shortcut, the shortcut receives nothing.
To Reproduce
Create an iOS shortcut with a single message box that shows the input to the shortcut (by default it will accept anything, i.e., images and any of the other 18 allowed types, in Italian "Immagini e altri 18")
Call service:
service: notify.mobile_app_gkipdm
data:
message: The garage door has been open for 10 minutes.
title: Your Garage Door Friend
data:
shortcut:
name: "Test1"
mytext: "this is my text"
Expected behavior The messagebox should show the input data, I guess a dictionary with mytext. It shows nothing instead.
Screenshots
I was attempting to utilize this today. I was running through a loop seeing how it was sent into the shortcut.
For context, here's the relevant docs: https://companion.home-assistant.io/docs/integrations/siri-shortcuts#executing-a-shortcut-via-home-assistant-notifications
FWIW - the fired event, of the shortcut ios.shortcut_run shows the input, so I know it's being passed.
For posterity here's an event of a shortcut I was testing. I wanted to add some more utility to a tea steeping timer automation I have setup, so the only key I'm attempting to pass is mgcaffeine with a value of "67", which would then be able to log it in Apple Health.
event_type: ios.shortcut_run
data:
device:
sourceDeviceID: ...
sourceDeviceName: ...
sourceDevicePermanentID: ...
input:
mgcaffeine: "67"
name: Test Hass Invocation
name: Test Hass Invocation
status: success
origin: REMOTE
time_fired: "2023-07-17T22:05:19.194795+00:00"
context:
id: ...
parent_id: null
user_id: ...
I was starting to think this was a way to pass callback data, i.e., context sent back to home assistant from the original invocation - until I stumbled upon this issue.
I have the same issue. @zacwest do you have any idea?
Is there any progress?
Same issue here, I don't think this feature actually works. Probably need to update the documentation.
After some trial and error, I now found a way to pass data to a shortcut - but it isn't really straight forward.
Here is how to do it:
In your shortcut:
- Make sure you have set up an input, meaning the section "Receive [Text] input from [Nowhere]"
- This can only be a text (string)
- This will be your only input. If you need to pass multiple values, send a JSON string from HA and decode it using the "Get Dictionary from Input" step.
In HA:
- Setup your notify action as follows:
action: notify.[your ios device]
data:
title: ...
message: ...
data:
shortcut:
name: "Name of your iOS shortcut"
input: text
text: "the value you want to send to the shortcut"
The actual payload the shortcut will then receive is the string after the text key (in this example "the value you want to send to the shortcut"). But you also need input: text.
This is how I got my automation to work, so I hope this helps you as well.
I'm so glad I finally found this issue, I thought I was losing my mind!
I currently just fetch the state of the entity from Home Assistant using "Render the provided template", but that doesn't work when the state has since changed and I want to use the state at the time of the notification, no matter how much later I actually tap on it.
Unfortunately, as soon as I modify my working shortcut to accept any input, tapping the notification simply opens Home Assistant without actually running the shortcut, whether I include input: text and text: ... or not. 😕