Echo Devices (Alexa) as Media Player - Testers Needed

Not sure why, but my setup has suddenly stopped working with an error about ‘originalDate’. I’d not changed anything previous to this, and it had been working happily for a while. I’ve tried uninstalling and reinstall the integration (with reboots in between), but all that has done is cleared all my Alexa devices. I noticed on github someone created an issue when timers are set, but I have none set (I’ve just gone round and asked all my devices to cancel timers, to which they replied there were none).

Log Details (ERROR)
Logger: homeassistant.core
Source: custom_components/alexa_media/__init__.py:607
First occurred: 7:06:45 PM (17 occurrences)
Last logged: 8:01:13 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/alexapy/alexawebsocket.py", line 152, in process_messages
    await self.on_message(cast(bytes, msg.data))
  File "/usr/local/lib/python3.7/site-packages/alexapy/alexawebsocket.py", line 234, in on_message
    await self.msg_callback(message_obj)
  File "/config/custom_components/alexa_media/__init__.py", line 921, in ws_handler
    login_obj, no_throttle=True
  File "/config/custom_components/alexa_media/__init__.py", line 469, in update_devices
    await process_notifications(login_obj, raw_notifications)
  File "/config/custom_components/alexa_media/__init__.py", line 607, in process_notifications
    n_date = notification["originalDate"]
KeyError: 'originalDate'

Hello! Is it possible to play music on one Echo device and then add another Echo device too play the same music? I have 4 Echo and Dot devices and would like this function. Not sure if its possible?

This looks like the same as this issue which I reported.
As for clearing the timers, it seems that old completed timers hang around for a bit. I’ve found that you can remove these by:

  • Open the Alexa app and go to the Activity section
  • Find the card from when you set up the timer
  • Tap on View Timer
  • Tap Delete

Sir you are a genius, I did indeed have some old timers which seems to be stuck at 00:00:00. After managed to find them all and delete them, things are back up and running again. Maybe the author could put some error handling in for the case of a timer without an ‘OriginalDate’ component, as these are obviously to be ignored as they are corrupted old timers.

Yes, in the Alexa app, create a multi-room music group. Add the two Echos that you want to play the same music. For example, I created an Everywhere group that has 5 of my 7 Echos. I now have a media_player.everywhere. If I tell it to play Spotify, only the echos in the everywhere group play Spotify.

1 Like

No. Not implemented. Feature request was closed because you should be able to do it in the official component.

It’s staged waiting for testing. Amazon removed the key from timers apparently in the last day or so.

Having this same issue.

I’m having an issue where, despite setting some test timers on the Alexa in my kitchen, the state of sensor.kitchen_next_timer never changes. Has anyone else run across this issue?

I’m trying to trigger other things when a timer ends on media_player.kitchen.

Same issue here. Have had 100’s of timers set (kids), has been working fine, and don’t seem to have any that need deleted. This just started happening. Coincidentally the Alexa Guard entity stopped responding. Seemed to coincide with me signing up for NabuCasa cloud. Not sure if any of that is related.

I have gotten past the OriginalDate issue but I’m now running into this:

Logger: homeassistant.components.websocket_api.http.connection.140531520961744
Source: custom_components/alexa_media/__init__.py:601
Integration: websocket_api (documentation, issues)
First occurred: 8:59:07 PM (1 occurrences)
Last logged: 8:59:07 PM

'deviceSerialNumber'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1234, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1257, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/configurator/__init__.py", line 235, in async_handle_service_call
    await self.hass.async_add_job(callback, call.data.get(ATTR_FIELDS, {}))
  File "/config/custom_components/alexa_media/__init__.py", line 224, in configuration_callback
    setup_platform_callback, hass, config_entry, login, callback_data
  File "/config/custom_components/alexa_media/__init__.py", line 215, in setup_platform_callback
    await test_login_status(hass, config_entry, login, setup_platform_callback)
  File "/config/custom_components/alexa_media/__init__.py", line 349, in test_login_status
    await hass.async_add_job(setup_alexa, hass, config_entry, login)
  File "/config/custom_components/alexa_media/__init__.py", line 1006, in setup_alexa
    login_obj, no_throttle=True
  File "/config/custom_components/alexa_media/__init__.py", line 468, in update_devices
    await process_notifications(login_obj, raw_notifications)
  File "/config/custom_components/alexa_media/__init__.py", line 601, in process_notifications
    n_dev_id = notification["deviceSerialNumber"]
KeyError: 'deviceSerialNumber'

I renamed my pickle file and rebooted and when trying to configure, the little pop up window just blanked out and no new pickle file was created.

I reverted back a few versions and now I properly get the Captcha again, but I’m getting the above error.

2.5.12 fixed my issue. Still need to check on Guard.

How do I get back an entity I deleted?

Thanks!

I’m not sure that’s correct.

That functionality was only for timers as far as I can see.

And there is another comment in the closed FR about it being the opposite of the requested function (set alarm clock time for an echo device from HA).

Hello I have an issue with the component. When i install it and go to configure via configuration page, i get stuck on OTP code… i enter it and it keeps spining and never finish. If i cancel it i have the component in the integration page but no devices in it. Also if i disable the two factor authentication i recieve a pop up for otp code but i dont recieve it because the authentication is not turned on.


image

can anybody tell me what i miss?

Thanks in advance.

edit: i left it for 10 minutes it finished with the configuration but still no devices are shown in the integration

