Echo Devices (Alexa) as Media Player - Testers Needed

ok… im totally in the dark about this, what can i do to fix it?
if i remove it an install it again it seems to work, how do i remove every track of alexa media before i try to ad it again? (can i remove the old version that its loading, how do i do this?) //regards

Wiki

1 Like

I have not touched this project for some time and revisited today. I am very impressed by the improvements made to the login scheme. I have been using sonos speakers with a local macOS engine for TTS and was looking to see if I could simplify by doing away with some of the sonos speakers.
The two big gaps to adoption are the lack of multi device announcement sync (that’s an amazon thing with group not being supported) and the delay. While my localized TTS is practically instant on the sonos, the tts here has a delay of 3-5s. Is it to be expected?

Any cloud based mechanism will have delay compared to a local component. I am seeing the 5 second delay you’re talking about. The component will have at least the following places for delay:

  • HA aiohttp sharing - We rely on the HA aiohttp session so if there’s a rate limiter there, we can’t control it.
  • Queuing delay - The component waits for at least 1.5 seconds to see if any other commands are received before sending out a command to the Alexa API. If another command comes in, it will wait another 1.5 seconds until it doesn’t see any other requests. This was to avoid the Too Many Requests error because we now try to batch large sequences of commands instead of sending them individually.
  • General cloud delays - The component needs to send up to Amazon and then back down again.
  • HA processing - This is one of many components in HA. Any delay in getting access to the event queue will delay the component.

Now it’s possible to probably fine tune this, but I’m not going to spend much time working on it since the difference between 1-3 seconds and 3-5 seconds doesn’t seem that important to me for my use case.

2 Likes

Any updates on the Ring Alarm/Guard integration front?

1 Like

Hello, until this morning all work fine with my device integrated in HA; today my device are offline. i’ve tried to remove integration, remove components from hacs, delete .pickle file, change passwd on amazon, turn off RPi, turn on, reinstall components, make integration. All this many time but, every time, integration don’t find my device and my entity on HA are lost.

Any suggestion?

Thanks

Today all work fine, probably, yesterday, amazon.it has connect problem

What card is that ? How did you create it ?

Hi Bill, the BBC are now on their own app “BBC Player”. Maybe that’s there reason.

In configuration yaml, you have to define an input_select that contains all your echos, an input_select for music services you want to use such as Spotify, Amazon, SiriusXM, Tune-In, and an input select for all stations, playlists, artists, or songs you want for each music service.

In scripts.yaml, you have to create one script for each music service.

In ui-lovelace.yaml, the card you see created is a vertical-stack-in-card that consists of conditional cards. along with entities cards along with the mini-media-player.

I can post mine if you want to use it as an example to create your own?

1 Like

Please post it :slight_smile:

Per your request for the code to produce the card below. Its extensive due to all the conditional cards but its reliable.

configuration.yaml

input_select:
    
  radio_station:
    name: 'Select Radio Station:'
    options:
      - The Roar
      - Easley Police
      - The Answer Greenville
      - KJZZ
      
  radio_source:
    name: "Select Service:"
    options:
      - Spotify
      - SiriusXM
      - Tunein

  speakers:
    name: 'Select Speakers'
    options:
      - Livingroom
      - MasterBr
      - Greatroom
      - Bathroom
      - Laundryroom
      - Garage
      - Everywhere
    initial: Livingroom
    icon: mdi:speaker-wireless
    
  siriusxm_station:
    name: 'Select siriusXM Station:'
    options:
      - 60s on 6
      - 70s on 7
      - 80s on 8
      - ESPN Radio
      - ESPN XTRA
      - MAD DOG SPORTS
      - Fox Sports
      - ESPNU Radio
      - ACC RADIO

  spotify_selection:
    name: 'Selection :'
    options:
      - Johnny Cash
      - Southern Rock
      - Steve Miller
      - The Eagles
      - Playlist Liked Songs
      - Playlist Liked from Radio
      - Playlist The Blacklist soundtrack
      - Playlist Your Top Songs 2016
      - Playlist 35 Soul Classics 1970-1975
      - Playlist Charlie Daniels Southern Boy
      - Playlist Cyndi 2
      - Playlist Discover Weekly
      - Playlist Good Times Great Oldies
      - Playlist Justin Bieber - Where are you now
      - Playlist Soft Rock

scripts.yaml

