Echo Devices (Alexa) as Media Player - Testers Needed

Everything worked just fine until I installed 0.4 and HA 0.73.1. Now it wont find the entity mediaplayer.alexa… Anyone alse who have the same error?

You should use the docker IP, not the device IP.

It seems that the docker image doesn’t play very well with portainer. If you try to restart it from portainer you got this on the logs:

Fatal server error:
(EE) Server is already active for display 99
    If this server is no longer running, remove /tmp/.X99-lock
    and start again.

any hints?

Here is how I have it set up in Unraid. based on your eror message, I think you need to include the tag “:0.4” on the end of the repository name.

1 Like

@keatontaylor thank you for the component
trying follow the container installation, but getting these errors in the docker log

Mon, 09 Jul 2018 12:40:53 GMT nightmare running
There was an errorInternal endpoint: 
curl -X POST -d "tts=Ask Alexa team for a proper TTS API" -d "deviceSerialNumber=deviceSerialNumber" http://localhost:8091/alexa-ttst request for getDevicesTypeError: 
Cannot read property 'alexaURL' of null
    at Object.getDevices (/workspace/alexa-api.js:180:19)
    at /workspace/index.js:29:13
    at Layer.handle [as handle_request] (/workspace/node_modules/express/lib/router/layer.js:95:5)
    at next (/workspace/node_modules/express/lib/router/route.js:137:13)
    at urlencodedParser (/workspace/node_modules/body-parser/lib/types/urlencoded.js:100:7)
    at Layer.handle [as handle_request] (/workspace/node_modules/express/lib/router/layer.js:95:5)
    at next (/workspace/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/workspace/node_modules/express/lib/router/route.js:112:3)    at Layer.handle [as handle_request] (/workspace/node_modules/express/lib/router/layer.js:95:5)
    at /workspace/node_modules/express/lib/router/index.js:281:22

@keatontaylor Oops. I incorrectly explicitly referenced individual Echo devices. I went back and reread the first post and realized all I needed to do was call the platform once.

media_player:
  - platform: alexa

Now I am getting the following error.

Could not connect to alexa server at http://addon_9ff8aed5_alexaapi (HTTPConnectionPool(host='addon_9ff8aed5_alexaapi', port=8091): Max retries exceeded with url: /alexa-getDevices (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fbe55ea9710>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)))

@clyra Thank you for that! Updating my definition to the following resolved all errors. Now to get to testing

media_player:
  - platform: alexa
    host: 10.0.0.20

Oh YEAH! I was just able to send TTS that played through my Echo Show’s speakers!!!

{"entity_id": "media_player.echo_living_room", "message": "Test message"}

FYI, here is how I added your Alexa API to my docker-compose.yaml.

  alexa_api:
    container_name: alexa_api
    image: keatontaylor/amd64-addon-alexa-api:0.4
    environment:
      - TZ=America/Los_Angeles # offset = -08:00 / DST -07:00
      - PGID=1004
      - PUID=1000
    ports:
      - 8091:8091
    restart: unless-stopped
    volumes:
      - /opt/alexa_api:/data
      - /etc/localtime:/etc/localtime:ro

The PGID & PUID may not be necessary, but I recently started using it in all of my containers by default just in case.

1 Like

@clyra, I do need to fix this and do a test if the xvfb display is already set.

@planet4 make sure you’re also using the most up-to-date version of the custom_component as well. it will have the VERSION 0.4 in the top comment block

Advice on Dilemma

I have been trying to get code to work for play_media so that you could select playlists/songs/stations to playback and wanted to discuss some of the issues with implementing it in hopes of getting feedback.

The major issue is that content ids need to be provided specific to the content type and provider. Now I can code this and allow the user to select the content type and ID via the play_media service, but the IDs are not human readable and not something that can be easily queryable by the user.

My thinking was that I would use the select_source method to allow a visual representation of all playlists/stations that can be selected for prime music, but unfortunately this will be limited to prime music if I went this route.

The other alternative is to provide the IDs necessary to playback that specific content when that content is playing. So a user could request Alexa to play Spotify and gather the ID from the media_players attributes and use that for automatons to play that song/playlist/album again

I’m not really sure what would be the best user experience so I want to get thoughts from all of those that have been so helpful in testing things.

I also wanted to try it. But when I press install I get this message:

18-07-09 20:30:52 INFO (SyncWorker_18) [hassio.docker.interface] Pull image keatontaylor/armhf-addon-alexa-api tag 0.4.
18-07-09 20:31:01 ERROR (SyncWorker_18) [hassio.docker.interface] Can't install keatontaylor/armhf-addon-alexa-api:0.4 -> 404 Client Error: Not Found ("no such image: keatontaylor/armhf-addon-alexa-api:0.4: No such image: keatontaylor/armhf-addon-alexa-api:0.4")

Hass anyone an idea?

Hmm, ran the command in docker on my machine and not get the 404. Could I get some more information. Are you running on a raspberry pi and what is your region/country.

Thanks for your support. Of course you can:

Raspberry Pi 3 with hass.io and germany (BW)

Other Add-Ons are working fine. So I don’t unterstand it at the moment.

Hi keatontaylor,

Thanks alot for the component . Do you plan by any chance to introduce the feature to connect to a Bluetooth device ? It was part of the shell script project you mentioned . It would be awesome to manage this over home assistant too.
I’m
Greetings

@nimey, absolutely!

@PrivatHomeServer not sure, I can pull it manually just fine copying the output from your logs. I also don’t think that docker hub has any region specific requirements. If you’re familiar with docker command line could you run:

docker pull keatontaylor/armhf-addon-alexa-api:0.4

and post the output?

My vote would be to “provide the ID’s necessary to playback that specific content when the content is playing”. I believe that is how the spotify component currently does it, so I would think it would make sense to stay consistent. Not sure if other components handle it the same way or not.

You can send playlists to spotify via the “media_content_type”: “playlist” and “media_content_id”: “spotify:user:spotify:playlist:37i9dQZF1DWSkkUxEhrBdF” which are a part of the media_player.play_media service, you can test this from the services control panel in the Home Assistant frontend.

Since I started playing with this code today Alexa keeps repeating something about “Simon Says”. Has anyone else had that? So far it only seems to happen on my Echo Show.

I guess she will repeat what you say if you say “Simon Says”. My wife thinks it triggers when it sees us move. I’ve disabled the code because we’re watching a movie. I will try to do more testing tomorrow.

@BrianHanifin, the way the TTS works is that is calls the same code that routines call if you had them speak something custom. On the amazon backend it is simply instructing the echo to say something as if you asked "Simon Says, ", hence the reason for the history showing that.

AMAZON REQUESTING CAPTCHA

I am also having the issue where Amazon is asking for captcha, I cant figure out how to get this addon to successfully login.

Im getting the “TypeError: Cannot read property ‘alexaURL’ of null” even tho my username and password is correct.

Does anyone have a solution for completing the captcha or allowing this addon to successfully login?

@J.eremy make sure that the settings in the plug-in are as follows. (with your settings of-course)

{
  "username": "[email protected]",
  "password": "mysupersecretamazonpassword",
  "url": "https://alexa.amazon.com"
}

The reason for using nightmare.js for the login was to avoid the captcha issues that plagued the shell/bash script written by others. So I’d double check that the above settings are absolutely correct and for the correct region that you live in, especially the URL.