Echo Devices (Alexa) as Media Player - Testers Needed

I’ve been using this without any issues for months. Thanks for the hard work. I was wondering if anyone had any way of knowing which echo received a voice command either via this tool, or some other way.

Basically I’d like to be able to say to my kitchen echo, “Alexa, xxx”, which in turn turns on an input Boolean, which then runs an alexa tts script, which provides some status. I do this now and it works great. But if I’m in the bedroom and ask, of course the script runs with my kitchen echo (or whichever one I have it set to run). I have a few scripts that do the TTS to multiple echos, but would be cool/nice to be able to have it reply with TTS to “last active echo”?

the script that started this is in this topic

and that also has the possibility to ask what the last active alexa was.

Thanks, I have been following that thread as well. Defnitely a bit more complex, but does seem to offer a few things. I did a quick skim/search and did not see any comments about the last used alexa. Can you point me to where I might review the script. Thanks

i can give you the link to the original script in german):

the command he added in februar ist:

alexa_remote_control.sh -lastalexa

I’m loving this. My only issue is the time it takes for TTS to play on my Echo. I have an automation setup so that when someone presses my Ring Doorbell, my Echo plays a message saying someone is at the door. In most cases the door has been answered and the person has already been let in and then the TTS message comes through.

This could very be the time it takes for the TTS message to be sent to the Alexa servers, processed into an audio file, and then sent back.

Does anyone know of a way to have a locally hosted audio file played to an Echo?

1 Like

that isnt possible.

its possible to play a short mediafile on alexa in a custom skill, the problem is that you only can trigger that custom skill by saying something to alexa.
the TTS way we use is an hack from the alexa app and from the alexa app you cant play local files.

All good. Thought I’d ask. Oh well. Guess I’ll just deal with the delay. Would be good if it could process on the local AWS servers rather than those in the US.

i would love that possibility myself.
would open up a lot of options.

Not sure if this is related or to this thread or HA in general. However, this is causing Alexa to stop responding to commands until HA is restarted.

An error occured accessing the API: An exception of type ConnectionError occurred. Arguments: (MaxRetryError(“HTTPSConnectionPool(host=‘alexa.amazon.com’, port=443): Max retries exceeded with url: /api/np/player?deviceSerialNumber=G090LF1175150Q4U&deviceType=A3S5BH2HU6VAYF&screenWidth=2560 (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x7f8ea265be10>: Failed to establish a new connection: [Errno 110] Operation timed out’,))”,),)

Edited: Appears Alexa is having issues. But, still need to understand the above error…

image

Could someone take a look and let me know why this script will not work with 2 elements, a doorbell from spotify and an alexa tts both played on same echo dot?

Individually, both work as expected but when combined (see below), it will only play the tts element.

doorbell:
  alias: Doorbell
  sequence:
    - service: media_player.play_media
      data:
        entity_id: media_player.kitchen_echo_dot
        media_content_id : "spotify:track:xyzsdfgkfbksdj"
        media_content_type: "SPOTIFY"
    - service: media_player.alexa_tts
      data_template:
        entity_id: media_player.kitchen_echo_dot
        message: -> ' Someone has pushed the front gate bell.'

OK I think I have a couple of very “cludgy” fixes for the volume problem

I am now running a bit of a Frankenstein configuration. I am running this custom media player and the python script

As we know when the media player goes into standby the volume controls fail to work. So the first “cludge” is to use a binary template to monitor the state of the media player. It is triggered on when the media player goes into standby. This then triggers a shell command which runs

alexa_remote_control.sh -d “echo name” -r “any valid radio station” - e pause

This will take the echo out of standby but is too quick for the radio station to play. As I said “cludgy” it will fill your history and stop the echo going into power standby.

*EDIT After more testing this is not reliable command is too quick, as I said cludgy sorry

The second cludge is to trigger a routine in the Alexa app. You can create multiple routines in the app that change the volume. You can run them with this

alexa_remote_control.sh -d “echo name” -e automation “name of routine”

I code in appdeamon so can supply code if required

@keatontaylor

First of all thank you very much for sharing this and relentlessly ironing bugs. Since my first failed attempt at running it back in July I’ve been following the progress and today I downloaded VERSION 0.9.5 and pretty much worked right away!

Could you perhaps consider adding the json tracker which works with this component.

GitHub

custom-components/custom_updater

:package: A component which allows you to track and update custom cards/components and python_scripts - custom-components/custom_updater

It effectively tracks your changes and informs users of changes/upgrades.

thank you again.

I think I ran into something similar.

It might be that the second service is called before the first service has a chance to start thereby negating the first service call.

Try putting a delay for a couple of seconds longer than your play_media call track length.

1 Like

I have the same setup but without the delay you are having… Mine is almost instant when the doorbell rings…

I see you are in Australia. How have you managed to get it to be instant? Would you mind sharing your setup? Also, is your echo setup on an AU account or US?

It takes about about a second or so for my chime to sound, and then the echo starts when the chime is finished. That’s how long it takes the echo to process.

Could also be that HA gets the button press from the ring servers, so there is a few trips to US servers before my Echo makes a sound. :frowning:

My Amazon account is set to US, I am running HA on PC running Ubuntu so not sure if that would make the diffrence, I have it also pause spotify on the echos if it’s playing so I don’t need to turn it off when people arrive (this is also instant). If you use TTS with the echos is it instant from HA?

Thank you, was looking for this. Works fine.

1 Like

Hmm. If I manually invoke a TTS message, it seems to be next to instant. This is the same way that I have my automation setup for my doorbell. Maybe it’s taking time for the Ring sensor to get the data for a ring event. Hmm…

I’ve set up an automation, triggered by an input boolean, to play a radio station but don’t know how to stop it when the input boolean is switched off… to start, the service command is “media_player.play_media” and I’ve tried “media_player.stop_media” but it doesn’t work. What would the command for that be?

  • alias: Alexa Play BBC1 on
    trigger:
    platform: state
    entity_id: input_boolean.alexa_bbc1
    from: ‘off’
    to: ‘on’
    action:
    • service: media_player.play_media
      data:
      entity_id: media_player.living_room
      media_content_id : “BBC Radio 1”
      media_content_type: “TUNEIN”
  • alias: Alexa Play BBC1 off
    trigger:
    platform: state
    entity_id: input_boolean.alexa_bbc1
    from: ‘on’
    to: ‘off’
    action:
    • service: media_player.stop ???

edit…not that it really matters actually now that i have already asked, because once the media player is live one uses the media player for control and if the “media” is stopped you still end up with an out of position switch. I guess I should just change it to a script so I get an " execute"/“activate” button instead.

Sorry for the dumb question

I love these media players. big thanks to Keatontaylor!

1 Like

I played with this a bit in the services menu:

media_player.media_play_pause => pauses it
call it again => unpauses it

media_player.turn_off => stops it and turns it off
media_player.turn_on =>turns it back on; no Media is played.

2 Likes