Hi,
I have the following code:
action: |
{% if target is defined and target == "xxxx" %}
notify.mobile_app_xxxx_handy
{% elif target is defined and target == "yyyy" %}
mobile_app_iphone_von_yyyy
{% else %}
notify.all_phones
{% endif %}
data:
message: "{{ body }}"
title: "{{ header }}"
data:
subtitle: "{{ message }}"
url: "{{ url }}"
actions: |
{% if action1_title is defined and action1_action is defined %}
- action: "{{ action1_action }}"
title: "{{ action1_title }}"
{% endif %}
{% if action2_title is defined and action2_action is defined %}
- action: "{{ action2_action }}"
title: "{{ action2_title }}"
{% endif %}
The part with the actions is not working, because the result is:
actions: |-
- action: "TEST_123"
title: "Test"
So the characters “|” and “-” were added after “actions:”. Due to those signs the action button is not visible at the iOS notification.
So how can I add action buttons (title and id) only if I set them in the variables (action1_title, action1_action and action2_title, action2_action) ? I don’t want to have multiple condition in my automations / scripts, because then I have duplicated code.
4 posts - 2 participants