Release Candidate and Support: Amazon Echo Control Binding

Hello,

I have 5 Alexa Echo/EchoDot and 3 of them are reporting UNDEF as volume level. Volume cannot be set neither.

Any idea of what can be the cause? Any way I can log what is going on?

Thank you in advance

  1. You have a type-o. Change the alarm name to ā€˜ECHO:system_alerts_repetitive_01ā€™

  2. The [%s] seen in your alarm itemā€™s state-format field is not used; Omit the [%s] .

  • Thomas

Were the Echoā€™s playing anything at the time?
This post might help understand the situation:

@Thomas: Thanks for this hint but unfortunately it was not solving my problem. I also tried to trigger to the alarm via the PaperUI Control board but with no success. I noticed that the Remind function does not work in my case either. All other functions like TTS, Flashbriefing, Volume etc. work without problems (as long as the login remains valid).

Itā€™s the alarm & remind function working for you?
Thanks for support!

Philipp

@Philipp, I am using the bindingā€™s alarm command on four echo dots and it works with 100% success. I donā€™t use the remind function so I cannot comment on it.

The allowed alarm sound values might vary on different echo devices. I suggest you revisit the amazonechocontrol page and click on the echo device(s) you are using for alarm testing. Then confirm the Channel playAlarmSound Value you are using matches exactly as shown on the listed allowed values.

  • Thomas

Iā€™ve been narrowing down speed issues with my REST item calls taking forever (6000+ms) and it seems that for each of my four Echos, the following channels seem to add significant delays when the linked items are called. If I comment out the items attached to these channels my interface is nice and snappy but with them things take forever. Has anyone else ran into this?

AmazonPlayListId (adds about 300-400ms each)
PlayAlarmSound (adds about 400-600ms each)
PlayMusicProvider (adds about 800-1000ms each)

1 Like

@Thomas: I accidentally found the root cause :sunglasses:. Exactly 2 hours after the last post, all my Echoā€™s have played the alarm. To be honest, it was a bit spooky because it was so unexpected, especially for my wife;). However, I realized directly that my OH server has set the wrong time zone. And indeed, after both devices are running in the same time zone, there are no more problems.

Thanks for your help!
Philipp

@Philipp, Glad to hear you got it working.

  • Thomas

Our of curiosity - could I play an alert tone before a TTS event? Iā€™d like to have an ā€œattention signalā€ before an announcement is made.

Sid

You are right: once the connection to Amazon account is reset, the volume resets to UNDEF until some media is started on the Echo device.
Wouldnā€™t it be smart to have the binding to initialize the Echo device volume level?

@KidSquid

Here is what I do: I start the alarm sound a few seconds before the TTS and then I stop the alarm a few seconds after the TTS. The alarm sound will automatically mute while the TTS is spoken. The result is a pleasant ALARM-VOICE-ALARM. I use a couple timers to schedule the action sequence.

  • Thomas

Do you have any example code you wouldnā€™t mind sharing?

Thanks,

Squid

I would also like to see the code you used to create an attention tone. Thanks, Mark.

Hi did anybody managed to output amazon echo TTS to a group?

@KidSquid, @m4rk:

Hereā€™s an example of how I bookend spoken TTS with alarm tones. Comments:

  1. Two of my echo dots are used in this voice alert.
  2. The volume is set to a preferred value at the beginning and is restored to the previous level at the end.
  3. The action begins with a few seconds of a pleasant alert sound. Then the TTS voice is spoken (alert sound is automatically muted). After the TTS voice ends the alert sound is heard again for a short time.
  4. Getting the right balance of alert tone and voice is a matter of playing with the timersā€™ duration parameter.
  5. Please donā€™t tease me for the unnecessary ā€œ?.cancel()ā€ I use in my code. I do this to remind myself that every timer needs a graceful end, even if it has already ended.

This example was copied directly from my files. Although Iā€™ve stripped out some unrelated code, all my vars and echo device names are as-is, so be prepared to change them to match your project.

Somewhere in your .item file you need these declarations:

// Virtual Control
String Echo_Kitchen_PlayAlarmSound   "Play Alarm Sound"   (Alexa_Kitchen)   {channel="amazonechocontrol:echo:accountTom:echoKitchen:playAlarmSound"}
String Echo_Theater_PlayAlarmSound   "Play Alarm Sound"   (Alexa_Theater)   {channel="amazonechocontrol:echo:accountTom:echoTheater:playAlarmSound"}

// Volume Control
Dimmer Echo_Kitchen_Volume               "Volume [%.0f %%]" <soundvolume>    (Alexa_Kitchen)   {channel="amazonechocontrol:echo:accountTom:echoKitchen:volume"}
Dimmer Echo_Theater_Volume               "Volume [%.0f %%]" <soundvolume>    (Alexa_Theater)   {channel="amazonechocontrol:echo:accountTom:echoTheater:volume"}

Near the top of your .rules file youā€™ll need this:

