Echo Devices (Alexa) as Media Player - Testers Needed

For those who are interested, I figured how to play sound effects (or any mp3) on an Echo device by using it as a Bluetooth speaker for a browser mod enabled device. I have browser mod linked to my raspberry pi and tablet that I’m using as Home Assistant dashboards, so they’re always available as media players via browser mod. I paired the tablet to the Echo dot via the Alexa app, and now any audio played on the tablet goes through the better speakers on the echo dot :slight_smile:

I tried to use this component in combination with Plex, but unfortunately Alexa won’t let you run any command in the background. So you’d have to say “Alexa tell Plex to play X” every time which won’t work for alerts. It’d be nice if Amazon allowed that to happen in the background without any prompt, but oh well.

Edit: Never mind, after about 15 minutes without media playing through Bluetooth, the Echo will say “Now streaming from device X” before playing the media. Giving up on obnoxious Alexa for now and just using the tablets to play alert sounds.

Sorry all , maybe the discussion has been made millions of time now , but unfortunately i am not able to get to a woring solution.
All post refers to different configurations , and i find quite difficult to retreive a solution.

I installed HACS
configured alexa component
Added in configuration.yaml

alexa_media:
  accounts:
    - email: [email protected]
      password: xx
      url: amazon.com
      include_devices:
        - bedroom
        - livingroom

then in mediaplayer.yaml

  - platform: alexa_media
    email: [email protected]
    password: xxx
    url: alexa.amazon.co.uk

I have now my 2 echos
image

image
image
Related services :

volume_level: 0.63
is_volume_muted: false
media_content_type: standby
media_position_updated_at: '2020-02-20T14:55:09.877705+00:00'
available: true
last_called: null
last_called_timestamp: null
friendly_name: echo_bedroom
supported_features: 56253

Added on frontpage a player custom card:

  - artwork: cover
    columns: 2
    entity: media_player.bedroom
    hide_volume: false
    icon: 'mdi:amazon-alexa'
    icon_state: true
    idle_view:
      when_idle: true
      when_paused: true
      when_standby: true
    name: Bed_room
    power_color: true
    scroll_info: true
    shortcuts:
      buttons:
        - icon: 'mdi:album'
          id: 'spotify:user:spotify:playlist:07o6biIfhRyK1zmesNXgpR'
          type: playlist
        - icon: 'mdi:cassette'
          id: 'spotify:user:spotify:playlist:1O71ZswxlTkA1vKaI6UrTk'
          type: playlist
      columns: 2
    show_source: true
    show_tts: google
    type: 'custom:mini-media-player'
show_header_toggle: false
title: Media players
type: entities

image

When i play something via voice or alexa app , it starts palyng , but the status become unavailable not showing what is happening.

If i push button to recall spotify playlists , it doesn’t play anything.

I am really lost to how to manage the integration of media player media play component.

Logs are the following

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 1204, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['Service']
2020-02-20 18:36:45 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140446029068048] extra keys not allowed @ data['Service']
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 1204, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['Service']
2020-02-20 18:36:58 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140446029068048] extra keys not allowed @ data['Service']
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 1204, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['Service']
2020-02-20 18:40:56 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140446029068048] extra keys not allowed @ data['Service']
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 1204, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['Service']

Thanks.

Nevermind , all solved , plugin deleted , folder alexa deleted , reinstalled , configured and now services as tts or play work

just installed this and it looks good. Is there a way to add a Smart Lock as a device, like alarm control panel? I have a Schlage Encode WiFi that I can control and monitor via Alexa, and am trying to get this device into HA. Can anyone point me in the right direction? Thanks!

Anyone notice tts has a significant delay as of recently? It seems to take 4-5 seconds to start speaking, (obviously not terrible) but I don’t feel like it was always that way.

Currently not possible and likely out of scope for this custom integration. Check with the official HA integration.

If you’re sending more than one request, there is some built in queueing so Amazon doesn’t throttle you. It waits 1.5 secs before sending the message and will continue to wait until that period is over without another message. However if you’re just sending a single message you likely won’t see this queuing effect and it’s probably an Amazon thing.

Out of scope maybe, but not possible? I see the lock in the Phoenix endpoint, and there is an Alexa LockContrller API. I’m very new to this but it seems doable. I’ll be going down a rabbit hole though. I was thinking of copying and modifying alarm_control_panel.py as smart_lock.py but I’m not sure how to get the lock object into the Alexa collection. Someone out there may be an to give me some suggestions?

Always possible. However, this component doesn’t use the official API. The official component is the way to go forward if you want to use that API. We may expose access to Alexa specific devices, but I don’t think it goes to exposing every device Alexa may interact with. Guard was exposed since it was Amazon specific. We have to be conscious of how often we hit the Amazon API so we don’t get banned.

