Release Candidate and Support: Amazon Echo Control Binding

See here Using Hue ONLINE / OFFLINE Events in rules or Detecting offline Things

Currently it seems that the amazon api fails if there are too many requests at the same time. The only work around would be a delay between the calls.
The interesting thing for me is, that users reports that there are less problems if the using the openhab group. But from the binding perspective there is no difference, the binding itself have no knowledge about groups. This is done by the open hab framework. So, I also can not explain what’s the difference between using groups or setting it in a loop in your rule. But it seems, that the timing is different.

Best,
Michael

I tried putting together what I thought you meant but it did not work.
perhaps you can elaborate? I have the following rule defined.

rule "HO echo online"
	when 
		Thing "amazonechocontrol:echo:account1:HO_Echo" changed
	then
		var status = ThingAction.getThingStatusInfo("amazonechocontrol:echo:account1:HO_Echo").getStatus()
		if (status.toString() == 'OFFLINE')
		{
			HO_Echo_Online.sendCommand(OFF)			
		}
		else {
			HO_Echo_Online.sendCommand(ON)
		}
	end		

Thanks
Pauyl

Are there any news to this topic?
(because I would like to use it for my doorbell)

Hi Michael,

Thanks for your reply, i’d hoped creating a group would resolve it but still get the odd error - strange.
However i do have a kind of fix for this - I create a routine on the Alexa app and in the routine i can have her make the announcement on all devices, seems to work OK. Then when i get a trigger i use the Start A Routine in openhab to make the announcement.
Thanks
Martin

1 Like

Audio tags still not supported

Sorry, I have no idea, I recommend, that you open a new topic for this in the forum, because this is not related to the binding, this should work for every thing type.

With openhab snapshot 1568, i have to recreate thethings every time I restart openhab

Went back to m1 build

Hi Tom, have you been able to add any kind of Pause?
Sometimes I would like to use a short pause within a TTS command.

Sure, use SSML

Example that gives a pause:

echo_TTS.sendCommand('<speak>Wait for the <break/> Pause</speak>')
1 Like

Awesome - thanks a lot!

@michi Hey Thanks for the reply Michael, However i am currently using the current beta version and have tried previous versions with the same error - any suggestions?

Many Thanks
Matt

Tried it, and it gives the same degree of a pause as using a comma
Is there a way to extend the pause for longer?
Thanks
Paul

Ok so I got this working using the code below for any one elese that may find it useful.

It ended up not being what I wanted.
Although this can trac the ONLine / Offline state changes it does not provide a way to discover the current state of an Echo device which is what I am really after.

Is they any tricks for this?

RULE for Thing State

// Somewhere in your .rule file.
rule "Amazon Echo Account Online Status"
when 
	Thing "amazonechocontrol:echo:account1:BR4_Echo" changed
then
	logInfo("EchoStatus.rules","Trigger: "+triggeringItem.name.toString)
    var EchoThing = getThingStatusInfo("amazonechocontrol:account:account1").getStatus()
    logInfo("EchoStatus.rules" , 'Amazon Account Status is ' + EchoThing)
    ConnectionLostTime = now
    
    if(EchoThing.toString() != 'ONLINE') {
        logInfo("EchoStatus.rules" , 'Amazon Echo Account is now ' + EchoThing + '. Starting Offline Timer')
        if (OfflineTimer === null) {
            OfflineTimer = createTimer(now.plusSeconds(30)) [|
                OfflineTimer?.cancel()
                OfflineTimer = null
                var AccountStatus = getThingStatusInfo("amazonechocontrol:account:account1").getStatus()
                if(AccountStatus.toString() == 'OFFLINE') {
                    logInfo("EchoStatus.rules" , 'Amazon Echo Account offline too long. Sending email to ' + emailRecipients)
					//createTimer(now.plusSeconds(3600)) [|
						//if (AccountStatus.toString() == 'OFFLINE') {sendMail(emailRecipients, "Openhab Warning: Amazon Account is Offline!", "Openhab\'s Amazon Account Connection lost on " + ConnectionLostTime.toString('MM/dd/yy HH:mm a') + ".\r\n") }
					//]
				}	
            ]
        }    
    }
    else if(EchoThing.toString() == 'ONLINE') {
        logInfo("EchoStatus.rules" , 'Amazon Echo Account is now ' + EchoThing + ', Canceled Offline Timer')
        OfflineTimer?.cancel()
        OfflineTimer = null
    }
end

It’s all explained in the SSML document to which I linked in my post.

For example, from the doc, a break of three seconds:

<speak>
     Mary had a little lamb <break time="3s"/>Whose fleece was white as snow.
</speak>

Hi Mainteners,

i have still the problem with the TTS Funktion that will log this error:

2019-04-13 12:33:16.925 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.openhab.binding.amazonechocontrol.internal.handler.EchoHandler@c0cb04a’: POST url ‘https://alexa.amazon.de/api/behaviors/preview’ failed: Bad Request

org.openhab.binding.amazonechocontrol.internal.HttpException: POST url ‘https://alexa.amazon.de/api/behaviors/preview’ failed: Bad Request

at org.openhab.binding.amazonechocontrol.internal.Connection.makeRequest(Connection.java:593) ~[?:?]

at org.openhab.binding.amazonechocontrol.internal.Connection.executeSequenceNode(Connection.java:1140) ~[?:?]

at org.openhab.binding.amazonechocontrol.internal.Connection.executeSequenceCommand(Connection.java:1125) ~[?:?]

at org.openhab.binding.amazonechocontrol.internal.Connection.executeSequenceCommandWithVolume(Connection.java:1116) ~[?:?]

at org.openhab.binding.amazonechocontrol.internal.Connection.textToSpeech(Connection.java:1089) ~[?:?]

at org.openhab.binding.amazonechocontrol.internal.handler.EchoHandler.startTextToSpeech(EchoHandler.java:738) ~[?:?]

at org.openhab.binding.amazonechocontrol.internal.handler.EchoHandler.handleCommand(EchoHandler.java:586) ~[?:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]

at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [102:org.eclipse.smarthome.core:0.10.0.oh240]

at com.sun.proxy.$Proxy178.handleCommand(Unknown Source) [191:org.openhab.binding.amazonechocontrol:2.5.0.Beta_06]

at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:75) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]

at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]

at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

at java.lang.Thread.run(Thread.java:748) [?:?]

Information: openhab2.4 stable and newest binding

I have no group only one Echo that will play the massage. Need help to fixed…

Thanks Mario

Still the same problem with snapshot #1569

Maybe this is a more general problem?( have to recreate thing at every startup; readding them from the inbox)

this was not present in #1566

@Kai ?

Looks like a bug to me, see also my comment in Snapshot 2.5.0~S1569-1 broke zwave things.

Thanks @Kai