Echo Devices (Alexa) as Media Player - Testers Needed

Hello, I tried to follow the instructions to install on Hassbian (I think it was only originally for hass.io)

created the directories as suggested.
I did try WGET to get alexa.py but this ended up being some kind of HTML file so copied and pasted the code from the link instead.
Update the configuration.yaml as suggested.
Restarted home assistant.

First of all it complained about BeautifulSoup / bs4 so I used pip to install that - that appeared to have been successful (in fact I think I managed to installed it for Python3 and 2) - I ran a test script which seemed to indicate BS was working (which I found in another post somewhere).

Each time I restart Home Assistant, the alexa.py script complains that no module ‘bs4’

Any ideas?

M

you need to install lxml as well

@Sunonline
I did this for the Python3.5
sudo python3 -m pip install lxml bs4 --ignore-installed (that worked) but still same problem with BS4

Tried same command with python2 (python instead of python3) but this complained about libxml2 - this is installed, checked with apt-get.

sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install bs4
pip install lxml

*if still error during install lxml /
sudo apt-get install libxml2-dev libxslt1-dev
*then
pip install lxml

“don’t forget to delete pycache in custom_components/media_player/pycache_/alexa.cypthon-35 or 36” depend on your python before restart you rha

Thanks for all your hard work!!

This is working great, but for some reason I am not able to uninstall the add on. It is not running, but when I try to uninstall it asks me if I am sure I want to uninstall it, then closes the window and goes back to the main Hassio add ons page. Doesn’t seem to affect functionality, but it will not uninstall for me.

I think I’ve got everything working properly. I can finish testing when I get home.

Has anyone been able to do TTS through the Alexa devices? If so, how have yall set it up?

Many thanks, that did the trick. I was unfamiliar with the command source /srv/homeassistant/bin/activate (I did get an error about libcryptodome but the media players have authenticated and appeared) - now to see if I can turn them on and test them.

TTS working nicely - thankyou.

very annoying the new setup every time you restart HA you need to put capcha;
and the main problem is that capcha doesnt seem to work all the time and that makes you setup the configurator.alexa_media_player witch also seems to have to try many times until you get the mediaplayer
sense you always updating and restarting HA to set new things, going with all this troubles and process seems to be a big pain

anyway to fix this?

Since I moved to Homeassistant running from a Docker container, I never had a problem missing dependencies, such as this BeautifulSoup and others … it seems that the docker container is very well provisioned with everything it needs to run. As for the alexa tts, I just edited my configuration.yaml file, like this,

media_player:
  - platform: panasonic_viera
    name: Panasonic TV
    host: 192.168.1.88
    mac: 48:A9:D2:70:AC:94
  - platform: alexa
    host: 192.168.1.151
    email: !secret media_player_alexa_email
    password: !secret media_player_alexa_password
    url: amazon.com

and it all just went fine from there … no errors. Try Docker, it’s easy when a new version of Home Assistant emerges, just stop the container, pull the new one, copy configuration and start the new container … no stopping ha service, no entering virtual environment, I remember installing all those packages and maintaining them regularly … no more, just try it, try Docker … just a thought.

1 Like

Found the issue: on the french amazon the title when logged in is translated as “Votre compte”. Everything works after editing this.

The current solution only works for english/us. Is there a way to make it lang independent?

I have a very simple appdeamon python script. which allows you to type a message into the UI

You will need to create an input_text component so you can type the message

input_text:
  alexa:
    name: alexa_speech

appdaemon configuration yaml. The device parameter is the name of the echo or dot to speak

SpeakAlexa:
  module: SpeakAlexa
  class: Speakalexa
  device: "media_player.lr_dot"

appdaemon script. Alexa will speak whenever the message changes

import appdaemon.plugins.hass.hassapi as hass
class Speakalexa(hass.Hass):
    def initialize(self):
        self.alexa = self.args["device"]
        self.listen_state(self.speakalexa,"input_text.alexa")
    def speakalexa (self, entity, attribute, old, new, kwargs):
        talk = self.get_state("input_text.alexa")
        if talk != "" :
            self.log("TTS Called")
            self.call_service("media_player/alexa_tts",entity_id=self.alexa,message=talk)
3 Likes

Definitely going to work on getting it to be language independent. I think I have a solution and will push a fix in a few days!

3 Likes

I have done just that today, installed on Raspbian and after some issues getting the systemctl script to auto boot HA correctly, I can confirm the component is working!

The captcha appears on each reboot, which is already known, but other than that, it seems to work very well. Great job @keatontaylor

I am also stuck in that captcha. Tried it several times but it still shows up and nothing in media player.

Press on ‘confirm’ without entering anything, then try again. A captcha reappeared for me after doing that

1 Like

tried that i am entering captcha but its coming again and again.

with this update already works with hassbian?

How do I remove the addon? I’m always getting an error.

1 Like