For your Schlage Encode, your’e better served by directly interacting with its API since it’s probably a local API. I have no idea whether anyone has figured it out though. EDIT: Check this thread.

Thanks for elaborating. I thought the official component was only for controlling HA devices using Alexa not the other way around. Am I mistaken?

From my searching so far it seems no one has figured out the wifi Schlage locks yet.

Hello, might be a little late but I found the character limit for me to be between 850 and 900 on my french setup.
I have setup a weather alert automation, and I need to truncate it using [:850] for it to work, although the problem might lie elsewhere, like in special or unescaped characters.
Cheers
EDIT: First post, not sure how replies are displayed but this is in reply to Alexa media player tts maximum string length.

1 Like

So, I just grabbed the latest version… first attempt at making this work. I am running hassio 0.105.5 on Ubuntu in docker.

The alexa.py file is in /config/custom_components/media_player, permissions are -rwxr–r--.

configuration.yaml entry:

media_player:
  - platform: alexa
    email: !secret alexa-user
    password: !secret alexa-pass
    url: “alexa.amazon.com”

Error when reload is called…

Platform error media_player.alexa - No module named 'homeassistant.components.alexa.media_player'

I am sure that I am doing something wrong, but cannot figure it out.

Matt

I just got it to work, actually installed HACS and then installed the component thru it. Trying to figure out how to send a test message to one now.

Almost working… I do not see a service

media_player.alexa_tts

I have a bunch of alexa based services entries for my devices, but nothing TTS.

Please read the wiki. You’re talking about things from this thread that haven’t been true for over a year.

Yup, just figured that out and now have it working. So much cruft surrounding HA and Hassio. Difficult to find the latest data sometimes.

Appear to be good now.

Thanks

Hello,

I am running 2.5.5 Alexa media player custom component, HA 0.106.2 and I have been getting the below error, and a few other websocket errors, repeatedly for a few versions of both the component and HA. Any help would be appreciated.

## Log Details (ERROR)

Logger: alexapy.alexawebsocket
First occured: 8:52:51 PM (5 occurences)
Last logged: 9:30:23 PM

WebSocket Error: <class 'aiohttp.streams.EofStream'>
Log Details (WARNING)
Logger: homeassistant.components.binary_sensor
Integration: Binary sensor (documentation, issues)
First occured: 8:19:17 PM (1 occurences)
Last logged: 8:19:17 PM

Setup of binary_sensor platform mqtt is taking over 10 seconds.
2020-02-29 22:24:06 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/alexa/state_report.py", line 181, in async_send_delete_message
    alexa_entity = ENTITY_ADAPTERS[domain](hass, config, hass.states.get(entity_id))
  File "/usr/src/homeassistant/homeassistant/components/alexa/entities.py", line 205, in __init__
    self.entity_conf = config.entity_config.get(entity.entity_id, {})
AttributeError: 'NoneType' object has no attribute 'entity_id'

2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-02-29 22:28:19 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>

As you can see, this is getting quite frustrating.
Alexa is also very slow to respond to any commands, like turn on light etc.

In my Homeassistant entity list I have tons of unavailable entities, which I am unable to delete. They are for each device: shuffle/rewind switch and next alarm/timer/reminder. How can I get rid of these or make them available

You’ve posted a couple of errors that aren’t related to the component so you may have some other issues. The websocket disconnect errors indicates Amazon is disconnecting you. You can try renaming your .pickle file to see if it’s an authentication issue. However, please note that the fact the official Alexa app is having problems may mean you have another issue with Amazon. Have you tried resetting the Echo devices?

Per HA, if a switch or sensor is not controllabe or has no info it should be unavailable. Those switches/timers may not be accessible depending on what mode an Echo device is in. You can hide them on the UI or you can just stop them from loading.

Thank you, I thought it might be deeper, but I was searching on here and needed to start somewhere.

Sorry guys, really confused here. I am running 2.5.6 of this component and 106.2 of Home assistant with hassio and have all of my notify.alexa devices in the services tab.

I am trying to figure out how to take the input from a text box and announce it to my alexa devices and i am getting no where.

My input box is taking the value typed here:
image

Here is my automation that should see the chage in state for the input box and make the annoucement:

- alias: Announce Input to all alexa
  trigger:
    - platform: state
      entity_id: input_text.alexa_tts
  action:
    - service: notify.alexa_media_echo
      data:
            type: tts
            message: "testing"

Nothing is announced by the alexa. I know, I have a fixed message, but not sure how to get the input from the box to the automation yet.

The notify service does work, the screenshot below makes it talk.
image