radio538:
  alias: Play Radio on Tunein
  sequence:
  - service: media_player.play_media
    data_template:
      entity_id: '{% if is_state("input_select.speakers", "Livingroom") %} media_player.echo_plus
        {% elif is_state("input_select.speakers", "MasterBr") %} media_player.jeffrey_s_echo_dot
        {% elif is_state("input_select.speakers", "Greatroom") %} media_player.jeffs_dot
        {% elif is_state("input_select.speakers", "Bathroom") %} media_player.bathroom
        {% elif is_state("input_select.speakers", "Garage") %} media_player.garage
        {% elif is_state("input_select.speakers", "Everywhere") %} media_player.everywhere
        {% endif %}

        '
      media_content_id: '{% if is_state("input_select.radio_station", "The Roar")
        %} W C C P {% elif is_state("input_select.radio_station", "Easley Police")
        %} Easley Police {% elif is_state("input_select.radio_station", "The Answer
        Greenville") %} The Answer Greenville {% elif is_state("input_select.radio_station",
        "KJZZ") %} K J Z Z {% endif %}

        '
      media_content_type: TUNEIN

siriusxm538:
  alias: Play Satellite Radio
  sequence:
  - service: media_player.play_media
    data_template:
      entity_id: '{% if is_state("input_select.speakers", "Livingroom") %} media_player.echo_plus
        {% elif is_state("input_select.speakers", "MasterBr") %} media_player.jeffrey_s_echo_dot
        {% elif is_state("input_select.speakers", "Greatroom") %} media_player.jeffs_dot
        {% elif is_state("input_select.speakers", "Bathroom") %} media_player.bathroom
        {% elif is_state("input_select.speakers", "Laundryroom") %} media_player.laundry_room
        {% elif is_state("input_select.speakers", "Garage") %} media_player.garage
        {% elif is_state("input_select.speakers", "Everywhere") %} media_player.everywhere
        {% endif %}

        '
      media_content_id: '{% if is_state("input_select.siriusxm_station", "60s on 6")
        %} Station 6 {% elif is_state("input_select.siriusxm_station", "70s on 7")
        %} Station 7 {% elif is_state("input_select.siriusxm_station", "80s on 8")
        %} Station 8 {% elif is_state("input_select.siriusxm_station", "ESPN Radio")
        %} Station 80 {% elif is_state("input_select.siriusxm_station", "ESPN XTRA")
        %} Station 81 {% elif is_state("input_select.siriusxm_station", "MAD DOG SPORTS")
        %} Station 82 {% elif is_state("input_select.siriusxm_station", "Fox Sports")
        %} Station 83 {% elif is_state("input_select.siriusxm_station", "ESPNU Radio")
        %} Station 84 {% elif is_state("input_select.siriusxm_station", "ACC RADIO")
        %} Station 371

        {% endif %}

        '
      media_content_type: SIRIUSXM

spotify538:
  alias: Play Spotify
  sequence:
  - service: media_player.play_media
    data_template:
      entity_id: '{% if is_state("input_select.speakers", "Livingroom") %} media_player.echo_plus
        {% elif is_state("input_select.speakers", "MasterBr") %} media_player.jeffrey_s_echo_dot
        {% elif is_state("input_select.speakers", "Greatroom") %} media_player.jeffs_dot
        {% elif is_state("input_select.speakers", "Bathroom") %} media_player.bathroom
        {% elif is_state("input_select.speakers", "Laundryroom") %} media_player.laundry_room
        {% elif is_state("input_select.speakers", "Garage") %} media_player.garage
        {% elif is_state("input_select.speakers", "Everywhere") %} media_player.echo_plus
        {% endif %}

        '
      media_content_id: "{% if is_state(\"input_select.spotify_selection\", \"Johnny\
        \ Cash\") %} Johnny Cash {% elif is_state(\"input_select.spotify_selection\"\
        , \"Southern Rock\") %} Blue Suede Shoes  {% elif is_state(\"input_select.spotify_selection\"\
        , \"Steve Miller\") %} Steve Miller Band {% elif is_state(\"input_select.spotify_selection\"\
        , \"The Eagles\") %} The Eagles {% elif is_state(\"input_select.spotify_selection\"\
        , \"Playlist Cyndi 2\") %} Cyndi 2 Playlist {% elif is_state(\"input_select.spotify_selection\"\
        , \"Playlist Liked Songs\") %} Liked Songs Playlist {% elif is_state(\"input_select.spotify_selection\"\
        , \"Playlist Liked from Radio\") %} Liked from Radio Playlist {% elif is_state(\"\
        input_select.spotify_selection\", \"Playlist The Blacklist Soundtrack\") %}\
        \ The Blacklist soundtrack Playlist {% elif is_state(\"input_select.spotify_selection\"\
        , \"Playlist Your Top Songs 2016\") %} Your Top Songs 2016 Playlist {% elif\
        \ is_state(\"input_select.spotify_selection\", \"Playlist 35 Soul Classics\
        \ 1970-1975\") %} 35 Soul Classics 1970-1975 Playlist {% elif is_state(\"\
        input_select.spotify_selection\", \"Playlist Charlie Daniels Southern Boy\"\
        ) %} Charlie Daniels Southern Boy Playlist {% elif is_state(\"input_select.spotify_selection\"\
        , \"Playlist Cyndi 2\") %} Cyndi 2 Playlist {% elif is_state(\"input_select.spotify_selection\"\
        , \"Playlist Discover Weekly\") %} Discover Weekly Playlist {% elif is_state(\"\
        input_select.spotify_selection\", \"Playlist Good Times Great Oldies\") %}\
        \ Good Times Great Oldies Playlist {% elif is_state(\"input_select.spotify_selection\"\
        , \"Playlist Justin Bieber - Where are you now\") %} Justin Bieber - Where\
        \ are you now Playlist {% elif is_state(\"input_select.spotify_selection\"\
        , \"Playlist Soft Rock\") %} Soft Rock Playlist\n{% endif %} {% if is_state(\"\
        input_select.speakers\", \"Everywhere\") %} in everywhere group {% endif %}\n\
        \ in shuffle mode\n"
      media_content_type: SPOTIFY

