Echo Devices (Alexa) as Media Player - Testers Needed

UPDATE!

0.4 released (for both the custom_component and hassio add-on.

Please be sure to update both the add-on and place the update alexa.py file in your media_player custom_components directory.

[https://github.com/keatontaylor/custom_components/blob/master/media_player/alexa.py]

Make sure you see VERSION 0.4 when downloading.

What this fixes:

  1. Support for other media providers besides amazon music. Spotify and others should show up correctly in HA now
  2. Better resolution album art
  3. Minor refactoring of the hassio add-on
1 Like

I did this for several devices:

curl -X POST -d 'deviceSerialNumber=G2A0P30774060QRT' http://192.168.1.11:8091/alexa-getState

{"statusCode":400,"body":"{\"message\":null}","headers":{"server":"Server","date":"Sat, 07 Jul 2018 09:09:20 GMT","content-type":"application/json","content-length":"16","connection":"close","x-amzn-requestid":"6ec33f41-81c5-11e8-ae18-2f0454587d02","x-amzn-alt-domain":"https://alexa.amazon.de/logout","x-amzn-error":"DEVICE_NOT_CONNECTED","vary":"Accept-Encoding,User-Agent"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"alexa.amazon.com","port":443,"hostname":"alexa.amazon.com","hash":null,"search":"?deviceSerialNumber=G2A0P30774060QRT&deviceType=A7WXQPH584YP&screenWidth=2560","query":"deviceSerialNumber=G2A0P30774060QRT&deviceType=A7WXQPH584YP&screenWidth=2560","pathname":"/api/np/player","path":"/api/np/player?deviceSerialNumber=G2A0P30774060QRT&deviceType=A7WXQPH584YP&screenWidth=2560","href":"https://alexa.amazon.com/api/np/player?deviceSerialNumber=G2A0P30774060QRT&deviceType=A7WXQPH584YP&screenWidth=2560"},"method":"GET","headers":{"Cookie":"session-id=135-8757514-3331324; session-id-time=2161671756l; csm-hit=H19GYE6J4KZ4EK9XSGJ8+s-H19GYE6J4KZ4EK9XSGJ8|1530951760584; ubid-main=133-1885545-6358834; x-main=\"zvIAjuxG3aIRu4fggnC@iRxgrz7DM2Xh\"; at-main=Atza|IwEBIKhay6PuyKu_BQQ3zCpvvpAMYmLaNs78yfg2BDevd80apUskkGZOeixuTOm2mOsATNb2BYvd_tkcAyYzgXaveVLDYwLS4k9-4GkrLBESXf5rDYGceS0PPytercBAi8Qu73d9KP7AtrkXl9n4DmwORGeSR2bqjDhtTi1Sv1Fzfnq9l0PbAMEaC4L0XylhoAxXwvteVo2u_KP2xuzd5nh1H4gjXEDkM6SphiUMuTEdBl_tjvhB0s3RqAYF-mhz1tbUIvnmIxuMAE8ygMGUYqdCBin8Fxv8AF5AnOd3JRkbPXrEI7lSF8ta3vhEvMtVVPerLuPcbUU_msXgwHzwlrRN7BsFV7DuNLalwCHZ91zCpuxywF4sYJLTuE--DsnDWN4kPzZhz_fyWaDVWpE1NM7Pa0va; sess-at-main=\"ib9UN1tuFCtATMvOULxOmbj4LoDF56hcz5tMpJCsLHw=\"; csrf=1821686027; ","csrf":"1821686027"}}}#

curl -X POST -d 'deviceSerialNumber=1084C963D52F4E85BB2556000DC1CA7A' http://192.168.1.11:8091/alexa-getState

{"playerInfo":{"hint":null,"infoText":null,"isPlayingInLemur":false,"lemurVolume":null,"lyrics":null,"mainArt":null,"mediaId":null,"miniArt":null,"miniInfoText":null,"playbackSource":null,"playingInLemurId":null,"progress":null,"provider":null,"queueId":null,"state":null,"template":null,"transport":null,"volume":null}}#

curl -X POST -d 'deviceSerialNumber=30559f9c4cd247a1a2d8ebfb9d8d7df2' http://192.168.1.11:8091/alexa-getState

{"playerInfo":{"hint":null,"infoText":null,"isPlayingInLemur":false,"lemurVolume":null,"lyrics":null,"mainArt":null,"mediaId":null,"miniArt":null,"miniInfoText":null,"playbackSource":null,"playingInLemurId":null,"progress":null,"provider":null,"queueId":null,"state":null,"template":null,"transport":null,"volume":null}}#

curl -X POST -d 'deviceSerialNumber=G090LF1180340C7E' http://192.168.1.11:8091/alexa-getState

{"statusCode":400,"body":"{\"message\":null}","headers":{"server":"Server","date":"Sat, 07 Jul 2018 09:12:13 GMT","content-type":"application/json","content-length":"16","connection":"close","x-amzn-requestid":"d6232db8-81c5-11e8-b808-67070dedb794","x-amzn-alt-domain":"https://alexa.amazon.de/logout","x-amzn-error":"DEVICE_NOT_CONNECTED","vary":"Accept-Encoding,User-Agent"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"alexa.amazon.com","port":443,"hostname":"alexa.amazon.com","hash":null,"search":"?deviceSerialNumber=G090LF1180340C7E&deviceType=A3S5BH2HU6VAYF&screenWidth=2560","query":"deviceSerialNumber=G090LF1180340C7E&deviceType=A3S5BH2HU6VAYF&screenWidth=2560","pathname":"/api/np/player","path":"/api/np/player?deviceSerialNumber=G090LF1180340C7E&deviceType=A3S5BH2HU6VAYF&screenWidth=2560","href":"https://alexa.amazon.com/api/np/player?deviceSerialNumber=G090LF1180340C7E&deviceType=A3S5BH2HU6VAYF&screenWidth=2560"},"method":"GET","headers":{"Cookie":"session-id=135-8757514-3331324; session-id-time=2161671756l; csm-hit=H19GYE6J4KZ4EK9XSGJ8+s-H19GYE6J4KZ4EK9XSGJ8|1530951760584; ubid-main=133-1885545-6358834; x-main=\"zvIAjuxG3aIRu4fggnC@iRxgrz7DM2Xh\"; at-main=Atza|IwEBIKhay6PuyKu_BQQ3zCpvvpAMYmLaNs78yfg2BDevd80apUskkGZOeixuTOm2mOsATNb2BYvd_tkcAyYzgXaveVLDYwLS4k9-4GkrLBESXf5rDYGceS0PPytercBAi8Qu73d9KP7AtrkXl9n4DmwORGeSR2bqjDhtTi1Sv1Fzfnq9l0PbAMEaC4L0XylhoAxXwvteVo2u_KP2xuzd5nh1H4gjXEDkM6SphiUMuTEdBl_tjvhB0s3RqAYF-mhz1tbUIvnmIxuMAE8ygMGUYqdCBin8Fxv8AF5AnOd3JRkbPXrEI7lSF8ta3vhEvMtVVPerLuPcbUU_msXgwHzwlrRN7BsFV7DuNLalwCHZ91zCpuxywF4sYJLTuE--DsnDWN4kPzZhz_fyWaDVWpE1NM7Pa0va; sess-at-main=\"ib9UN1tuFCtATMvOULxOmbj4LoDF56hcz5tMpJCsLHw=\"; csrf=1821686027; ","csrf":"1821686027"}}}#

