Amazon Echo Control Binding from MainUI

Coming back to OH configuration after running a few things in production for 3 years. Big question: I’m bringing up the Amazon Echo Control BInding in a dev instance of OH5.0.3.

Got the binding loaded and authenticated with Amazon. I know it’s connected because I can switch my echo in and out of “do not disturb” mode.

Looking for a quick UI based example of how to play out a doorbell tone on the Echo from an OH Rule. Or just to get the Echo to do or say something.

Here’s one to get you started.

When my gate is opened, it sends an ‘alert’ followed by a voice message, to 3 different Alexas in the house. Note the inclusion of the openhab rules tools, which you will need.

I have a few extra bits in there to stop the notifications if the alarm is set (and therefore in theory, no one at home to hear it!!)

Hope this helps.

var {TimerMgr} = require('openhab_rules_tools');
var timers = cache.shared.get('alexa_tm', () => TimerMgr());


var tmexpire = function(iname,speakVolume,speakText) {
  return () => {
    //console.info(`Night Control: Enable Timer "${iname}" Now turning off ${pwritem}`);
    //Stop Alarm Sound
    items[iname+"_AlarmSound"].sendCommand('');
    //Announce Entry
      //Set TTS Volumes on Echo units
      items[iname+"_SpeakVolume"].sendCommand(speakVolume);
      //Send TTS message to echo units
      items[iname+"_Speak"].sendCommand(speakText);
  };
}

var gateNotifyAlexa = function(alexaItemName,alexaAlarmSound,alexaNotificationVolume,alexaAlarmDuration,alexaSpeakVolume,alexaNotificationMessage)
{
  // Set Alert Volume and Start Alarm Sound
  items[alexaItemName+"_NotificationVolume"].sendCommand(alexaNotificationVolume);
  items[alexaItemName+"_AlarmSound"].sendCommand(alexaAlarmSound);
  
  //Set a timer to stop the alarm sound, and play message
  schedtime = time.ZonedDateTime.now().plusSeconds(alexaAlarmDuration);
  timers.check(alexaItemName+"_notify",schedtime.toString(),tmexpire(alexaItemName,alexaSpeakVolume,alexaNotificationMessage),true,null,'alexa_tm_'+alexaItemName+"_notify");    
}

//Notify all Alexa Echo's in house, if the Alarm is not set, and the Disable flag is not set
if((items["ZelioAlarmArmed"].state === "OFF")&&(items["DisableNotification_Echo"].state === "OFF"))
  {
  gateNotifyAlexa("EchoDotBedroom1","ECHO:system_alerts_soothing_01",25,12,25,"Gate Opened");
  gateNotifyAlexa("EchoDotLivingRoom","ECHO:system_alerts_soothing_01",35,12,35,"Gate Opened");
  gateNotifyAlexa("EchoDotLounge","ECHO:system_alerts_soothing_01",35,12,35,"Gate Opened");
  }

Hello.

I’m using the Amazon binding for a lot of stuff.
One example is, that my Echo tells me, when it has started to rain outside.
Technical wise I have a rainsensor which has an open try contact, and closes the contact
from his relais when it get wet. This sensor is connected to a Shelly 1 which is also included in the OH 5.03 installation.
If this shelly gets a change of his channel for the “usage”, this is used for a trigger for a rule,
which sends me a voice notification, that rain has started.

Here is the rule which I use for Email, Whatsapp and Alexa in this case.

And here the Blockly script for the execution:

I hope this helps to get some scripts for the Alexa for you.

Nice is also to start a query from Alex, Like “status Weather”.
Alexa then tells me, if it rains outside or not.
This is done with two rules, which check the status from the channel and gives the right answer,
also via a rule. One rule for not raining, and one rule for raining…

I use the amazon text to speech for a few notifications. Below is how I’m creating a notification when a garage door opens that uses the string channel of an amazon echo thing as target (among others). No reason why you couldn’t do the same for a connected doorbell.

I also send a similar notification to my default audio sink (a sonos speaker) and a few kodi instances. But you get the idea. It’s pretty simple with the echo string channel.

You guys are amazing! I put together a blockly script that can start music playing, but can’t quite work out which item to send a command like

ECHO:system_alerts_melodic_02

I’m using send_command in blockly

Please read here:

Just to close the loop on how I got it to work

Install the Amazon Echo binding and authenticate the bridge. I set discovery to “
Direct, over Alexa and openHAB skill”

Go into CHANNELS on the Echo Device and click ADVANCED.

Create an item for the Alarm Sound.

The Item will helpfully show you a list of sounds it knows how to make.

Below I show an example of a Blockly script that plays out one of the sounds. You have to type in the string name of the sound you want to play. The Alarm plays continuously on my Alexa until it’s cancelled. The Blockly script shows playing the sound and then cancelling it with a null command after a few seconds.

In my setup it takes 5 or 6 seconds for the alarm to start playing which is a bit slow for a doorbell.

I’m also seeing this logfile event every time I start an alarm

“Failed to get notifications: Amazon Sign-In failed with code 400: Bad Request”

It took quite a bit of fiddling and several tries to get the Amazon Echo binding installed and authenticated but wanted to give an example where it’s working