amazon538:
  alias: Play Amazon
  sequence:
  - service: media_player.play_media
    data:
      entity_id: media_player.echo_plus
      media_content_id: boyz ii men in everywhere group
      media_content_type: AMAZON_MUSIC

stop538:
  alias: Stop Playing
  sequence:
  - service: media_player.media_pause
    data:
      entity_id: media_player.everywhere_2

ui-lovelace.yaml

  - title: Radio
    background: center / cover no-repeat url("/local/back.png") fixed
    icon: mdi:music
    panel: false
    cards:
      - type: custom:vertical-stack-in-card
        cards:
          - type: entities
            style: |
              ha-card {
                background-image: url("/local/music-2.jpg");
                background-repeat: no-repeat;
                background-size: 100%, 100%;
                border-top: solid 1px rgba(80,80,80,0.4);
                border-left: solid 1px rgba(80,80,80,0.4);
                border-right: solid 1px rgba(80,80,80,0.4);
                 }

            title: Radio
            show_header_toggle: false
            entities:
              - input_select.speakers
              - type: divider
                style:
                  height: 10px
              - input_select.radio_source

          - type: conditional
            conditions:
              - entity: input_select.radio_source
                state: "Spotify"
            card:
              type: entities
              style: |
                ha-card {
                  background-image: url("/local/black.jpg");
                  background-repeat: no-repeat;
                  background-size: 100%, 100%;
                  border-left: solid 1px rgba(80,80,80,0.4);
                  border-right: solid 1px rgba(80,80,80,0.4);
                   }
              entities:
                - input_select.spotify_selection
                - type: divider
                  style:
                    height: 10px
                - script.spotify538

          - type: conditional
            conditions:
              - entity: input_select.radio_source
                state: "SiriusXM"
            card:
                type: entities
                style: |
                  ha-card {
                    background-image: url("/local/black.jpg");
                    background-repeat: no-repeat;
                    background-size: 100%, 100%;
                    border-left: solid 1px rgba(80,80,80,0.4);
                    border-right: solid 1px rgba(80,80,80,0.4);
                     }
                entities:
                  - input_select.siriusxm_station
                  - type: divider
                    style:
                      height: 10px
                  - script.siriusxm538

          - type: conditional
            conditions:
              - entity: input_select.radio_source
                state: "Tunein"
            card:
              type: entities
              style: |
                  ha-card {
                    background-image: url("/local/black.jpg");
                    background-repeat: no-repeat;
                    background-size: 100%, 100%;
                    border-left: solid 1px rgba(80,80,80,0.4);
                    border-right: solid 1px rgba(80,80,80,0.4);
                     }
              entities:
                - input_select.radio_station
                - type: divider
                  style:
                    height: 10px
                - script.radio538

          - type: conditional
            conditions:
              - entity:  input_select.speakers
                state: "Livingroom"
            card:
              type: custom:mini-media-player
              entity: media_player.echo_plus
              icon: mdi:amazon-alexa
              background: "/local/black.jpg"
              artwork: cover
              artwork_border: true
              show_source: true
              style: |
                ha-card {
                  border-left: solid 1px rgba(80,80,80,0.4);
                  border-right: solid 1px rgba(80,80,80,0.4);
                  border-bottom: solid 1px rgba(80,80,80,0.4);
                    }

          - type: conditional
            conditions:
              - entity:  input_select.speakers
                state: "Laundryroom"
            card:
              type: custom:mini-media-player
              entity: media_player.laundry_room
              icon: mdi:amazon-alexa
              background: "/local/black.jpg"
              artwork: cover
              artwork_border: true
              show_source: true
              style: |
                ha-card {
                  border-left: solid 1px rgba(80,80,80,0.4);
                  border-right: solid 1px rgba(80,80,80,0.4);
                  border-bottom: solid 1px rgba(80,80,80,0.4);
                    }

          - type: conditional
            conditions:
              - entity:  input_select.speakers
                state: "Bathroom"
            card:
              type: custom:mini-media-player
              entity: media_player.bathroom
              icon: mdi:amazon-alexa
              background: "/local/black.jpg"
              artwork: cover
              artwork_border: true
              show_source: true
              style: |
                ha-card {
                  border-left: solid 1px rgba(80,80,80,0.4);
                  border-right: solid 1px rgba(80,80,80,0.4);
                  border-bottom: solid 1px rgba(80,80,80,0.4);
                    }

          - type: conditional
            conditions:
              - entity:  input_select.speakers
                state: "MasterBr"
            card:
              type: custom:mini-media-player
              entity: media_player.jeffrey_s_echo_dot
              icon: mdi:amazon-alexa
              background: "/local/black.jpg"
              artwork: cover
              artwork_border: true
              show_source: true
              style: |
                ha-card {
                  border-left: solid 1px rgba(80,80,80,0.4);
                  border-right: solid 1px rgba(80,80,80,0.4);
                  border-bottom: solid 1px rgba(80,80,80,0.4);
                    }

          - type: conditional
            conditions:
              - entity:  input_select.speakers
                state: "Greatroom"
            card:
              type: custom:mini-media-player
              entity: media_player.jeffs_dot
              icon: mdi:amazon-alexa
              background: "/local/black.jpg"
              artwork: cover
              artwork_border: true
              show_source: true
              style: |
                ha-card {
                  border-left: solid 1px rgba(80,80,80,0.4);
                  border-right: solid 1px rgba(80,80,80,0.4);
                  border-bottom: solid 1px rgba(80,80,80,0.4);
                    }

          - type: conditional
            conditions:
              - entity:  input_select.speakers
                state: "Garage"
            card:
              type: custom:mini-media-player
              entity: media_player.garage
              icon: mdi:amazon-alexa
              background: "/local/black.jpg"
              artwork: cover
              artwork_border: true
              show_source: true
              style: |
                ha-card {
                  border-left: solid 1px rgba(80,80,80,0.4);
                  border-right: solid 1px rgba(80,80,80,0.4);
                  border-bottom: solid 1px rgba(80,80,80,0.4);
                    }
                
          - type: conditional
            conditions:
              - entity: input_select.speakers
                state: "Everywhere"
            card:
              type: custom:mini-media-player
              entity: media_player.everywhere_2
              icon: mdi:amazon-alexa
              background: "/local/black.jpg"
              artwork: cover
              artwork_border: true
              show_source: true
              style: |
                ha-card {
                  border-left: solid 1px rgba(80,80,80,0.4);
                  border-right: solid 1px rgba(80,80,80,0.4);
                  border-bottom: solid 1px rgba(80,80,80,0.4);
                    }