Some of them are real echo devices and some are mobiles with apps running. I only need the real echos so far. The one with the big return seem to be my real echo devices, but not 100% sure.

Everything was working fine before the last update. Now I’m getting this error:

TypeError: Cannot read property 'alexaURL' of null
at Object.getDevices (/workspace/alexa-api.js:181: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

UPDATE: Found the error, have to put the full URL ( “url”: “https://alexa.amazon.com”) after the login settings.

1 Like

I tried it last night while i couldnt sleep and it seems to work perfectly, even works with the fire tablets

Hey!
so fare very nice and right in time :slight_smile:
Does anybody already has set up a pick list to select you favorite radio and or playlist?

And I’m still struggling to use alexa for TTS - actualy I Use my Sonos with that script.
May that would be usefull and suitable for alexa as well:

sonos_say:
alias: Sonos TTS script
sequence:

  • service: media_player.sonos_snapshot
    data_template:
    entity_id: ‘{{ sonos_entity }}’
  • service: media_player.sonos_unjoin
    data_template:
    entity_id: ‘{{ sonos_entity }}’
  • service: media_player.volume_set
    data_template:
    entity_id: ‘{{ sonos_entity }}’
    volume_level: ‘{{ volume }}’
  • service: tts.google_say
    data_template:
    entity_id: ‘{{ sonos_entity }}’
    message: ‘{{ message }}’
  • delay: ‘{{ delay }}’
  • service: media_player.sonos_restore
    data_template:
    entity_id: ‘{{ sonos_entity }}’

okay - I got the TTS part :slight_smile:

even more easy than sonos

  • service: media_player.alexa_tts
    data_template:
    entity_id: “media_player.Stiffs_echo”
    message: “Hello everybody.”

next I try to figure out how to adress the content ID in Amazon music

- service: media_player.play_media
  data_template:   
    entity_id: "media_player.Stiffs_echo"
    media_content_id: ????
    media_content_type: audio/mp3

@Stiff04, play_media does not yet work. Currently a work in progress.

thanks for the answere - so do I understand right. Actual it is not possible to choose a playlist or a song?

Not yet possible, but coming soon.

Could you expose all ‘in development’ features?

Since this is basically in development all features that have been implemented so far are in the 0.4 version released.

Sorry, I meant unreleased features that you’re working on.

Response is the same, what I have written is what is released so far. Things on the todo list but nothing yet written.

Hi

i changed alexa.amazon.com to alexa.amazon.de and now it is working fine!
So if you live in gemrnay, use that. Ty for this good work so far!

Regards

custom_componets/media_player

or

custom_components/media_player ??

Great addon, thanks!!

Just installed it successfully.

Noob question:
I like to use the tts possibility.
Is it possible to control the volume using tts, so just louder the volume during the message?

custom_components/media_player

I would love to use this, but my Home Assistant fails to install the addon with the following error message:

18-07-08 11:38:19 ERROR (SyncWorker_4) [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").

Any thoughts?

could you imaging to support also playing local files, or something like mopidy?

I would like to store some files on the raspberry and output them on the echo.

kind regards

Hmm, @flobbo this might an issue with docker hub. The image most certainly does exist.