Echo Devices (Alexa) as Media Player - Testers Needed

Awesome! Thanks didn’t even notice the media_player.alexa.tts

@keatontaylor
I just wanted to take a second to say THANK YOU for this. I have a sonos that I’ve used for TTS for a while it although it works well, I only have one in my house. Now, suddenly this has opened a whole new world. Using the 6 or so various devices around my house (Echos, Dots, Show and Spot) I am now able to really use TTS for notifications like I’ve always wanted to.

Alert me in my bedroom at night if the doors are opened after I go to bed - Check!
Alert me on every speaker in my house if there is a water leak detected - Check!
Just let me know when doors or windows open, but just in my centrally located Echo - Check!
Let me know when it’s time to leave for work based on traffic conditions - Check!

I’ve been getting push bullet notifications for all of these, which is OK, but getting a nice verbal notice from my echos, is really what I’ve always wanted in a smart home.

Seems like there are still a few kinks for some people running hass.io, but I’m sure that will be fixed soon. I just hope that nothing changes in the future at amazon to block this.

For me other than the obvious, turning lights off and on, locking doors, etc, this is going to be the most useful thing I have running.

2 Likes

I’m having the exact same experience. I can open the alexa_mediapost file and login fine, (although I did have to do the captcha twice), but I still can’t login through the configurator.

I’m also like you having the second configurator line popup and disappear from time to time. Not every time as far as I can tell, but maybe every 3rd or 4th.

EDIT: I did just notice an error that I hadn’t noticed before. Every time the captcha fails, I get an error in the log stating:

2018-08-10 22:03:56 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

Are you having this too @finity?

I’m getting the same error message. Did you ever figure this out?

humm the below does not seem to work alexa just announces the whole thing in {} rather than the ‘state’ what am I doing wrong @keatontaylor ?

{"entity_id": "media_player.master_bed", "message": "Attention. It looks like its raining currently {{ states ('sensor.netatmo_rain_gauge_rain') }} millimeters has fallen" }

