Echo Devices (Alexa) as Media Player - Testers Needed

I can’t even get my simple 1 = 1 test notification as a script.

'1546701126812':
  alias: Test Alexa
  sequence:
  - data:
      entity_id: media_player.living_room_echo_dot
      message: '{% if 1 == 1 %}hello{% else %}bye{% endif %}'
    service: media_player.alexa_tts

Replace - data with - data_template
As I told you, a simple typo will mess up everything.

1 Like

Ding, ding, and the winner is @Remco_Timmer. Thanks

2 Likes

I’m hoping in the future we could invoke a Alexa Skill using HA. Specifically the Start my car Chevy app! That would be awesome!

If you submit a pull request we can help you merge it in. Just remove the extraneous comments you have that you used for notes and also increment the version by 0.0.1 and allow edits and we can help. We all start from the beginning when it comes to programming and you’ve already made the first step by getting the code working for your use.

  1. Turn on debugging.
  2. Confirm tts works for your devices on reboot.
  3. When things fail with Alexa in the future, try the tts you used in 2 above again and put the relevant part of the home-assistant log in a secret gist. It should include any errors you may have gotten from alexa and the alexa tts component. Remove any amazon emails/passwords
  4. Private message me with the gist url. I can take a look and guide further.

I have this issue:
Set mediaplayer volume
Maybe someone here can help out.

By the way: Is it possible to update this component with the custom_updater?

1 Like

Everything worked in the past, but right now I do not have the alexa_tts entity.
All my Echos are present an I can control them via HA. If I try to use the Text to Speech feature in the media card Alexa tells me that there has to be the Alexa Text to Speech service.
I already upgraded to the latest alexa.py and deleted the py-cache, but nothing changed!

Can anybody help me with this?

Well i made a pull request but i also took my README.md which should not be merged.

Sorry for this mistake.

Should playing to MRM groups work the same as a specific device?

If I do a service call in the dev console using “media_player.living_room” as the entity, it works fine (that’s a single echo). “media_player.whole_house” does not. I can control the Whole House MDM via Media Player Card if I play it using voice commands. I debugged the JSON being posted, and everything looks identical as far as what is POSTed to alexa.amazon.com. Any ideas or guidance on MRM groups?

The media card has never worked for tts..
Are you saying you don’t have a service media_player.alexa_tts? We’ll need logs to figure out why. Please turn on debugging and post any errors being generated by the component in an issue and we’ll take a look.

There have been scripts posted in the thread to help set the volume by playing a silent track prior to any TTS announcement. Please search. Alternatively, you can wait till someone resolves it here.

As for custom updater, no one’s filed an issue for it although people have requested it a couple of times.

I believe it’s an Amazon limitation that it only supports Amazon’s built in music services; HA can’t interact with the groups directly. Workarounds have been to create a HA group with all media_player entities and then adjust for the different response times since they do not all sync anymore.

Thank you, found the solution here Echo Devices (Alexa) as Media Player - Testers Needed - #1458 by b3voholic

I also opened an issue (custom updater).

Do we need amazon music unlimited for this?

It works for me now because I have a test phase, but I won’t use it after it ended. I do have amazon music (prime). Does it work with that too?

yes it works without unlimited. Prime is enough.

1 Like

HA can interact with music groups, but only for music.
you can only do with HA what you can do with an alexa (so with something you say, or something you do in the app)
you cant talk to all alexas at the same time, so it cant respond on all at the same time.
remember there is no such thing as TTS on amazon. in HA we create a hack to mimic TTS.

I think we can make this script a little smarter, I had problems with the delay as the song was not playing when it sets the volume after the 3 second delay. I think the wait_template is the right choice.

alexa_test:
  sequence:
    - service: media_player.play_media
      data:
        entity_id: media_player.echo_dotr
        media_content_id: Silence 5 Seconds
        media_content_type: AMAZON_MUSIC
    - wait_template: "{{ states.media_player.echo_dot.state == 'playing' }}"
    - service: media_player.volume_set
      data:
        entity_id: media_player.echo_dot
        volume_level: 0.4
    - delay:
        milliseconds: 200
    - service: media_player.alexa_tts
      data:
        entity_id: media_player.echo_dot
        message: "Test"

Also I think we could make a script out of this that could be used for different tts messages with only filling in the message.

Maybe @petro can help making this script more compact and smarter.

I’m not sure you can. If those delays are needed and your goal is to “play something, turn the volume up, and then say test”, then it’s pretty much optimized.

@petro in another thread you showed me how to use scripts with data_template to use them in different automations. This we could avoid a lot copied and pasted code.

I copied the code above to every tts service call. So maybe this could be make it more compact.

Well then this could be made into a w/ variables

alexa_test:
  sequence:
    - service: media_player.play_media
      data_template:
        entity_id: "{{ media_player }}"
        media_content_id: "{{ content_id }}"
        media_content_type: "{{ content_type }}"
    - wait_template: "{{ is_state(media_player, 'playing') }}"
    - service: media_player.volume_set
      data_template:
        entity_id: "{{ media_player }}"
        volume_level: "{{ volume_level }}"
    - delay:
        milliseconds: 200
    - service: media_player.alexa_tts
      data_template:
        entity_id: "{{ media_player }}"
        message: "{{ message }}"

Then just call this in any action and fill it in with the appropriate info.

  - service: script.alexa_test
    data:
      media_player: media_player.echo_dotr
      content_id: Silence 5 Seconds
      content_type: AMAZON_MUSIC
      volume_level: 0.4
      message: "Test"
2 Likes

Thank you @petro

I remember a conversation about calling such a script (with variables) multiple times at the same time.

Will this fail when to automations trigger this script at the same time? I think the one that is triggers some milliseconds before will “win”, right? The other one will “ignored”?

Yes, I believe so. In that regard, you’d need to build a message queue. Normal HA automations can’t do that, but AppDaemon or a python script can.