Skip to content
Alexa Unsolicted TTS for Home Assistant
Shell
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md Update README.md Jun 30, 2018
alexa_remote_control.sh Upstream CSRF additional acquisition points Jul 1, 2019
alexa_wrapper.sh Create alexa_wrapper.sh Jun 18, 2018

README.md

ha-alexa-tts

Alexa Unsolicted TTS for Home Assistant

Here is the unsolicited text to speech for Alexa devices that we have been waiting for!

The loetzimmer.de shell script has been updated (Thanks Ralf Otto) with the excellent work of Michael Geramb to support direct TTS to any Alexa devices!

This script does work by using the Alexa web interface, so it may break at anytime. However, the TTS component is POSTing a JSON object direct to the API endpoint, so the odds that TTS portion stays working are high.

The TTS works with two shells scripts, the original by Alex Loetzimmer and wrapper for it that allows Home Assistant to call it as a command line notify component.

To get started, download the scripts: https://github.com/walthowd/ha-alexa-tts

Save scripts in your Home Assistant config directory and make them executable (chmod +x alexa_remote_control.sh & chmod +x alexa_wrapper.sh)

Add your login credentials to the Home Assistant secrets.yaml file, with the keys alexa_email and alexa_password.

Run the script interactively to pull your devices:

./alexa_remote_control.sh -a

If login fails look at /tmp/.alexa.login. Search for "password" and see if you are being prompted for the captcha. If so, you can attempt to login to Alexa manually from a browser (from the same IP) and see if that fixes the issue for you. It never did for me, so I logged in to https://alexa.amazon.com with Chrome and used the cookies.txt extension(https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg?hl=en) to export my amazon cookies to /tmp/.alexa.cookie. Other individuals have reported success using the same procedure, but only when using Firefox.

Once you have ./alexa_remote_control.sh -a returning your devices you can test TTS by running:

./alexa_remote_control.sh -d "My Dot Name" -e speak:This_is_a_test!

If that works, next in a shell type:

echo $PATH

Copy that value and put it in the PATH in alexa_wrapper.sh

Add a command line notify to Home Assistant:

notify:
  - platform: command_line
    name: 'My Dot Name'
    command: "/home/homeassistant/.homeassistant/alexa_wrapper.sh -d 'My Dot Name'"

If you are using hass.io, adjust the command line to:

     command: "/config/alexa_wrapper.sh -d 'My Dot Name'"

Restart Home Assistant and you should now be able to call notify.my_dot_name with a message from an automation or the services interface broadcast messages to your devices.

You can also add a notify for all of your Alexa devices:

notify:
  - platform: command_line
    name: 'All Alexas'
    command: "/home/homeassistant/.homeassistant/alexa_wrapper.sh -d 'ALL'"

Let me know if you have any questions!

You can’t perform that action at this time.