This is an old revision of the document!


Make Alexa Speak a Message Received via MQTT

These instructions assume an OpenHAB2 configuration with Mosquitto MQTT enabled and working. However, HUE emulation must not necessarily be installed and configured since these instructions use a different binding. Furthermore, there is no need to install any TTS engine (ie: from Paper UI → Add-Ons → TTS) since the Amazon Echo itself will be used as the TTS device. These instructions partially synthesize the official Amazon Echo Control Binding documentation.

The Amazon Echo Control Binding since version 2.3 supports text-to-speech and thereby outdates hardware solutions. To make the Amazon Echo speak a message received on a given MQTT following, perform the following steps:

  • Install the Amazon Echo Control Binding via the OpenHAB2 user interface (Paper UI → Add-Ons → Bindings → Amazon Echo Control Binding).
  • Log-in to your Amazon Alexa account by navigating to http://alexa.amazon.com and browse the menus to Settings → Devices (select your device) → Serial number and jot down the serial number for the next step.
  • Create a things file at /etc/openhab2/things/echo.things with the following contents:
Bridge amazonechocontrol:account:AMAZON_ACCOUNT_NAME "Amazon Account" @ "Accounts" [amazonSite="amazon.com", email="AMAZON_ACCOUNT_EMAIL", password="AMAZON_ACCOUNT_PASSWORD", pollingIntervalInSeconds=60]
{
    Thing AMAZON_ECHO_NAME                 AMAZON_ECHO_NAME          "Alexa" @ "Living Room" [serialNumber="AMAZON_ECHO_SERIAL_NUMBER"]
    Thing flashbriefingprofile flashbriefing "Flash Briefing Technical" @ "Flash Briefings" 
}

and replace the following placeholders:

  • AMAZON_ACCOUNT_NAME - a descriptive name for your Amazon account,
  • AMAZON_ACCOUNT_EMAIL - the E-Mail used to login to your Amazon account,
  • AMAZON_ACCOUNT_PASSWORD - the Amazon account password,
  • AMAZON_ECHO_NAME - a descriptive name for the Amazon echo device,
  • AMAZON_ECHO_SERIAL_NUMBER - your echo device serial number obtained from the previous step.
  • Browse to your OpenHAB2 web interface with the following path /amazonechocontrol/account (ie: http://openhab2.home:8080/amazonechocontrol/AMAZON_ACCOUNT_NAME) where AMAZON_ACCOUNT_NAME is the descriptive name of the account from the echo.things file created in the previous step.
  • Create the file /etc/openhab2/items/MQTTSay.items with the following contents:
String MQTTSay_String { mqtt="<[mosquitto:alexa/say:state:default]" }

String EchoTTS "Text to Speech" {channel="amazonechocontrol:echo: AMAZON_ACCOUNT_NAME: AMAZON_ECHO_NAME:textToSpeech"}

and replace the placeholders that must match the settings in /etc/openhab2/things/echo.things:

  • AMAZON_ACCOUNT_NAME - a descriptive name for your Amazon account,
  • AMAZON_ECHO_NAME - a descriptive name for the Amazon echo device
  • Create the file /etc/openhab2/rules/MQTTSay.rules with the following contents:
rule "Make Alexa say an MQTT message"
when
    Item MQTTSay_String received update
then
    EchoTTS.sendCommand(MQTTSay_String.state.toString())
end

Finally, restart OpenHAB2.

For testing, tail the OpenHAB2 log file (usually, placed at /var/log/openhab2/openhab2.log and then from a different machine, use mosquitto_pub to send a message to the MQTT server, ie:

mosquitto_pub -h MQTT_SERVER_HOSTNAME -t 'alexa/say' -m "Program me daddy\!" -v

where:

  • MQTT_SERVER_HOSTNAME is the hostname or IP address of the MQTT server.

fuss/openhab2.1535747858.txt.gz · Last modified: 2018/08/31 20:37 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.