Echo Devices (Alexa) as Media Player - Testers Needed

Ah yes, it is working now. I use “include_devices” so it did not appear automatically. Thanks!

Now that it appears to be running, only one of my devices shows up. When I try to have it say something the Alexa says

“Sorry, Alexa text to speech services…… See the alexa_media wiki for information.”

My config file looks like this:

alexa_media:
 accounts:
 - email: !secret amz-email
   password: !secret amz-pwd
   url: amazon.com
   scan_interval: 30
   include_devices:
     - Office
     - Kitchen
     - bob_s_dot
     - ramona_s_dot


So I looked at the wiki and can’t understand 1) why it doesn’t work properly and 2) why it does not see my other devices.

Any ideas?
Thanks as always.

Thanks for the help, its working now. I made the mistake of just renaming the old folder when I should have deleted it.

2019-09-11 12:20:05 INFO (SyncWorker_5) [homeassistant.loader] Loaded alexa_media from custom_components.alexa_media_old
2019-09-11 12:20:05 INFO (SyncWorker_1) [homeassistant.loader] Loaded alexa_media from custom_components.alexa_media

1. 2.

@alandtse: As usual, your response is awesome and well appreciated. I am trying to rebuild a working .84.4 system that was working flawlessly with Alexa_tts and having no luck at all. Most of the Alexa integration videos and instructions out there are hopelessly out of date and lead to the mass confusion that is often reflected here with so many individual problems like mine. I apologize.

So the format of the device names is probably throwing it off. The above are the original names but only “Kitchen” matches exactly. In the old system, the “bob_s_dot” name was attached to the device automatically but now, from the json response I see it is “bob’s dot” . I don’t think I can put the apostrophe in the configuration file so I’ll try to enclose it in quotes or something. Any hints are appreciated.

[UPDATE:] Apparently bob_s_dot works fine so no problem. All my devices are working.

Only issue left is how to template the notify.alexa_media service to ensure it responds to (formerly last_alexa). My automations were written to respond to the alexa spoken to. I haven’t found any reference to how to do this. Is it still necessary and if so how to do it using a template? my current script looks like this:

- id: 'house_temperature'
  alias: What is the house temp
  trigger:
  - entity_id: script.house_temp
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
    - service: notify.alexa_media
    - data_template:
        target: '{{ states.sensor.last_alexa.state }}'
        data:
          type: tts
        message: The hallway temperature is {{states ('sensor.house_temp')}} degrees.
    - data:
        entity_id: script.house_temp
      service: script.turn_off

and I realized that the sensor.last_alexa does not exist. but the error I get is:

Invalid config for [automation]: [data_template] is an invalid option for [automation].

Thanks

I have a script which runs an Alexa routine as part of my alarm. This morning it failed, with an error in the logs which was something like “‘NoneType’ object is not iterable” due, presumably, due to the token bcoming invalidated. I restarted Home Assistant and the routines now work again.

This got me thinking, would it be possible to have a service (something like alexa_media.check_token) which does the same checks which happen on startup? That way we could create an automation to schedule the check to happen on a daily basis or, in my case where the script runs on a daily basis anyway, make the token check the first action in the script.

Excuse me if this was covered here already… hard to find things in a 3147 Post Thread^^
Is it in the meantime possible to show each device that is playing if a Group is playing?
The same way as was implemented for the Chromecast Groups?

i.e.: Group Plays Song from Spotify. Then all the Media_players in this Group also show as playing this song from Spotify.

Just upgraded to v2.1.2 (running HA 98.5). No problems!! :slight_smile: thanks!!

Exactly my problem as well. At least once a month the same issue which leads me to check the logs every morning. That can not be the idea of home automation

NVM: after another cycle of going back to 1.4.1 to login and back it is working again…

So I keep having issues with this component, previously going back to 1.4.1 was working so I would revert to that and try again on next update. Running 0.98.5, and all of a sudden last night all devices became unavailable, I removed my pickle and tried re-establishing connection. I got no pop up for the CAPTCHA at all with 1.4.1, and no errors, updated to 2.1.2 and it didn’t work. So reverted again still no captcha, went back to 2.1.2 magically worked fine…
Now tonight after a reboot I am getting error setting up platform alexa_media again, so I turned on debug and this is what I get.

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 924, in _wrap_create_connection
    await self._loop.create_connection(*args, **kwargs))
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 986, in create_connection
    ssl_handshake_timeout=ssl_handshake_timeout)
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 1014, in _create_connection_transport
    await waiter
ConnectionResetError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/setup.py", line 168, in _async_setup_component
    hass, processed_config
  File "/home/homeassistant/.homeassistant/custom_components/alexa_media/__init__.py", line 132, in async_setup
    await login.login_with_cookie()
  File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/alexalogin.py", line 165, in login_with_cookie
    await self.login(cookies=self._cookies)
  File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/alexalogin.py", line 312, in login
    if (cookies and await self.test_loggedin(cookies)):
  File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/alexalogin.py", line 233, in test_loggedin
    ssl=self._ssl
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/client.py", line 476, in _request
    timeout=real_timeout
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 522, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 854, in _create_connection
    req, traces, timeout)
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 992, in _create_direct_connection
    raise last_exc
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 974, in _create_direct_connection
    req=req, client_error=client_error)
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 931, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host alexa.amazon.com:443 ssl:<ssl.SSLContext object at 0x##########> [None]

