Echo Devices (Alexa) as Media Player - Testers Needed

I have the normal 2FA, had to do this re-auth every couple days. But didn’t have any “new password required” so far.

This is what I use:

entities:
  - entity: input_select.alexa_state
    name: Select Alexa device
  - entity: input_text.cmd_text
    name: 'Type question/command here:'
    type: 'custom:text-input-row'
  - action_name: Run Command/Ask Question...
    icon: 'mdi:voice'
    name: ' '
    service: script.send_alexa_command
    type: call-service
  - action_name: Stop Alexa
    icon: 'mdi:voice'
    name: ' '
    service: script.stop_alexa_command
    type: call-service
  - entity: input_text.announcement_text
    name: 'Type announcement text here:'
    type: 'custom:text-input-row'
  - type: call-service
    name: ' '
    icon: 'mdi:voice'
    action_name: Announce It...
    service: script.send_alexa_annoucement
type: entities

Screen Shot 2020-12-21 at 4.10.24 PM

I believe all the scripts referenced are from the Alexa Media Player wiki. The “Stop Alexa” button action is nice if you accidentally leave her playing in another room or you can hear a timer going off, you can stop it without having to talk to her and guessing which echo device is playing.

This is my card as shown above…

type: entities
entities:
  - entity: input_select.target_echo
  - entity: input_text.alexa_command
    name: Do...
    type: 'custom:text-input-row'
  - entity: input_text.speak
    name: Say...
    type: 'custom:text-input-row'
title: Alexa commands

Is there any way to shorten the response time after Alexa says ok, till the message is read

Can you share your scripts?

I just wanted to post this in case the open-source code might help with re-authentication.
Back in October, I moved my Alexa TTS from AMP to node-red-contrib-alexa-remote2. It’s been working well.
Well, discovered it has a neat feature that refreshes the account’s login cookies.
Since it’s node red, I have a simple flow that refreshes my Amazon account cookies every 60 minutes. This means I don’t have to re-auth the account.

The function call to refresh the cookie is:

The node is called the "alexa init’ node and the option is “Refresh Cookie”.
Here’s a screenshot:
alexa-remote2 init node, refresh cookie Screen Shot 2020-12-22 at 7.32.51 PM

Maybe someone can reverse-engineer how this Refresh Cookie function talks to Amazon and use a similar approach to help with the re-auth issues here in AMP.
The “Refresh Cookie” running every 60 minutes has been key to my Alexa TTS running reliably since October.

For that node, when you create an account for alexa-remote2 you can use the “File Path” to save the cookie info and it will automatically refresh it. Below is my setting, I never have to re-auth my account.

Yeah, I had the refresh set to “1 days”, but would still have to re-auth. So that’s why i now refresh cookie every 60 minutes.

1 Like

Good to know. Thanks. For me, I never have to re-auth on that node, but frequently on this component. It is same amazon account :frowning:

I have the following setting in notifiers.yaml which doesn’t work. What am I doing wrong?

- name: broadcast
  platform: group
  services:
    - service: tv
    - service: hangouts_chatgroup
    - service: alexa_media
      data:
        type: announce
      target:
        - media_player.bedroom

I also tried using notify.alexa_media_bedroom without the target, but no luck.
I even tried defining a new notifier for a certain target and then used it as a service in the group notifier (like with my hangouts_group) and that doesn’t work as well.

I want to continue using my notification group, as I have complex templated messages that I don’t want to copy/paste in several automations.

Thanks for posting. Currently working on this here in case anyone wants to try to help (as in code as I’m stuck).

1 Like

I have a simple Node-Red sequence that triggers an announcement to all our devices if someone rings the doorbell, which is great. However, if I’m on a conference call in my office I’d like to stop my Echo Dot from announcing. If I enable the Do Not Disturb switch it doesn’t seem to stop it. Any ideas?

1 Like

Any idea why I am seeing this in the Supervisor CORE logs:

/usr/local/lib/python3.8/site-packages/alexapy/aiohttp/connector.py:999: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  hosts = await asyncio.shield(

I’ve followed this to setup my office and kitchen echo dots, I am able to send command and announcement to them individually. However when select ‘all’, which map to ‘Everywhere’, none of the echo dot responds. In Alexa app, I have a speaker group “Everywhere” which includes both echo dots.

Below is my sensor section:

sensor:
  - platform: template
    sensors:
      alexa_selector:
        friendly_name: "Alexa Selector Sensor"
        value_template: >
          {%- set room = states("input_select.alexa_state")|replace('media_player.','') -%}
          {%- if room == "office" -%}
            office_dot
          {%- elif room == "kitchen" -%}
            kitchen_dot
          {%- elif room == "all" -%}
            Everywhere
          {%- endif -%}

What could be the issue and how to do troubleshooting? I don’t see any error on the log file. Thanks.

You should not write “Everywhere” in capital letters. Write everywhere

Henry,

As Jörg replied, “everywhere” needs to be all lowercase just like “office_dot” and “kitchen_dot”. The names you use in the selector can be capitalized if you prefer (i.e. Office, Kitchen, All) but not the device name that is used in the template.

Thanks @Pirol62 @Didgeridrew, this works. I was thinking it should be same as what in the Alexa app which is wrong.

Btw: where can I find more information about the syntax of the script?

Henry,

Check out these pages in the docs:
YAML
Templating

1 Like

It’s because in python 3.10 the version of aiohttp we use will be deprecated. Now that HA is actually using updated versions of aiohttp again I may decide to switch back to using the HA version assuming I upstream my bug fixes back to aiohttp.

2 Likes