var Timer WasherStopVolumeTimer = null
var Timer WasherStopAlarmTimer1 = null
var Timer WasherStopAlarmTimer2 = null

val EchoVolumeKitchen   = 75
val EchoVolumeTheater   = 80

Somewhere in your .rules file (within in your actionā€™s rule) youā€™ll create the voice-alarm sound:

val Echo_Kitchen_current_volume = Echo_Kitchen_Volume.state as Number
logInfo("LaundryBuddyWasher.rules" , 'Current Kitchen Echo Dot Volume = ' + Echo_Kitchen_current_volume)
Echo_Kitchen_Volume.sendCommand(EchoVolumeKitchen)
                
val Echo_Theater_current_volume = Echo_Theater_Volume.state as Number
logInfo("LaundryBuddyWasher.rules" , 'Current Theater Echo Dot Volume = ' + Echo_Theater_current_volume)
Echo_Theater_Volume.sendCommand(EchoVolumeTheater)

if (WasherStopVolumeTimer === null) {
    WasherStopVolumeTimer = createTimer(now.plusSeconds(1)) [|
        Echo_Kitchen_PlayAlarmSound.sendCommand('ECHO:system_alerts_melodic_07')
        Echo_Theater_PlayAlarmSound.sendCommand('ECHO:system_alerts_melodic_07')
        WasherStopVolumeTimer?.cancel()
        WasherStopVolumeTimer = null
    ]
}

if (WasherStopAlarmTimer1 === null) {
    WasherStopAlarmTimer1 = createTimer(now.plusSeconds(7)) [|
        Echo_Kitchen_TTS.sendCommand('Hello, the washer has stopped and your laundry is ready. I Repeat, your laundry is ready.')
        Echo_Theater_TTS.sendCommand('Hello, the washer has stopped and your laundry is ready. I Repeat, your laundry is ready.')
        WasherStopAlarmTimer1?.cancel()
        WasherStopAlarmTimer1 = null
    ]
}
if (WasherStopAlarmTimer2 === null) {
    WasherStopAlarmTimer2 = createTimer(now.plusSeconds(15)) [|
        Echo_Kitchen_PlayAlarmSound.sendCommand('')
        Echo_Theater_PlayAlarmSound.sendCommand('')
        Echo_Kitchen_Volume.sendCommand(Echo_Kitchen_current_volume)
        Echo_Theater_Volume.sendCommand(Echo_Theater_current_volume)
        WasherStopAlarmTimer2?.cancel()
        WasherStopAlarmTimer2 = null
    ]
}
2 Likes

@lukics:
Iā€™m using groups with TTS and alarm sounds without any issues. Thereā€™s nothing special required, just declare the group and its channel devices in your .items file. Same syntax as any other group.

  • Thomas

@m4rk:
Itā€™s interesting that you found TTS to be unreliable. Iā€™m experiencing intermittent/random TTS Voice, perhaps one missing TTS every thirty messages.

I donā€™t see this problem with alarm sounds or volume control. OpenHabā€™s logs show that everything is fine, which makes this a difficult issue to fix.

Iā€™m envious that you fixed your TTS issue with just the volume command. Iā€™m doing that too, plus several other things to help reduce the occurrence of missing TTS. Iā€™ve made the TTS more reliable, but not 100%.

For those that use this bindingā€™s TTS Voice a lot, Iā€™d be interested in knowing if you are also experiencing intermittent missing TTS messages.

  • Thomas

I didnā€™t get your code to work and so I fiddled around, simplified and ended up with this:
AlarmSound worked but not PlayAlarmSound

    Echo_AlarmSound.sendCommand('ECHO:system_alerts_melodic_07')
    Thread::sleep(20000)
    Echo_AlarmSound.sendCommand('')
    Echo_Volume.sendCommand(35)
    Thread::sleep(2000)
    Echo_Speak.sendCommand('Snow mode is off')

It works but its slow to ramp in volume. Is there a way to get the volume high from the start of the alarm? I tried setting volume but gets ignored, Is all the timer complication doing something I do not understand?

PS I saw very similar code to yours at top of the binding description. Also using timer.

@m4rk:

It works but its slow to ramp in volume. Is there a way to get the volume high from the start of the alarm?

  • Your current code delays the volume command for 20 secs. You need to move your Echo_Volume.sendCommand(35) to the top of the routine if you want to control volume at the beginning.

Is all the timer complication doing something I do not understand?

  • Timers avoid the code blocking caused by Thread::sleep. That is to say, a Thread::sleep stops all other rules [in the file] from running until it expires. Timers donā€™t do this. They are spawned into their own independent thread and do not suspend (block) all the other activity in the .rule file.

I know there are plenty of fans for Thread::sleep to delay openhab commands, but Iā€™m not one of them. I rarely use it. But everyone is different and Iā€™m not here to push my coding preferences.

  • Thomas
1 Like

Are the streams synced when plying TTS?
I created a group in Alexa App, this group appeared in OH Inbox and I created a Thing. Though there is no TTS channel in this Thing.