Echo Devices (Alexa) as Media Player - Testers Needed

The device family for Echo Show is “KNIGHT”.

When I move the volume slider to 0, it “mutes” it and disables the volume slider so I cannot turn the volume back up. Is this a bug? Does anyone else have this issue?

Edit: Nevermind. Looking at the code, I see that the mute functionality does not do anything if the echo is not playing music.

This looks interesting, I’m especially interested in the Alexa TTS feature. I basically just want all my Echoes to say ‘Ding Dong’ when my doorbell (MQTT) is pressed. Currently I have a doorbell chime playing on a Xiaomi gateway but have Echoes elsewhere that I’d also like to make a noise.

Would this add-on allow me to do that? In OP it suggests that TTS can only be triggered from the UI? Or can it also be from a script / automation?

Yes, the doorbell TTS works in script and automation. I have Alexa make a spoken message, so the dogs won’t bark at the chime sound. Alexa is actually constantly giving all kinds of sensor information around the house with this component. I love it, my wife doesn’t

1 Like

Thanks! Is it possible you could share a snippet of your TTS automations?

You can pass sensor info into it? E.g. it could say the temperature based on some temp sensors I have?

Also, now you mention it, I have an alarm system and would love Alexa to be announcing when it’s triggered etc…

Sure. This is my ‘alarm triggered’ script.

alarm_triggered:
  sequence:
  - data:
      data: 
        icon: https://goo.gl/xeetdy
        vibration: 0,65,706,86,657,95,668,100"
      message: "House alarm away!!!"
      title: "Home Assistant"
    service: notify.phones
  - data:
      entity_id: media_player.downstairs
      volume_level: "1"
    service: media_player.volume_set
  - data_template:
      entity_id: media_player.downstairs
      message: -> 'Attention, the alarm has been triggered. The owner has been notified.'
    service: media_player.alexa_tts
  - data_template:
      entity_id: media_player.upstairs
      message: -> 'Attention, the alarm has been triggered. The owner has been notified.'
    service: media_player.alexa_tts
  - data:
      entity_id: group.all_covers
    service: cover.open_cover
  - data:
      entity_id: switch.counter_top
    service: switch.turn_on
  - data:
      entity_id: switch.bedroom_light
    service: switch.turn_on
  - data:
      entity_id: switch.dining_table
    service: switch.turn_on
  - data:
      entity_id: switch.lr_ceiling_power
    service: switch.turn_on
  - data:
      entity_id: switch.outside_light
    service: switch.turn_on
  - delay: 00:00:08
  - data_template:
      entity_id: media_player.downstairs
      message: -> 'Attention, the alarm has been triggered. The owner has been notified.'
    service: media_player.alexa_tts
  - data_template:
      entity_id: media_player.upstairs
      message: -> 'Attention, the alarm has been triggered. The owner has been notified.'
    service: media_player.alexa_tts

And my ‘welcome home’ script:

remco_home:
  alias: Remco home
  sequence:
  - data:
      entity_id: group.alarm
    service: switch.turn_off
  - data:
      entity_id: switch.drapes_open
    service: switch.turn_on
  - wait_template: '{{ is_state(''sensor.broadlink_s1c_sliding_door'', ''open'') }}'
    timeout: 00:30:00
  - delay: 00:00:12
  - data_template:
      entity_id: media_player.downstairs
      message: -> 'Hello Remco. Welcome home. Cherry is {% if is_state("device_tracker.zy223rkvxx",
        "home") -%} also at home. {%- else -%} not at home. {%- endif %} The temperature
        inside is {{ states("sensor.broadlink_sensor_temperature") }} degrees. And
        outside it is {{ states("sensor.weather_temperature") }} degrees.'
    service: media_player.alexa_tts

And when I unplug my cellphone from the charger in the morning:

remco_awake:
  alias: Remco woke up
  sequence:
  - data:
      entity_id: group.alarm
    service: switch.turn_off
  - data:
      entity_id: switch.drapes_open
    service: switch.turn_on
  - data_template:
      entity_id: media_player.upstairs
      message: -> 'Hello Remco. Goodmorning. The temperature outside is {{ states("sensor.weather_temperature")
        }} degrees. There will be {% if states("sensor.weather_precipitation") ==   '0.0'  -%}
        no rain today. {%- else -%} {{states("sensor.weather_precipitation")}} milimeter
        of rain today, bring an umbrella. {%- endif %} Your first calendar item is;
        {{ states("sensor.next_appoint_remco_message") }}, at {{ states("sensor.next_appoint_remco_tijd")
        }}. Your Travel time to work is approximatly {{ states("sensor.waze_travel_time")
        }} minutes if you take {{ states.sensor.waze_travel_time.attributes.route
        }}. Have a nice day'
    service: media_player.alexa_tts
  - wait_template: '{{ is_state(''sensor.broadlink_s1c_living_room_door'', ''open'')
      }}'
    timeout: 00:30:00
  - delay: 00:00:05
  - data_template:
      entity_id: media_player.downstairs
      message: -> 'Hello Remco. Your Travel time to work is approximatly {{ states("sensor.waze_travel_time")
        }} minutes if you take {{ states.sensor.waze_travel_time.attributes.route
        }}. Have a nice day.'
    service: media_player.alexa_tts