@Corey_Maxim,@finity
Please turn on debug mode as it will explain where you are in the login process when it fails. The debug .html only lets you know what the page looks after we submit info, logging in won’t help with the component. Have you tried turning on the _LOGGER.debug("Submit Form Data. . . line that shows what info is submitted to the page to verify email and password are correct?

@basschipper:
Does switching the url domain to amazon.com change the result with tts? Can you see the media_player tiles and see the state when music is streaming?

@staticmethod
def get_devices(url, session):
try:
response = session.get(‘https://alexa.’ + url +
‘/api/devices-v2/device’)
return response
except:
_LOGGER.error(“An error occured accessing the API”)
return None
this?

I wanted to suggest, that maybe this post should be separated into two. the help section getting alexa_tts running and the what you can do with the working component or issues with automatons/scripts etc. I did have this working for a few days restarted and it wasn’t working then finally go it running again until a restart now im stuck. im very interested in what others are doing with it when its working be because this post is so very popular a lot gets buried. just a thought. :slight_smile:

Hi @alandtse,

Thanks for helping, when I switch to amazon.com the state is giving me unavailable:
08

Also, when I login to https://alexa.amazon.com I’m redirected to .co.uk, so I think I should use co.uk?

Yah, if it’s redirecting, it probably makes sense to use amazon.co.uk. Can you see the media player update when you play music? Can you control the music with the tile?

I have no music provider connected to the Echo, but when I unplug the Echo from mains it switches to unavailable. So, the login and device connection seems to be ok.
Mmmm, my initial login was at .com before I switched to .co.uk, maybe there’s something wrong with the cookie let me try a re-login with .co.uk.

Edit:
Yes! It’s working now, relogin did the trick, Thanks for pointing me in the right direction!

I am running ha on arch linux and have installed this component and confirmed TTS works perfectly with automations and scripts!

I have noticed however that if alexa is busy playing the radio or something else that she doesn’t wake up and spit out the TTS message. Is there a way to force her to be interrupted so the message still gets through?

@alandtse

Here is the output of the log after restarting HA and one attempt at the captcha:

2018-08-11 10:43:17 DEBUG (SyncWorker_4) [custom_components.media_player.alexa] Fetching cookie from file /config/alexa_media.pickle
2018-08-11 10:43:17 DEBUG (SyncWorker_4) [custom_components.media_player.alexa] Error loading pickled cookie from /config/alexa_media.pickle: An exception of type FileNotFoundError occurred. Arguments:
(2, 'No such file or directory')
2018-08-11 10:43:17 DEBUG (SyncWorker_4) [custom_components.media_player.alexa] No cookies for log in; using credentials
2018-08-11 10:43:17 DEBUG (SyncWorker_4) [custom_components.media_player.alexa] Captcha: None SecurityCode: None
2018-08-11 10:43:17 DEBUG (SyncWorker_4) [custom_components.media_player.alexa] Submit Form Data: {'appActionToken': 'huuEZ3RfgApZb5VgdJCsZ933rEcj3D', 'appAction': 'SIGNIN_PWD_COLLECT', 'openid.pape.max_auth_age': 'ape:MA==', 'openid.return_to': 'ape:aHR0cHM6Ly93d3cuYW1hem9uLmNvbS9ncC9jc3MvaG9tZXBhZ2UuaHRtbC8xMzgtNzMzMjExMS0zNTQ5MTQ0P2llPVVURjgmJTJBVmVyc2lvbiUyQT0xJiUyQWVudHJpZXMlMkE9MA==', 'prevRID': 'ape:WDhQMjc1VEhRMjJNRFIwWEFUUUI=', 'openid.identity': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=', 'openid.assoc_handle': 'ape:dXNmbGV4', 'openid.mode': 'ape:Y2hlY2tpZF9zZXR1cA==', 'openid.ns.pape': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvZXh0ZW5zaW9ucy9wYXBlLzEuMA==', 'prepopulatedLoginId': '', 'failedSignInCount': 'ape:MA==', 'openid.claimed_id': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=', 'pageId': 'ape:dXNmbGV4', 'openid.ns': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjA=', 'email': '[email protected]', 'password': 'scrubbed', 'create': '0'}
2018-08-11 10:43:18 DEBUG (SyncWorker_4) [custom_components.media_player.alexa] Captcha requested
2018-08-11 10:43:18 DEBUG (SyncWorker_4) [custom_components.media_player.alexa] Creating configurator to request captcha
2018-08-11 10:43:25 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.124 (auth: False)
2018-08-11 10:43:35 WARNING (SyncWorker_1) [netdisco.ssdp] Error fetching description at http://10.26.10.6:63903
2018-08-11 10:43:37 DEBUG (MainThread) [custom_components.media_player.alexa] Status: {'captcha_required': True, 'captcha_image_url': 'https://opfcaptcha-prod.s3.amazonaws.com/405c92c34c6c4dbdba6a7a57f1c207a5.jpg?AWSAccessKeyId=AKIAIY47NMAQVBRQOU5A&Expires=1533998898&Signature=G%2FaFM8AAeCVJhu0eApt4ioaeGNo%3D'} got captcha: nmqa2d securitycode: None
2018-08-11 10:43:37 DEBUG (MainThread) [custom_components.media_player.alexa] No cookies for log in; using credentials
2018-08-11 10:43:37 DEBUG (MainThread) [custom_components.media_player.alexa] Captcha: nmqa2d SecurityCode: None
2018-08-11 10:43:37 DEBUG (MainThread) [custom_components.media_player.alexa] Submit Form Data: {'appActionToken': 'huuEZ3RfgApZb5VgdJCsZ933rEcj3D', 'appAction': 'SIGNIN_PWD_COLLECT', 'openid.pape.max_auth_age': 'ape:MA==', 'captchaObfuscationLevel': 'ape:aGFyZA==', 'openid.identity': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=', 'forceValidateCaptcha': 'ape:dHJ1ZQ==', 'pageId': 'ape:dXNmbGV4', 'ces': 'ape:QUNTXzRzZW9lZlRoSWtqakxFWXRiMU43LzM5L2YzOEFBQUFBQUFBQUFRTW5TOEtrOGNUQnJieWgySEd2RXk3N0d1VDBualYvWjd0bzNVN2pMVGFjQUdhcEwzZys4ZWZ6YTE1WHVsTVJaTUQ0alpPRkMyZTdsVWdlUk1uUndIR1BWU0ZhRFNnSTRLeFJqaDdDTXkrWUM1NXNtWEdma2RhVXczRG1OUUpNUVFSRUxSSUkvbkUycCtSdUZPMy83VzF5VEZEOXhiMVQzb20xdnBleUMwaTR3cjFabU5QRGFjOENUbkJXUEdHcWNLdWlGWS83QVZzTGhNS3lsMzFqL2ZKN2t1MmJBU3dZYnhzT3lpQW4zVndHQjFrTGx2RlU0dXJzd3lETGtWMHVlTFBBbDhSTTY3ekM3M1VKckE5bFF3bkN4eUdWNENPbVdHaU1sWXErR1VZc1ZDdnBQNEZsYjRjcnkzTE8zOEozcUxLcktGeE12ZkxHN2lQRXo5OE1DQXc9', 'openid.return_to': 'ape:aHR0cHM6Ly93d3cuYW1hem9uLmNvbS9ncC9jc3MvaG9tZXBhZ2UuaHRtbC8xMzgtNzMzMjExMS0zNTQ5MTQ0P2llPVVURjgmJTJBVmVyc2lvbiUyQT0xJiUyQWVudHJpZXMlMkE9MA==', 'prevRID': 'ape:TllYUU05V1E0N0pZQkM5MkFQTjg=', 'openid.assoc_handle': 'ape:dXNmbGV4', 'openid.mode': 'ape:Y2hlY2tpZF9zZXR1cA==', 'openid.ns.pape': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvZXh0ZW5zaW9ucy9wYXBlLzEuMA==', 'prepopulatedLoginId': 'ape:ZXlKamFYQm9aWElpT2lKQ2JUUmpkWFJVY3poaFIwczBlREZEVGpOdFIyWldSM1ZzVFVSeVoyYzJWa1pUYUZoWmIyNTVSVkl3UFNJc0lrbFdJam9pVERGM01sbHBRV1l6VlhNd1ZIWnFTbHBaUm5sTlVUMDlJaXdpZG1WeWMybHZiaUk2TVgwPQ==', 'failedSignInCount': 'ape:MQ==', 'openid.claimed_id': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=', 'openid.ns': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjA=', 'email': '[email protected]', 'password': 'scrubbed', 'use_image_captcha': 'true', 'use_audio_captcha': 'false', 'guess': 'nmqa2d', 'rememberMe': 'true'}
2018-08-11 10:43:37 DEBUG (MainThread) [custom_components.media_player.alexa] Captcha/2FA not requested; confirming login.
2018-08-11 10:43:37 DEBUG (MainThread) [custom_components.media_player.alexa] Not logged in.
2018-08-11 10:43:37 DEBUG (MainThread) [custom_components.media_player.alexa] Login failed; check credentials
2018-08-11 10:43:37 DEBUG (MainThread) [custom_components.media_player.alexa] Captcha/2FA failed; requesting new captcha
2018-08-11 10:43:38 DEBUG (MainThread) [custom_components.media_player.alexa] No cookies for log in; using credentials
2018-08-11 10:43:38 DEBUG (MainThread) [custom_components.media_player.alexa] Captcha: None SecurityCode: None
2018-08-11 10:43:38 DEBUG (MainThread) [custom_components.media_player.alexa] Submit Form Data: {'appActionToken': 'MCvVE3yvZ6P2E2mWRpfyRLjQRtAj3D', 'appAction': 'SIGNIN_PWD_COLLECT', 'openid.pape.max_auth_age': 'ape:MA==', 'openid.return_to': 'ape:aHR0cHM6Ly93d3cuYW1hem9uLmNvbS9ncC9jc3MvaG9tZXBhZ2UuaHRtbC8xNDItNzc1ODQ5MC01NzA4MzI5P2llPVVURjgmJTJBVmVyc2lvbiUyQT0xJiUyQWVudHJpZXMlMkE9MA==', 'prevRID': 'ape:RTlTU1Y1R1pKSkszQzA4SjBKTkY=', 'openid.identity': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=', 'openid.assoc_handle': 'ape:dXNmbGV4', 'openid.mode': 'ape:Y2hlY2tpZF9zZXR1cA==', 'openid.ns.pape': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvZXh0ZW5zaW9ucy9wYXBlLzEuMA==', 'prepopulatedLoginId': '', 'failedSignInCount': 'ape:MA==', 'openid.claimed_id': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=', 'pageId': 'ape:dXNmbGV4', 'openid.ns': 'ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjA=', 'email': '[email protected]', 'password': 'scrubbed', 'create': '0'}
2018-08-11 10:43:38 DEBUG (MainThread) [custom_components.media_player.alexa] Captcha requested 

I’e quadruple checked the email & password. Everything is correct. I even changed my password at amazon just to make sure there wasn’t any issues there.

I am able to login to the site using the mediahost.html file that was created using the new password and the captcha. But for some reason I can’t do it thru HA.

Running the old versions the media player worked really well and I was never asked for a capcha lilke most on here but since the update I have had to enter a captcha but I can’t get past that stage. I get the “service configurator/configure called” message come up but the entities don’t come up and I assume the captcha was not correct so I keep trying.
I have been doing this for two days now…

Hi … you can do whatever you want to me, I left you hanging for 3 days, I deserve it … :slight_smile: … no internet, no life as we know it on those remote sites I’ve been. The answer is: Every time you upgrade your HA instance or your alexa.py file, remember to DELETE the shit out of that your_ha_folder/custom_components/media_player/__pycache__/alexa.cpython-36.pyc file. It will grow back and all your problems will be over ! … :slight_smile:

2 Likes

i finally got it working again this morning so all is good!! Ty buddy!

Everything … you’re doing everything wrong … :slight_smile: … here, take this:

- service: media_player.alexa_tts
  data_template:
    entity_id: media_player.batman
    message: “ Hello! Michael, this is your climate and weather report, The outside temperature is {{states ('sensor.dark_sky_apparent_temperature') }} degrees, the home climate system states the following values for Livingroom, {{states.climate.sufragerie.attributes.current_temperature}}, Bedroom, {{states.climate.dormitor.attributes.current_temperature}}, and Kitchen, {{states.climate.bucatarie.attributes.current_temperature}} ”

It’s working like a charm !

Of course it’s a data template clearly was not paying attention when creating my automation…

@alandtse

Yep same here, my email and password are right in the logs, but I’m still in an endless captcha loop. :frowning:

Stealing this - works great for my dark sky sensor, but how would I edit to to read the state of a light.lamp, to see if it is off or on?

I tried using

{{states.state.light.lamp}} nothing happens
or {{states.light.lamp}} (it reads out all attributes of the lamp, but not off/on state at all?

when i do something like that it will only tell me the name of sensor never tells me is value is there something i have to enable?