Change and highlight input source on AV Receiver

Hello, hope you´re all alive and kicking.

I would like to create a card to change input on my Yamaha AV Receiver, and it should look something like this:

image

So I guess changing the sources is not the problem, I would do that with a service call. But I want the source also to stay highlighted when selected, like this example:

image

Is this possible and how would I do that?
Thanks for any suggestions and/or code exapmples!

Stay healthy,
Philipp

make template switches for each source, then use button cards for each source. Only 1 will be on at a time.

switch:
- platform: template
  switches:
      # Roku Source
      roku_source:
        value_template: "{{ is_state_attr('media_player.yamaha_receiver', 'source', 'Roku') }}"
        turn_on:
          - service: media_player.select_source
            data:
              entity_id: media_player.yamaha_receiver
              source: Roku
        turn_off:
          - service: media_player.select_source
            data:
              entity_id: media_player.yamaha_receiver
              source: Roku

It doesn’t matter what the turn_off is because you’ll never be ‘turning off’ your source, only turning on. So I just made my turn_off service identical to turn on.

This my current Harmony, Yamaha, Source setup. The 2nd to last row is my sources on the reciever. The last row is my surround sound system modes.

Thank you, I will try it during the day.
Do you mind sharing your code on how you did these cool glowing frames around the buttons?

Not sure if I’m allowed to bump old topics, but I didn’t want to remake a thread just to ask the same question. In your example your input sources are highlighted as the OP asked, but when I try to implement it, both my sources show in the “off” state.

04.17.21-17:43:00

switch:
  - platform: template
    switches:
      # ShieldTV Source
      shield_source:
        value_template: "{{ is_state_attr('media_player.yamaha_receiver', 'source', 'HDMI4') }}"
        turn_on:
          - service: media_player.select_source
            data:
              entity_id: media_player.yamaha_receiver
              source: HDMI4
        turn_off:
          - service: media_player.select_source
            data:
              entity_id: media_player.yamaha_receiver
              source: HDMI4
      desktop_source:
        value_template: "{{ is_state_attr('media_player.yamaha_receiver', 'source', 'AUDIO1') }}"
        turn_on:
          - service: media_player.select_source
            data:
              entity_id: media_player.yamaha_receiver
              source: AUDIO1
        turn_off:
          - service: media_player.select_source
            data:
              entity_id: media_player.yamaha_receiver
              source: AUDIO1

It’ll only work when the receiver is on

Yep, the receiver is on.

Then when you click the switch for an input it should change the source and it’ll show as on. If that’s not happening, you have the wrong source names.

The source is switching perfectly, but the state isn’t changing to on. I’m sure I’ve made a mistake somewhere, but I can’t find it.

Does the media player source attribute show the proper source?

Yes sir it does.

Copy the source from the source attribute and use that in the template. Try it in the template editor. Also try the version you have in the template editor.

Before I read your reply I went into my entities and manually toggled then on and off. Now the cards are actually showing the source state properly. I have no idea why that’s the case, I’ll just assume user error.

Thanks taking the time to help me!

1 Like

@petro Aaand it stopped working again. Even manually toggling the entity keeps switching it to off. Pretty weird.

sounds like browser cache/issues.

Tried a couple browsers, incognito mode, phone, tablet, all the same result. It’s wild. Damn gremlins.

EDIT: In case anyone needs some closure, my issue was that in my configuration.yaml I renamed a couple of my receiver inputs, and completely forgot about that. @petro your comment about the media source attribute being the proper source was bang-on, I just completely misunderstood what you asked and was looking at something else entirely.

We’re good now!