I have an automation that triggers from a webhook but with a json trigger condition, that works without problems:
- alias: Fullfillment Basic UPS
trigger:
- platform: webhook
webhook_id: Fullfilment_Order_Shopify
condition:
- condition: template
value_template: "{{ trigger.json.tracking_company == 'UPS' }}"
action:
- service: homeassistant.update_entity
entity_id: sensor.shopify_unshipped_orders
- service: notify.mylogg
data_template:
message: '{{ now().strftime(''%d.%m.%y %a %X'') }} SHOPIFY Ready! EXPRESS {{ trigger.json.name }} ({{ trigger.json.destination.city }}, {{ trigger.json.destination.country }})'
- service: var.set
data_template:
entity_id: var.fullfilment
value: "EXPRESS Order {{ trigger.json.name }} - ({{ trigger.json.destination.city }}, {{ trigger.json.destination.country }})"
but now I need to add two other conditions that will trigger other things with the content of the trigger.json. So I made this here:
- alias: Fullfillment Trigger
trigger:
- platform: webhook
webhook_id: Fullfilment_Order_Shopify
action:
service_template: "{% if trigger.json.tracking_company == 'None' %} script.ups_fullfillment
{% elif trigger.json.tracking_company == 'Deutsche Post' %} script.deutsche_post_fullfillment
{% else %} script.rest_fullfillment {% endif %}"
But the problem is the three scrips cant read trigger.json (Error rendering data template: UndefinedError: 'trigger' is undefined)
ups_fullfillment:
sequence:
- service: homeassistant.update_entity
entity_id: sensor.shopify_unshipped_orders
- service: notify.mylogg
data_template:
message: '{{ now().strftime(''%d.%m.%y %a %X'') }} SHOPIFY Ready! EXPRESS {{ trigger.json.name }} ({{ trigger.json.destination.city }}, {{ trigger.json.destination.country }})'
- service: var.set
data_template:
entity_id: var.fullfilment
value: "EXPRESS Order {{ trigger.json.name }} - ({{ trigger.json.destination.city }}, {{ trigger.json.destination.country }})"
I tried to have three different automation with separate conditions, but it seems a webhook can only trigger one automation. How can I get this automation to work?