Pass Value to an Automation

I have an automation change_tv_channel that switches TV channels:

description: "Change TV Channel"
mode: single
trigger: []
condition: []

action:
  - service: media_player.play_media
    target:
      entity_id:
        - media_player.lg_webos_smart_tv
    data:
      media_content_id: >-
        {% set channel = {
        'ARD':'736',
        'ZDF':'693'} %}
        {{ channel[option]  }}
      media_content_type: "channel"

I’m trying to pass the Value of [option] to the automation, like in a service call, from a card with a button (actually ideally from a dropdown of input_select) like so:

show_name: true
show_icon: true
type: button
name: Test Automation (Input)
show_state: false
tap_action:
  action: call-service
  service: automation.change_tv_channel
  service_data:
    option: ARD

It gives me “Service not found”. I know it’s not a service, but I can’t find anything to call an automation like that.
Would be great to get a hint in the right direction, thank you!

If you don’t have a trigger, use a Script not an Automation. Scripts can be called as services and have variable passed to them.

Depending on how you want it to work, another option might be to use a Template select.

2 Likes