Two webhook triggers, choose one action

Hi everyone!

Does enyone knows how to achieve this for an automation?

alias: Webhook - Phone Charger
description: ''
trigger:
  - platform: webhook
    webhook_id: "abcabc"
  - platform: webhook
    webhook_id: "123123"
condition: []
( IF webhook "abcabc" do next action )
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.sonoff_phone_charger
( IF webhook "123123" do next action )
action:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.sonoff_phone_charger
mode: single

It’s not 100% clear what you’re trying to achieve, but I’m 99% sure it would be easier with 2 automations

Like this:

alias: Webhook - Phone Charger
description: ''
trigger:
  - platform: webhook
    webhook_id: "abcabc"
  - platform: webhook
    webhook_id: "123123"
action:
  - service: "switch.turn_{{ 'on' if trigger.webhook_id == 'abcabc' else 'off' }}"
    target:
      entity_id: switch.sonoff_phone_charger
mode: single
5 Likes

I already done this with two autiomations, I just try to minimize the number of automations

1 Like

Thats it, it is working flowless. I just wanted to know that “trigger.webhook_id”, but your aproach, made me learn new things. I didn’t know that I can use code into other services than Template :smiley: Which is wow.
Thank you so much!

1 Like

I reduced the number of my automations, from 40 to 6 :)) With this webhook trigger method.

1 Like