Anyone have any ideas what could be going on?

I have just tried installing but can’t get working.
Running Home Assistant 0.92.1.

It is coming up with
Configuration invalidCHECK CONFIG
Component not found: alexa_media

I have downloaded latest ZIP file and extracted and copied the alexa_media folder into custom_components.

And I have added to my configuration.yaml

alexa_media:
accounts:
- email: “My email”
password: “my Password”
url: amazon.com

What am I missing?

With 92.x you have to install alexa 1.4.1. For the higher versions you need ha 0.98.x
afaik

We’ve never had this sensor by default. You probably previously created it in a template somewhere. Again wiki.

We have some rudimentary disconnect detection with an attempt to try to relogin in. Evidently it’s not robust enough so logs would be needed to try to have it relogin. That is probably a more robust solution than a “connected sensor/service”.

I’ve been working on a configflow variant which may make it much easier to refresh the token without a restart.

No not yet; feature request it. It’ll need to be added to the queue and will probably be a low priority UI feature to be honest.

We mimic the app where it’s treated as a separate Alexa presumably so you can resume whatever you were playing in the other ones. We could probably temporarily force anything in the Group to display the Group info while that is playing.

That’s a network error. For some reason your HA box can’t connect to Amazon. We don’t have any logic yet to deal with temporary connectivity issues. One reason is paranoia in case Amazon is deciding to block your connection so we don’t keep hammering it (potentially extending the ban).

Use proper quoting so we can tell what the issue is. Otherwise, the quick answer is you need to have proper spacing for yaml since you didn’t include any in your post but that could be because you didn’t use quoting in the forum. It may be your quotes or you may have some other error we can’t diagnose without more info like logs. Make sure you’re following the instructions.

I can’t remember what versions worked for 92.x was but @Pirol_62 could be right that you need an older version but no idea without logs.

Hi all,
Need some help from those of you who speak different languages and are comfortable editing json files. I plan for the next release to add config_flow support; however for it to display correctly if you’re not using English, I’ll need help with languages. Essentially, I need help creating translations of en.json. The languages that HA supports can be found by looking at any official component and I’ll just need a submission with the appropriate file name (es.json for Spanish, de.json for German, etc). One hint for translations is you can ignore anything inside of brackets {} or \n.

If you’re able to help, the best way is to submit a PR to my branch here with your file into the custom_components/alexa_media/.translations directory. I’m also happy to take files DMed to me too.

Thanks!

I keep having the same problem. The component won’t be loaded. I removed all files, reinstalled from hacs. I removed the pickle file. Still no luck. Sometimes when I reboot the component is loaded but not always. Really in the dark here.

The following components and platforms could not be set up:

  • alexa-media
  • alexa_media.notify

Please check your config.

Ps: not sure why it says Alexa-media when in the config alexa_media is specified.

Same for me why???

I’m tracking the issue #362 on GitHub, this seems to be the same problem I am having in my setup.

2.2.0 is out.

Two main things to this release:

  1. I should have finally squashed the login bug so you probably don’t need 1.4.1 anymore. Turns out one of our dependencies, aiohttp, had a bug that I’m also trying to fix for them.
  2. We now have config entry support. This means you can go to Configuration -> Integrations and add/remove your accounts there without restarting. This will also let you relogin if your pickle expired. We are still processing your configuration.yaml and will auto import it, but you can now delete the alexa_media entry entirely. I’ll eventually update the wiki but if someone else can help I’d appreciate it. We currently only have English and German (thanks @Dielee). If you want your language supported, help us do the translations. Please note, we may deprecate include_devices/exclude_devices in a future release since HA prefers you use the entity registry.

Pretty picture of integration support:

For those on hassio, you may have to restart 2-3 times before HA will load the dependencies. HACS will solve this problem too. You should really be on HACS. Why aren’t you on HACS?

Feature

Fix

  • increase delay for switch load (2b865f4) (closes #361)
  • bump alexapy to 1.2.0 (2eca9fe) (closes #353)
  • correctly treat add_devices with empty list as non error (168101d) (closes #357)

Full changelog.

As always, please use the the Wiki and FAQ if you need instructions or have questions. Also, please help in documenting features in the wiki since this thread is basically unsearchable now. We also use GitHub for bug reports/feature requests .

EDIT: Grammar.

1 Like

Already finished the update via hacs — works without issues!
Really great work! Thanks a lot.
image

By the way: was euphoric and deleted the config entry: works as well :wink:
After that its good to go ino entities registry and delete “This device” or these “joerg’s alexa apps”

Hi,

after a restart due to new sensors I had this:

Thu Sep 19 2019 20:47:36 GMT+0200 (Mitteleuropäische Sommerzeit)
Error setting up entry [email protected] - amazon.de for alexa_media
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 190, in async_setup
    hass, self
  File "/config/custom_components/alexa_media/__init__.py", line 172, in async_setup_entry
    await login.login_with_cookie()
  File "/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py", line 168, in login_with_cookie
    await self.login(cookies=self._cookies)
  File "/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py", line 331, in login
    if (cookies and await self.test_loggedin(cookies)):
  File "/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py", line 246, in test_loggedin
    ssl=self._ssl
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 497, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 844, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 588, in read
    await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: None
Verbindung getrennt. Verbinde erneut...

The second time now