I’m having an odd issue on 0.107.7 and latest alexa media via HACS. My problem is likely not related specifically to these versions but I’m noting them for reference.

My TTS responses are firing but not audible at first. For example, I have a test TTS where I can type a word or phrase, select a dot or echo device and expect to hear this on the selected device. I’m noticing that the ring will light up when the command is received but the announcement is not audible on the first try. Subsequent attempts usually result in it working fine (able to hear).

I didn’t think this was an issue at first but realized recently that my automations that trigger announcements do not work. Has anyone else experienced this problem?

How do I need to configure tts/notify service to work with this component. Since one of the latest release it stopped working. Cant see any “alexa_media” services availably any longer.
Any tips?
Regards
Lukas

I had the same issue, restarted home assistant and it’s all sorted.

very strange behavior on my alexa media player, if i restart i have to run “ha core rebuild” in ssh for alexa to work, if dont then i cant remove alexa from integration,i cant ad it or annything, im getting this in the logg:

Logger: aiohttp.server
Source: custom_components/alexa_media/init.py:15
First occurred: 2:44:51 PM (1 occurrences)
Last logged: 2:44:51 PM

Error handling request
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py”, line 418, in start
resp = await task
File “/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py”, line 458, in _handle
resp = await handler(request)
File “/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py”, line 119, in impl
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/real_ip.py”, line 39, in real_ip_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/ban.py”, line 72, in ban_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/auth.py”, line 127, in auth_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/view.py”, line 123, in handle
result = await result
File “/usr/src/homeassistant/homeassistant/components/config/config_entries.py”, line 130, in post
return await super().post(request)
File “/usr/src/homeassistant/homeassistant/components/http/data_validator.py”, line 50, in wrapper
result = await method(view, request, *args, **kwargs)
File “/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py”, line 62, in post
handler, context={“source”: config_entries.SOURCE_USER}
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 100, in async_init
flow = await self.async_create_flow(handler, context=context, data=data)
File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 504, in async_create_flow
integration.get_platform(“config_flow”)
File “/usr/src/homeassistant/homeassistant/loader.py”, line 277, in get_platform
f"{self.pkg_path}.{platform_name}"
File “/usr/local/lib/python3.7/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 953, in _find_and_load_unlocked
File “”, line 219, in _call_with_frames_removed
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 967, in _find_and_load_unlocked
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/config/custom_components/alexa_media/init.py”, line 15, in
from alexapy import AlexapyLoginError, WebsocketEchoClient, hide_email, hide_serial
File “/usr/local/lib/python3.7/site-packages/alexapy/init.py”, line 11, in
from .alexaapi import AlexaAPI
File “/usr/local/lib/python3.7/site-packages/alexapy/alexaapi.py”, line 37, in
class AlexaAPI:
File “/usr/local/lib/python3.7/site-packages/alexapy/alexaapi.py”, line 85, in AlexaAPI
) -> ClientResponse:
File “/usr/local/lib/python3.7/site-packages/backoff/_decorator.py”, line 181, in decorate
"backoff.on_exception applied to a regular function "
TypeError: backoff.on_exception applied to a regular function inside coroutine, this will lead to event loop hiccups. Use backoff.on_exception on coroutines in asynchronous code

Yes, some people posted after I posted the link here to check the change and confirmed it wasn’t. I’ll reopen the PR request.

You’re probably running into a bug where the AlexaAPI changed and broke the component again. Hopefully it’s fixed.

See my response to @Miki_Krstevski above.

This is being caused by the fact it’s loading an old version of backoff. There’s a component in your official HA that is forcing the old version to be loaded.

1 Like

Hi, just a quick bug fix I think. I installed this component and started getting exceptions in my log file.

The first exception (multiple times) was a keyError for “originalDate” and then a keyError for “originalTime” and I fixed it like this in __init__.py line 608 as not all notification have a time and date.

            if "originalDate" in notification and "originalTime" in notification:
                n_date = notification["originalDate"]
                n_time = notification["originalTime"]
                notification["date_time"] = f"{n_date} {n_time}"
            else:
                notification["date_time"] = ""

I realise that you might wish to do it different so go for it, I just thought you’d want to know :slight_smile:

I also get this exception that I didn’t fix as it only occurs once and I wasn’t sure what to do (other than comment out some of your code)

2020-04-11 20:33:14 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up alexa_media platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/alexa_media/sensor.py", line 151, in async_setup_entry
    hass, config_entry.data, async_add_devices, discovery_info=None
  File "/config/custom_components/alexa_media/helpers.py", line 111, in wrapper
    result = await func(*args, **kwargs)
  File "/config/custom_components/alexa_media/sensor.py", line 112, in async_setup_platform
    account,
  File "/config/custom_components/alexa_media/sensor.py", line 428, in __init__
    client, n_json, "date_time", account, f"next {self._type}", "mdi:alarm"
  File "/config/custom_components/alexa_media/sensor.py", line 192, in __init__
    self._process_raw_notifications()
  File "/config/custom_components/alexa_media/sensor.py", line 200, in _process_raw_notifications
    self._all = list(map(self._update_recurring_alarm, self._all))
  File "/config/custom_components/alexa_media/sensor.py", line 257, in _update_recurring_alarm
    recurring_pattern = value[1]["recurringPattern"]
KeyError: 'recurringPattern'

Excellent component by the way :smile:

Thanks. By the way I fixed it this morning. Please make sure you have the latest version, 2.5.13.