I have a restful notify command setup in configuration.yaml
to post template data as json to an external service:
notify:
- name: ntfy
platform: rest
method: POST_JSON
data:
topic: "{{ data.topic }}"
priority: "{{ data.priority | default('default') }}"
tags: "{{ data.tags }}"
icon: "{{ data.icon | default('') }}"
attach: "{{ data.attach | default('') }}"
click: "{{ data.click | default('') }}"
actions: "{{ data.actions | default(null) }}"
title_param_name: title
message_param_name: message
resource: https://server_address
The problem is that not all data
fields are used, and the service being called doesn’t like the default values being provided. Ideally I should only provide data fields for which there is an actual value.
I’ve tried passing in the entire data object, but that fails as well:
notify:
- name: ntfy
platform: rest
method: POST_JSON
data: "{{ data }}"
title_param_name: title
message_param_name: message
resource: https://server_address
Is there a way to pass in data fields only if they have values?