đź“» DIY Amazon Echo Link Amp

This blueprint will help you automate an Alexa device connected to an amplifier that’s not always on.
It will:

  • turn on the amplifier and switch to the correct source when the Alexa device starts playing music
  • turn off the amplifier after 10 seconds of no music playing
  • stop playback on the alexa device if the amplifier is turned off or the source is switched

It is intended for the following setup:

  • One “Main” Alexa device which you’ll talk to and get answers from
  • One “Music” Alexa device which will be muted
  • An amplifier which is controllable in Home Assistant via a media_player entity

The “Music Alexa” must be connected to the amplifier.
Set up a group in the Alexa app and add the “Main” and “Music” Alexa and set the preferred speaker for music to the “Music Alexa”.

:zap: This blueprint currently doesn’t support multiroom audio groups. The amp will not turn on if you, for example, start music on the “Everywhere” group. This feature might get added in a future version of this blueprint.

This blueprint requires the alexa_media custom integration.

blueprint:
  name: DIY Echo Link Amp
  description: Emulate the behaviour of an Amazon Echo Link Amp by using your existing Amp and an Amazon Echo device connected to your Amp.
  domain: automation
  input:
    echo:
      name: Amazon Echo device
      description: The Amazon Echo device that is connected via AUX to the speakers.
      selector:
        entity:
          integration: alexa_media
          domain: media_player
    speaker:
      name: Speaker
      description: The media_player for the speaker.
      selector:
        entity:
          domain: media_player
    source:
      name: Source
      description: The source of the speaker to which the Amazon Echo is connected.
      selector:
        text:

variables:
  echo: !input echo
  speaker: !input speaker
  source: !input source

trigger:
  - platform: state
    entity_id: !input speaker
    to: "on"
  - platform: state
    entity_id: !input speaker
    attribute: source
  - platform: state
    entity_id: !input echo
    from: playing
    for: 00:00:10
  - platform: state
    entity_id: !input echo
    to: playing

condition: []

action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.entity_id == speaker

              and ((trigger.from_state.state == "on" and trigger.to_state.state == "off")
              or trigger.from_state.attributes.source == source and trigger.to_state.attributes.source
              != source) }}'
        sequence:
          - service: media_player.media_stop
            data: {}
            entity_id: !input echo
      - conditions:
          - condition: template
            value_template: '{{ trigger.entity_id == echo and
              trigger.to_state.state == "playing" }}'
        sequence:
          - service: media_player.turn_on
            data: {}
            entity_id: !input speaker
          - service: media_player.select_source
            data:
              source: line3
            entity_id: !input speaker
      - conditions:
          - condition: template
            value_template: '{{ trigger.entity_id == echo and

              trigger.from_state.state == "playing" and trigger.to_state.state != "playing"
              }}'
        sequence:
          - service: media_player.turn_off
            data: {}
            entity_id: !input speaker
    default: []

mode: restart

This blueprint is based on a previous blog post of mine where I achieved this using Node Red: https://vigonotion.com/blog/alexa-connected-to-an-audio-receiver/

1 Like