Combining actions under one button card for virtual home cinema remote

Hello all.

I have recently (two weeks ago) taken the plunge and upgraded from IKEA Tradfri to Home Assistant in order to be able to automate more of my home than just lighting. I’ve already integrated my tv and cinema amp and I’ve created a dashboard with a virtual remote control for my whole home cinema setup.

So far I’ve been able to achieve everything I wanted to by searching previous topics, etc, but the one final thing that has had me stuck for a few days now is controlling the input source of my Onkyo cinema amp with a click of a button card. Unfortunately the official Onkyo integration is not terribly sophisticated.

I have created a dropdown helper with the source options (BLURAY, SKY, etc) and have been able to get a button card to select the correct source in the dropdown helper, for example:

    cards:
      - show_name: true
        show_icon: false
        type: button
        tap_action:
          action: perform-action
          target:
            entity_id:
              - input_select.onkyo_source_selector
          perform_action: input_select.select_option
          data:
            option: BLURAY
        hold_action:
          action: none
        name: BLURAY

and I’ve been able to create a script that can be run at the click of a button card that can select a specified input on the amp, for example:

action: media_player.select_source
metadata: {}
data:
  source: BLURAY
target:
  entity_id: media_player.tx_nr646

I even managed to create multiple separate scripts, one for each source/button card, but I cannot, for the life of me, figure out how to combine the steps into a single script so the appropriate source will be selected on the amp depending on which button I click.

Any assistance or pointers will be most gratefully received as I’m spending far too long on this late at night and my wife is beginning to suspect I’m up to no good!

Use an automation that triggers whenever the input_select changes.

triggers: 
  - trigger: state
    entity_id: input_select.onkyo_source_selector
    not_to:
      - unknown
      - unavailable
actions:
  - action: media_player.select_source
    data:
      source: "{{ trigger.to_state.state }}"
    target:
      entity_id: media_player.tx_nr646
1 Like

Good afternoon, Tom.

You’re a gentleman! I’ve already used automations to get my smart lighting working in HA with my IKEA Tradfri remotes, but it just hadn’t occurred to me that I could use a helper as a trigger like a physical button… In all the other similar topics I’ve looked at over the last few nights, solutions have involved scripts, custom button cards and all sorts, but this is a simpler and more elegant solution.

Many thanks for your consideration and quick response, despite the fact I feel a bit silly! :slight_smile: