How to control input source on Denon AVR with Alexa?

Hello - my goal is to be able to control the input source on my Denon AVR-X1400H using a voice command to Alexa. It’s very possible I’m missing something obvious so appreciate any help in setting me straight.

The steps I’ve taken so far are:

  1. Added the denonavr component to my configuration.yaml - this was successful in creating a media_player.receiver entity that I can use to control the AVR, including input source selection, from the Home Assistant UI without issue.
  2. Exposed this entity to Alexa from the Home Assistant Cloud configuration - this was also successful and I can successfully ask Alexa to set the volume, etc.

On the Alexa Configuration doc for Nabu Casa, I see that the media_player domain supports “play, pause, stop, set volume, adjust volume, next track, and previous track”. I’m assuming then, I’ll need another way to ask Alexa to invoke the media_player.select_source service to control the input source on the AVR.

Is there a best practice for this… through automation, script, scene or otherwise? Or am I overthinking this? Thanks!

Seeing that alexa itself doesn’t support changing the sources, the best way to approach this would be:

“What do you want to say to switch the source?”

Turn on “source”

Run “source”

Execute “source”

Personally, i’d vote for the turn on source route. Then what you can do in home assistant is build template switches…

switch:
- platform: template
  switches:
    denon_hdmi1:
      friendly_name: Denon HDMI 1
      value_template: >
        {{ is_state_attr('media_player.denon_avr_x1400h', 'source', 'HDMI 1') }}
      turn_on:
        service: media_player.select_source
        data_template:
          entity_id: media_player.denon_avr_x1400h
          source: 'HDMI 1'
      turn_off:
        service: media_player.turn_off
        entity_id: media_player.denon_avr_x1400h

Then expose each switch to nabu casa and your phrase will be:

Alexa, turn on Denon HDMI 1

1 Like

Ah-ha! Thanks so much - just got it up and working. This is great. Template switches… I should have thought of that!

1 Like

This is a great suggestion, very useful for me as well. Is it possible to use this template to do several things, ie. select source, then volume set to a certain level? I have tried using a sequence for this, but I am struggeling. Anyone that can help out?

Best regards,
Anders

1 Like

Yes, tread the turn_on/turn_off sections as scripts:

switch:
- platform: template
  switches:
    denon_hdmi1:
      friendly_name: Denon HDMI 1
      value_template: >
        {{ is_state_attr('media_player.denon_avr_x1400h', 'source', 'HDMI 1') }}
      turn_on:
      - service: media_player.turn_on
        entity_id: media_player.denon_avr_x1400h
      - service: media_player.volume_set
        data:
          entity_id: media_player.denon_avr_x1400h
          volume_level: 0.4
      - service: media_player.select_source
        data_template:
          entity_id: media_player.denon_avr_x1400h
          source: 'HDMI 1'
      turn_off:
      - service: media_player.turn_off
        entity_id: media_player.denon_avr_x1400h
2 Likes