Echo Devices (Alexa) as Media Player - Testers Needed

Now, I reentered the configuration.yaml info.
Nest start:

Thu Sep 19 2019 21:06:37 GMT+0200 (Mitteleuropäische Sommerzeit)
Error setting up entry [email protected] - amazon.de for alexa_media
Traceback (most recent call last):
  File "/usr/local/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 981, in create_connection
    ssl_handshake_timeout=ssl_handshake_timeout)
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 1009, in _create_connection_transport
    await waiter
ConnectionResetError

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

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 476, in _request
    timeout=real_timeout
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 522, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 854, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 992, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 974, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/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.de:443 ssl:<ssl.SSLContext object at 0x727f6270> [None]
Verbindung getrennt. Verbinde erneut...

I have no other idea then to rollback to 1.4.1

ok, after rolling back everything works again.
This error comes at startup:

Error importing platform config_flow from integration alexa_media to set up alexa_media config entry: No module named 'custom_components.alexa_media.config_flow'

seems to be a rest of 2.2.0
Sorry that I cannot test more but it’s late and my family kills me, when alexa is not working tomorrow :wink:

Ok, the integration entry is still present. That’s obviously the reason for the error above.
Maybe I have to delete the integration, but I have respect for the resulting issues. Will try it tomorrow.

Just to close:
Deleted integration entry - started again - entered captcha - everythings fine so far.

Thanks. Let’s move the debugging to the issue thread.

@alandtse I think that options include_devices, exclude_devices, debug and scan_interval should be configurable by config entry options. With that user could change these options without removing and re-adding integration.

Using the config flow, I’m not able to actually populate exclude_devices. No matter how I enter them in the config GUI, exclude_devices ends up empty. If I switch to the config via yaml, it works as expected.

updated to 2.2.0 and hassio , all seems well notifications are working. just not the mediaplayer side of things, it used to show what i was playing etc this no longer happens.
ill try a roll back first

ignore me lol took a few reboots and now working as before. thanks for the hard work :slight_smile:

As mentioned above, I’m thinking the filters may get deprecated because HA is allowing you to disable devices in the entity_registry and that’s the preferred mechanism. We’ll probably leave them in, but won’t do anymore work on them. Debug is something that may make sense to include in the options but it’s also something I needed to setup in the initial config in case there’s login issues which history shows is still a problem. :sweat_smile: Scan_interval definitely can move but in reality it’s not really used assuming we get the websocket connection up.

BTW, thanks for the Polish translation. I’ve merged it in for the next release.

Oops, that’s a bug. Staged for next release. But note my comment above.

You probably also ran into a bug that we have a fix for.


BTW, want to thank everyone for hanging in there as we moved to 2.x and made it async. I know a bunch of you outside of the US have had random connection/login issues and it’s been a bit frustrating for you to lose access on updates. But thanks for everyone who’ve helped debug as I couldn’t have done any of the recent fixes without you.

3 Likes

Hi all,

I’m trying to install Alexa devices as Media Player but I cannot finish the configuration in Home Assistant.

I’ve installed Alexa Media player 2.2.0 through HACS but Home Assistant keeps asking me to enter the captcha to config it until it aborts. Then I need to restart my home assistant and start again, but never finishes the configuration or never accepts the captcha.

I’ve tried to unitstall and installing it back again with no success. Any ideas what can I test?

Many thanks.

Regards,

Hi, if you install it the first time, then I would recommend to install version 1.4.1 first. This version works perfectly.
If you would like to help testing, then you should provide your logs.

today error in log… The following components and platforms could not be set up:

Please check your config.
2019-09-21 19:06:06 ERROR (MainThread) [homeassistant.setup] Error during setup of component alexa_media
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/setup.py”, line 168, in _async_setup_component
hass, processed_config
File “/config/custom_components/alexa_media/init.py”, line 132, in async_setup
await login.login_with_cookie()
File “/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py”, line 165, in login_with_cookie
await self.login(cookies=self._cookies)
File “/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py”, line 384, in login
site = await self._process_page(await post_resp.text(), site)
File “/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py”, line 578, in _process_page
site)
File “/usr/local/lib/python3.7/re.py”, line 183, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object