2 Likes

And my doorbell script;

doorbell:
  alias: Doorbell
  sequence:
  - service: media_player.alexa_tts
    data_template:
      entity_id: media_player.downstairs
      message: -> ' Ding-Dong. Someone is at the door.'
  - service: media_player.alexa_tts
    data_template:
      entity_id: media_player.upstairs
      message: -> ' Ding-Dong. Someone is at the door.'
1 Like

Nice work!
I have imported the flow but getting messages about Home assistant connection failed with error: Connection to home assistant could not be established with config: DUMMY_URL

I have connected all of the server nodes, but not sure where to change the DUMMY URL and what it should be?

I have been able to get TUNEIN radio to work!
Has anyone been able to get iHeartRadio to work?

alexa_play_radio_wtvn:

alias: Radio Alexa play Radio WTVN Kitchen
sequence:

  • service: media_player.play_media
    data:
    entity_id: media_player.kitchen
    media_content_id: WTVN
    media_content_type: “iHeartRadio”

Tried this and not working.

1 Like

Found this thread and setting up was super easy, thanks to all the various contributors, so big thanks and have TTS working for various trigger activities now.

I’d like also to be able to a) stream radio and b) play local media files. Realising that b) is not yet possible, does anyone have examples of how to stream audio, initiated from HA? preferably through the media_player interface?

Can anyone here help me with solution how to set Alexa media player value while it is in standby state?

Problem details are described in separate thread

Thanks! This is excellent. Appreciate it.

Followed the guided procedure from the first post, working like a champ.

Hats off. Excellent work. Thanks…

I’m running on Hasso.io 79.3.

I’m still hoping for a solution to the volume control on idle issue.

Is that not going to happen or is it working now and I just missed it?

@inutilis @rclust @finity @Birdbrainuk
Try my version, here. I’ve never programmed in Python before so it’s not very efficient, but this should allow you to change the volume when the echo is in idle/standby, either by using the media_player.volume_set service call, or media_player.alexa_tts.

Note that when using the alexa_tss call, you’ll now need to specify the volume you want to set. Also note that when the echo is in standby, there will be an additional ~10 second delay before the TTS.

Example:

{
“entity_id”: “media_player.my_echo_dot”,
“message”:“testing 1 2 3 4”,
“volume”:“.5”
}

2 Likes

Request to add the following into the alexa.py config file.

Ability to only display standby devices.

There was an earlier post on adding this to line 212. However, this is now on line 214.

     for device in devices:

        if device['online'] is False:
            continue

Edited: Also, would be great to hide the Silent Track

Thanks for the help.

So just to be clear…

I need to replace the contents of the existing ‘alexa.py’ file with the contents from your repo.

Then from then on everything will work exactly the same except that on every TTS service call you will be required to specify the volume and there will be a 10 second delay while the echo device automatically plays a 10 second silent track and adjusts its volume to the selected volume?

And if you use the volume_set call then it will again automatically play a 10 second silent track while it adjusts the volume to the selected volume?

Basically, yes. It doesn’t play for ten seconds, but that’s just roughly how long it takes to queue up the song, play it, and then play the TTS message. This delay will only happen when the echo is in standby. One other thing… I have Prime Music Unlimited, so I’m honestly not sure if the song I chose is available for non-Unlimited members. Someone will just have to test it and see.

Thank you for this amazing component. Now I can send notifications to all my Echos in my home.

However in order to send notification to my Echo, I have to use this custom service; media_player.alexa_tts. Example action in automation…

  action:
    service: media_player.alexa_tts
    entity_id: media_player.office
    data:
      message: "Message goes here"

But I prefer to send notifications via the notify service so that I don’t have to change all my existing automation that uses the notify service.

My solution is to recreate the notify entities using Rest platform:

Example for one Echo device…

notify:
  - name: office
    platform: rest
    resource: 'https:/[YOUR HA URL]/api/services/media_player/alexa_tts'
    method: POST_JSON
    data:
      entity_id: 'media_player.office'
    headers: 
      x-ha-access: !secret http_password
      content-type: 'application/json'

Hope this helps if you are looking for similar solution.

1 Like

By the way, the Alexa TTS seems to ignore the degree (°) or percent (%) symbol in temperature. e.g. 31.1 °C.

It reads out as… “thirty one point one C” instead of “thirty one point one degree Celsius”.

My other custom news briefing and skills for alexa read out fine.

Is it due to encoding issue?