Release Candidate and Support: Amazon Echo Control Binding

I have mine in a group a group and sometimes there are errors in the log and one or other member of the group fails to make the announcement. It seems to be a random event.


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.executeSequenceNodes(Connection.java:1149) ~[?:?]

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

	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.GeneratedMethodAccessor505.invoke(Unknown Source) ~[?:?]

	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.$Proxy145.handleCommand(Unknown Source) [259: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.GeneratedMethodAccessor504.invoke(Unknown Source) ~[?:?]

	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) [?:?]```

I get also the same error randomly:

23:56:35.325 [ERROR] [rnal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org                                                     .openhab.binding.amazonechocontrol.internal.handler.EchoHandler@1692fb49': POST url 'https://alexa.amazon.fr/api/behaviors/preview' failed:                                                      Bad Request
org.openhab.binding.amazonechocontrol.internal.HttpException: POST url 'https://alexa.amazon.fr/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.sendAnnouncement(Connection.java:1082) ~[?:?]
at org.openhab.binding.amazonechocontrol.internal.handler.EchoHandler.startTextToSpeech(EchoHandler.java:736) ~[?:?]
at org.openhab.binding.amazonechocontrol.internal.handler.EchoHandler.handleCommand(EchoHandler.java:586) ~[?:?]
at sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.ec                                                     lipse.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.$Proxy155.handleCommand(Unknown Source) [191:org.openhab.binding.amazonechocontrol:2.5.0.Beta_05]
at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:75) [109:org.eclips                                                     e.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.GeneratedMethodAccessor217.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.ec                                                     lipse.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(Unknown Source) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
at java.lang.Thread.run(Unknown Source) [?:?]

It seems that the player in the echo goes offline. Please try the new channels:

  1. Set “musicProviderId” the id of your radio provider. e.g. “TUNEIN” (You will find the full list of ids on the account web page.
  • Open the binding website:
  • http://<youropenhab>/amazonechocontrol
  • Navigate to your account
  • Click on the echo device
  1. Set a string with the name of your favorite station to the channel “playMusicVoiceCommand” It should be namedin the way how you can start it with your voice, eg. “Hitradio Ö3”

Hi, you have to use the beta version of this thread in the top most posting or a 2.5 beta.

Hi,

Thank you @richaardvark for all your use-full information.

Just some background information to the binding. The things (e.g. echo, echoShow, wha…) only differs in the provided channels. Currently the echoshow supports all channels. The api calls are the same for all devices.
If someone test ALL channels on an unsupported device and give me feedback which are working, I could implement a own thing type for that.

Best,
Michael

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