I got a bit confused with notification actions and could use some help.
Here's what's working:
- I can use
notify.send_message with multiple target, the problem is that notify.send_message does not allow me to set the data field (to make the notification high priority, or make it android auto compatible)
- I can use
notify.mobile_app_phone_name, which allows me to set data field, but it only supports one target (I tried to create a notification group but notify.group_name does not appear as a valid action name)
So it looks like notify.notify is the right one that both allows me to set multiple targets, and also the data field, but I'm really struggling with how to set its target field.
I tried to set it to entity_id: notify.group_name and got error: value should be a string @ data['target'][0]. Got None
Then I tried to set it to [notify.group_name], which got me an unknown error.
I also tried both [notify.mobile_app_phone_name] and [notify.phone_name] (the auto completion only gives me notify.phone_name not notify.mobile_app_phone_name), both got me an unknown error.
What's the correct way of targeting multiple devices with extra data field?
notify.notify is never the right one.
If you want to use data, you need to use the individual actions. You can use a Repeat to iterate through them or create legacy Notify groups.
Thanks. I guess Repeat it is then. I tried to create a notification group but that doesn't really show as a notify.foo action either.
They should....
The legacy Notify groups (configured in YAML) group notify actions by creating a new action. The Notify group Helpers (configured in the UI) group notify entities by creating a new entity.
This is what I got repeat to work:
repeat:
for_each:
- action: notify.mobile_app_phone1
- action: notify.mobile_app_phone2
sequence:
action: "{{ repeat.item.action }}"
metadata: {}
data:
message: ...
data: ...
but I wonder if there's a better way to write this, as in this form it's no longer editable in visual UI.
The mobile app integration now creates notify.xxxxx entities for each of your devices.
You can use that in a notify.send_message action.
- action: notify.send_message
metadata: {}
target:
entity_id:
- notify.phone_1
- notify.phone_2
data:
title: Whatever
message: Blah, blah.
This can also be done in the automation editor UI by the way.
One gotcha. I've not been able to use the notify.send_message action to do TTS output. You still have to use the notify.mobile_app_xxxx action for that.