3 Likes

Hello,
I have an little question, maybe it is simple but after many reading i don’t undestand how make it.
Il want to collect the “media_title” of the curent song played by my echo and send to MQTT.
So if i use : {{ states(“media_player.echo”)}}, il have the state (like PAUSED), but how to collect the attribut “media_title” of the entity “media_player.echo” ?

Thanks for your help.

KG

Thank you !

1 Like

Anyone know how to send the loop command to Alexa using this? Repeat wont work as I’m using Apple Music. Here’s a link I found relating https://developer.amazon.com/en-GB/docs/alexa/music-skills/api-setloop.html

{{ states.media_player.echo.attributes.media_title }}

Or you could create a sensor in configuration.yaml:

sensor:
  - platform: template
    sensors:
      whats_playing:
        friendly_name: 'What is Playing?'
        value_template: "{{ state_attr('media_player.echo', 'media_title') }}"
1 Like

What can I do if tts works, but announce does not?

- id: '1587334405947'
  alias: Alexa Echo Test
  action:
  - data:
      data:
        type: tts
      message: 'Test Message'
      target:
      - media_player.membersounds_echo_dot
    service: notify.alexa_media

If I trigger the action above manually, I can hear the message.
But if I change type: announce, nothing is played. Why?

Nevermind, I had to explicit enable announces for the device inside the alexa app.

It seems it’s not working well with Amazon Music, any idea why ? I have seen you are not using it.

Amazon Music should work with the same method. I forget why I didn’t completely enable that part when I changed from my old way of doing it. I’ll take a look later because I want to have that as an option too.

It somehow works but for example if I put Bon Jovi as an option it plays something else. If I say by voice to play Bon Jovi it plays Bon Jovi.