Help with a blueprint - apns_headers

I have taken the code from someones blue print and I am attempting to make an option to define a name for grouping notifications.

action:
  - delay: "{{ delay }}"
  - service: camera.snapshot
    entity_id: !input "camera"
    data:
      filename: "{{ snapshot_create_file_path }}"
  - device_id: !input "notify_device"
    domain: mobile_app
    type: notify
    title: "{{ notification_title }}"
    message: "{{ notification_message }}"
    data:
      '{% set android_data = { "channel": "alarm_motion", "group": "alarm_motion",
      "ttl": 0, "priority": "high", "clickAction": "%s", "image": "%s"} | format(clickAction,
      snapshot_access_file_path) %} {% set ios_data = { "channel": "alarm_motion", "url":
      "%s", "apns_headers": { **"apns-collapse-id": "groupingname"** }, "attachment": {"url":
      "%s", "content_type": "JPEG"},  "push": { "sound": { "name": "default" } } } | format(clickAction, snapshot_access_file_path) %} {{
      ios_data if is_ios else android_data }}'

This line overwrites past notifications with the latest on iOS. but doing this just groups them all together as groupingname. I want to use this blueprint for other devices so don’t want to group all notifications. I want groupingname to be defined when using the blueprint by the user.

apns-collapse-id": “groupingname”

I have added this to the blueprint

variables:
  groupingname: !input "groupingname"

However no joy… two different notifications set up in two automations overwrite each other.

Hey,

You need an input, a variable to link to the input and changes in the your action.

I have changed the blueprint with the things you asked for. Try it.

Brilliant, will give this a go, I have been trying various different methods to get this to work, I wandered for a while what %s meant so im assuming that means the action looks for the the input to apply to the variable. Also Json is usually formatted like so groupingname: “groupingname” so when everything is written like this it makes it slightly more confusing “groupingname” : “groupingname”

Anyhow thanks for the help with this one!

I have not tested this yet, please let me know.

This is all still very new for me as well.
I’m sure this blueprint can be made in more clever or shorter way.
The big if else structure does make it more easy to understand.

Hi Stan,

Yes I have tested and it works! There may be better ways but you got it working which is something I couldn’t.

Is there a way to add the option to play one of the pre-loaded sounds?