with version v1.4.1:
2019-09-21 19:14:50 ERROR (MainThread) [homeassistant.setup] Error during setup of component alexa_media
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/setup.py”, line 172, in _async_setup_component
component.setup, hass, processed_config # type: ignore
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/alexa_media/init.py”, line 100, in setup
account.get(CONF_DEBUG))
File “/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py”, line 48, in init
self.login_with_cookie()
File “/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py”, line 93, in login_with_cookie
self.login(cookies=cookies)
File “/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py”, line 200, in login
if (cookies is not None and self.test_loggedin(cookies)):
File “/usr/local/lib/python3.7/site-packages/alexapy/alexalogin.py”, line 146, in test_loggedin
self._session.cookies.get_dict()[‘csrf’]
AttributeError: ‘dict’ object has no attribute ‘get_dict’

Delete your pickle file if you go down to 1.4.1 after logging in with 2.x.

already deleted but always the same log

I have just installed version 2.2.0. No issues so far. Question: Do I still need to define alexa_media in the configuration.yaml file?

yes

alexa_media:
  accounts:
    - email: !secret amazon_user
      password: !secret amazon_password
      url: amazon.com

the authentication method has changed. my domain is amazon.it. I deleted the .pickle file and now it works regularly

Actually, 2.2.0 introduced the the ability to set it up without the configuration.yaml. You can use a configuration.yaml as @matteos1 pointed out or you can set it up using the Integration menu. I assume when you say no issues so far, you mean you set it up with the Integrations menu.

Still ironing out an issue where restarts aren’t logging in correctly, so be aware if you restart you may have to remove and readd it. It appears to be impacting international domains so you may not see the issue.

Thought a reboot fixed the media updating but it’s stopped working now. Running latest and using Amazon.co.uk as server.
I’ll keep eye out for your beta fix
Thanks

Hi All,

I’m still having issues with logging to alexa_media in Home Assistant. I’ve never had the .pickle file.

Here is attached my log

alexa_media
Version: 1.4.1
This is a custom component
If you have any issues with this you need to open an issue here:
https://github.com/keatontaylor/alexa_media_player/issues
-------------------------------------------------------------------

2019-09-22 13:58:20 INFO (SyncWorker_19) [custom_components.alexa_media] Loaded alexapy==0.7.1
2019-09-22 13:58:20 DEBUG (SyncWorker_19) [alexapy.alexalogin] Trying cookie from file /config/[email protected]
2019-09-22 13:58:20 DEBUG (SyncWorker_19) [alexapy.alexalogin] Error loading pickled cookie from /config/[email protected]: An exception of type FileNotFoundError occurred. Arguments:
(2, 'No such file or directory')
2019-09-22 13:58:20 DEBUG (SyncWorker_19) [alexapy.alexalogin] No valid cookies for log in; using credentials
2019-09-22 13:58:20 INFO (MainThread) [homeassistant.setup] Setting up hacs
2019-09-22 13:58:20 DEBUG (MainThread) [hacs] Configuration type: yaml
2019-09-22 13:58:20 INFO (MainThread) [hacs] 

The new version 2.2.1 will fix the problems with amazon.co.uk.
This will fix: media updating + keeping the integration after a restart/reboot.

Strange to not have the pickle file. (for this version, but Alandtse might remove the need for this file in upcomming versions)
But it seems you also have a old alexapy version. Any reason to stay on the old version?

Maybe remove the integration (and alexa_media files in you custom components folder) and then install latest version via HACS.
After a restart set it all up again.
It might be a hassle but seems the best way to move forward in my opinion.

Hi BVE, thank you for your help.

Pirol_62 told me to test with version 1.4.1. I’ve tried with 2.2.0 and with the manual installation without HACS and i’m getting the same problems.

Many thanks for your help.

Regards,