Echo Devices (Alexa) as Media Player - Testers Needed

Hi everyone, this is my first post but i have been following the thread for the last few days, since I started setting up Alexa on my Hass.

I’m currently using v1.2.2 of this add-on running on Home Assistant 0.89.2 and in my configuration.yaml I have:

alexa_media:
    accounts:
    - email: !secret my_email
      password: !secret amazon_pass
      url: amazon.co.uk

this what i see in the log:

2019-03-19 20:02:03 ERROR (SyncWorker_0) [custom_components.alexa_media] m***x@a****o.net: Websocket failed: 'ubid-main'
Traceback (most recent call last):
  File "/config/custom_components/alexa_media/__init__.py", line 405, in setup_alexa
    websocket = WebsocketEchoClient(login_obj, ws_handler)
  File "/config/deps/lib/python3.7/site-packages/alexapy/alexawebsocket.py", line 37, in __init__
    url += str(self._cookies['ubid-main'])
KeyError: 'ubid-main'

The component doesn’t start properly and nothing happens (no captcha).

I was able to get the captcha by using url: amazon.com and component to load correctly (and the error above didn’t appear in the log) but the player stays unavailable and does nothing.

Was anyone able to get it working for url: amazon.co.uk ? Am I doing anything wrong?

Hi

Using this in the UK so amazon.co.uk without issue
Had a bit off trouble setting up as amazon use 2FA - so after putting the the captcha response it then comes back and asks for your confirmation code that amazon send to your mobile - once done it then seems to be working

Hi
What is the scan interval for alexa_media
Doesnt seem to update when next track is playing
Can get it to update by pressing vol up/vol down

Thanks @alandtse. That was the fix. :smiley:

1.2.3 is out.

This is mainly bug fixes for websockets. We’ve implemented fixes from other Alexa libraries which should give us more regions, but please let us know if it’s still causing errors for you.

Fixes:

  • Fix bug where polling would not resume after websocket failure (resolves #128)
  • Update to alexapy 0.4.2 (resolves #127)

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 .

This is a known bug resolved in 1.2.3. However, the error actually wouldn’t impact your ability to use the component assuming your’e able to log in. If you’re in the UK region, you need to use the amazon.co.uk server; using the US region will result in the devices being unavailable. If you enable logs, it should tell you what the error is. You may have to enable 2FA in Amazon.co.uk.

By default the scan interval is 60 seconds. However, when we know a Alexa is playing music, it drops it down to 20 seconds. We added websockets in 1.2.x which should make it nearly instantaneous and the scan interval isn’t used except to discover new devices.

I think it applies to both groups and multiroom groups.

I tried it and was able to add multiple alexa devices in a multiroom group. It than shows this group as a new media player.
However, using announce in that group (a 2. gen and a 3. gen echo dot) played the message asynchronous. Same as listing both devices in that service.
I’ don’t mind that’s it is asynchrone, but wanted to note it here, that for me it didn’t make a differende, if I put them in a group or use them in a list.

I followed the installation instructions , i can see my echo mediaplayer , i ran a script where i can set the volume , even the media_player.alexa_tts worked as json , but in my yaml files the only thing working is set the volume , no notify , no tts , no routines… Help needed…

should look like this

Will try tonight…
I have run this , wich somebody here helped me with…

dash_button_test:
alias: Dash Button Test
sequence:

  • service: media_player.volume_set
    data:
    entity_id: media_player.406_living_room_echo_dot
    volume_level: 0.8
  • delay: 00:00:02
  • service: notify.alexa_media
    data:
    target:
    - media_player.406_living_room_echo_dot
    message: Hi Fifke, how is your programming going?
    data:
    type: tts

and she sets the volume but then nothing… Do is there something wrong here? I will try your link tonight…
Thx

please format your code correctly, than we can if something’s wrong

You should change the entity_id: and target: to match your own echo device

Sorry if i am posting here the wrong way… Still very new at this home assistant and this forum…

How should i format my code correctly ?

I changed the target and the entity_id: to my echo dot 's name , as like i can see in home assistant , but no succes…
she only seems to react to set the volume , nothing else she does , the code from the link doesnt work neither , i see the script , i start it , but nothing happends

{
“entity_id”: “media_player.ginosechodot”,
“message”: “Test message”
}
if i start this json with the media_player.alexa_tts she speaks… so i guess she is connected the wright way or not ?

Thu Mar 21 2019 18:27:21 GMT+0100 (Midden-Europese standaardtijd)
Error executing service <ServiceCall script.alexa_test_announce (c:fbb5d03b69af427e8d75c3c237d9bf17)>
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1147, in _safe_execute
await self._execute_service(handler, service_call)
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1160, in _execute_service
await handler.func(service_call)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/script/init.py”, line 116, in service_handler
context=service.context)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/script/init.py”, line 174, in async_turn_on
kwargs.get(ATTR_VARIABLES), context)
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/script.py”, line 131, in async_run
await self._handle_action(action, variables, context)
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/script.py”, line 210, in _handle_action
action, variables, context)
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/script.py”, line 299, in _async_call_service
context=context
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py”, line 88, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context)
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1115, in async_call
raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: (ServiceNotFound(…), ‘Service notify.alexa_media not found’)

this is the log

Nodered config if anyone is interested
echo%20show

2 Likes

The main purpose to do this alexa tts is to start my routines made in Alexa app.
But i am getting nowhere with this… Notify isnt working , start routines isnt working , need help please… I am realy a newbee at this…

Thx for this… I can believe its maybe frustrating for you guys with beginners like me… But hey , ive got to start somewhere… Any idea why i am not able to do wath i want with the alexa media player?

alexa_test_routine:
  sequence:
    - service: media_player.play_media
      data_template:
        entity_id: media_player.ginosechodot
        media_content_id: "dining light on"
        media_content_type: "routine"

This is my routine , its not working…

dash_button_test:
  alias: Dash Button Test
  sequence:
  - service: media_player.volume_set
    data:
      entity_id: media_player.ginosechodot
      volume_level: 0.8
  - delay: '00:00:02'
  - service: notify.alexa_media
    data_template:
      entity_id: media_player.ginosechodot
      message: "Hi Fifke,,, how is your programming going?"
      data_template:
        type: tts

this is a button test ive got here in the forum , it works till the volume is set , and then it stops