Add trigger id as a param when calling an automation

Hi!

When you use automations you get them to be triggered by some automatic events, but it’s also handy to be able to launch them manually. We have the service automation.trigger for that, which is great, but it would be great if the trigger id could be passed.

When using automations for some daily tasks, like rolling up/down window blinds for example, you usually have an automation to roll them up in the morning and another one to roll them down in the evening. That’s a lot of integrations it you want different times for some blinds. Using the trigger id is great, as you have half of them. Something like this automation:

alias: example
trigger:
  - id: 'off'
    platform: sun
    event: sunrise
  - id: 'on'
    platform: sun
    event: sunset
condition: []
action:
  - service: 'switch.turn_{{ trigger.id }}'
    target:
      entity_id: switch.whatever

This works like a charm and avoids you to have two different automations. Problem comes when you want to call this automation manually: as you can’t pass the trigger param, you can’t.

Any chances to add the trigger as a param to the automation.trigger service call?

Thanks!

PS: Yes, this could be donde using a script that you call manually and also from the automation, but it’s madness having things in both sides unless it’s handy and you will end up with 2 automations and 1 script.

Probably not.

How is calling one service, automation.trigger, more handy than calling another service, script.blinds_up?

You can have as many or few automations and scripts as you want, including just 1 of each…

Automation Examples

1 or more Automations with 2 scripts

alias: example
trigger:
  - id: 'up'
    platform: sun
    event: sunrise
  - id: 'down'
    platform: sun
    event: sunset
  - id: 'down'
    platform: state
    entity_id: zone.home
    to: 0 
condition: []
action:
  - service: 'script.blinds_{{ trigger.id }}'

OR 1 or more automations, just one script…

alias: example
trigger:
  - id: 'off'
    platform: sun
    event: sunrise
  - id: 'on'
    platform: sun
    event: sunset
  - id: 'on'
    platform: state
    entity_id: zone.home
    to: 0 
condition: []
action:
  - service: script.blinds
    data:
      action: "{{ trigger.id }}"

As I said, totally possible to do it… having more “things” (automations/scripts). I just though that adding one parameter will add possible functionality and reduce the number or automations/scripts you need to have in HA.

It’s a matter of giving a much better user experience by just adding ONE parameter to a function, not a bug or anything.