Echo Devices (Alexa) as Media Player - Testers Needed

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

Maybe, Mine also turns on the porch light when it detects motion which is also instant,I would re-add the ring component again and redo the automations to try and track down the delay. How far is your router from the doorbell?

It’s not that far. Maybe less than 10m. RSSI in the app is in the green showing good signal. I contacted Ring support a few months back about something else and they insisted that my wifi was to blame. Seems to be a common answer with them. I have no issues with any other device on my network.

Unfortunately, I don’t think removing the component will do much. Not without removing any Ring specific dependencies that the component installs, and this is beyond my knowledge.

thanks Willy! And thanks for reminding me of the service menu, after all this time with HASS I still find myself setting up yaml lines to test things… :man_facepalming:

is there anyway of adjusting the volume through a yaml command?
I’m using the media player as an alarm clock with a mix of tts messages and media but the tts is so much louder than the media it would be good to adjust these levels within the automation

To avoid the cloud server, The Hook up guy set up a simple doorbell but you would have to set up picture seperately…

This is supposed to work but I haven’t had a chance to test it yet:

- service: media_player.volume_set
  data:
    entity_id:
      - media_player.computer_room_dot
      - media_player.kitchen_dot
    volume_level: 0.9

The volume levels are .1 to 1.

And the player has to be actually playing something for it to work. So call your play_media first then call volume_set.