Release Candidate and Support: Amazon Echo Control Binding

The system clock was showing the correct time. It’s a raspi 3 and I sync it to the NTP servers once in a while

Good point, it actually does not have a picture for the album art. So that must be the reason. Thanks for all the work, this is an awesome add-on!!!

It’s ok …for some reason it’s working properly now.

Hi Michael,

This issue has been happening since I implemented the beta bindings when routine was introduced; I’m not sure why though?

Whenever I start OH up OR push a new rule set; I set a bunch of states on items and one of them is the fans in the house. If Jun - Nov, turn them ON else turn them OFF through an Alexa Routine.

This routine works fine in a rule but in a startup mode; it “mostly” fails with the error below. It does sometimes work but more often not. The routine does exist within Alexa and does work in rules based on virtual switches. It’s just in the startup OR new rule pushing mode this happens.

The Amazon account is ONLINE also.

2019-01-31 06:19:40.018 [WARN ] [mazonechocontrol.internal.Connection] - Routine turn routine fans off not found
2019-01-31 07:46:35.872 [WARN ] [mazonechocontrol.internal.Connection] - Routine turn routine fans off not found
2019-01-31 08:00:35.952 [WARN ] [mazonechocontrol.internal.Connection] - Routine turn routine fans off not found
2019-01-31 09:46:28.914 [WARN ] [mazonechocontrol.internal.Connection] - Routine turn routine fans off not found
2019-01-31 10:21:29.208 [WARN ] [mazonechocontrol.internal.Connection] - Routine turn routine fans off not found

Item Event:

2019-01-31 06:07:04.342 [ome.event.ItemCommandEvent] - Item 'Echo_Living_Room_StartRoutine' received command turn routine fans off

OH Log:

2019-02-01 09:48:32.403 [INFO ] [marthome.model.script.Startup Script] - Echo: Sets All Fans to OFF since the month is NOT between June - Sept
2019-02-01 09:49:04.415 [INFO ] [marthome.model.script.Startup Script] - -----------------------------------------------------------------------------
2019-02-01 09:49:04.416 [INFO ] [marthome.model.script.Startup Script] - Startup Script Done with - Turn Fans On/Off Based Off Month
2019-02-01 09:49:04.417 [INFO ] [marthome.model.script.Startup Script] - -------------------------------------
2019-02-01 09:49:04.434 [INFO ] [marthome.model.script.Startup Script] - Michaels Amazon Account Status is ONLINE
2019-02-01 09:49:04.435 [INFO ] [marthome.model.script.Startup Script] - Tricias Amazon Account Status is ONLINE

I’d be interested if this is happening to anybody else or is just me?

Its NOT a big deal just trying to improve Michael’s binding.

I’m running OH2.3 with the latest Beta 2.5 (3) binding.

Best, Jay

No idea, it seems that the query for existing routines does not return the routine. But I have no idea why this could happen. Maybe it is an issue on amazon site, that the call only works after some time the login, but this seem very uncommon, too.

INFORMATION UPDATE

I just want to give some information to the community.

Can TTS used synchronized on multiple devices?
No.
If the API is called too often at nearly the same time, the amazon server returns an error. This is the reason why you need an delay in OH rules when you sent TTS to multiple devices.
The API used for TTS with SSML allows to define multiple output devices, but unfortunately even there is an offset between the devices. So it makes no sense to include this in the binding code.

Audio tags in SSML are not working
It seems that audio tags are not supported in the used API. Regardless if you use the soundbank url or an normal https urls to MP3.

More tags for SSML
You can take a look at this page. There are tags to select a different voice or speechcons for special sayings.
Nice sample for german users, this let speak alexa with french accent:

<speak><voice name='Celine'>Ich liebe Dich</voice>.</speak>

Support for controlling smarthome devices through this binding
It would be possible to implement this, but I do not own devices which are connect to alexa. So from my side there is no interest to implement this in my free time. But if there is an other developer who want do this, I would support this development.
With the current version of the binding, switching devices can be done with the workaround by using routines in the alexa app and trigger them by the startRoutine channel.

Best,
Michael

I thought the same thing also, so I moved this logic to the bottom of the startup rule but no luck. I also tried setting the volume levels (not really needed for routines, but a call to the Amazon binding on startup as a thought) but that didn’t work either. Very strange . . .

		// Turn Fans On/Off Based Off Month

		if (currMonth !== null)		{currMonth = now.getMonthOfYear}
		if (currMonth >= 6 && currMonth <= 9) {

    		logInfo("Startup Script", "Echo: Sets All Fans to ON since the month is between June - Sept")

			if (Alexa_Status.state == 'ONLINE') {

				// Setting volumes specially here to wake up the Echo connection
				Echo_Living_Room_textToSpeechVolume.sendCommand('40')
					Thread::sleep(2000)  // 2 second wait

    			Echo_Living_Room_StartRoutine.sendCommand('turn routine fans on')
					Thread::sleep(10000)  // 10 second wait
 		} else {

    		logInfo("Startup Script", "Echo: Sets All Fans to OFF since the month is NOT between June - Sept")

			if (Alexa_Status.state == 'ONLINE') {

				// Setting volumes specially here to wake up the Echo connection
				Echo_Living_Room_textToSpeechVolume.sendCommand('40')
					Thread::sleep(2000)  // 2 second wait

    			Echo_Living_Room_StartRoutine.sendCommand('turn routine fans off')
					Thread::sleep(10000)  // 10 second wait
			}

			logInfo("Startup Script", "-----------------------------------------------------------------------------")
		}

		logInfo("Startup Script", "Startup Script Done with - Turn Fans On/Off Based Off Month")
		logInfo("Startup Script", "-----------------------------------------------------------------------------")

Best, Jay

I’ve been getting the following error message in my logs since updating the Amazon Echo Control binding to the latest version. Is there something I don’t have setup right?

2019-02-02 10:37:19.329 [ERROR] [trol.internal.handler.AccountHandler] - refresh data fails with unexpected error {}
java.lang.NullPointerException: null
    at java.time.chrono.ChronoZonedDateTime.isBefore(ChronoZonedDateTime.java:601) ~[?:?]
    at org.openhab.binding.amazonechocontrol.internal.handler.EchoHandler.updateNotifications(EchoHandler.java:1294) ~[?:?]
    at org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler.refreshNotifications(AccountHandler.java:407) ~[?:?]
    at org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler.refreshData(AccountHandler.java:508) ~[?:?]
    at org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler.checkData(AccountHandler.java:376) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
    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) [?:?]

Thank you Mike for reporting.
This was a bug which happens depending on some data, so I have not seen it in the debugger.

It is fixed now with beta 2.5 (4).

New bugfix Beta 2.5 (4)
This beta fixes a bug from the previous beta 2.5 (3). Download this version from the top most posting.

I realy love this binding!, thanks for all the hard work Michael!

I keep discovering possibillities!, I have nine Echo devices, and since short a Echo Input, connected to my Receiver.
I have it connected as an echo device and it works when i tell it to play music, however i do not see the Image and progress info, (Song, Album, Time played etc)
I get this error in my log (Rpi, OpenHabian, 2.4.0):

2019-02-03 12:07:16.384 [WARN ] [trol.internal.handler.AccountHandler] - handling of websockets fails: {}

org.openhab.binding.amazonechocontrol.internal.HttpException: GET url 'https://alexa.amazon.com/api/equalizer/G090VP048464xxxx/A1JJ0KFC4Zxxxx failed: Internal Server Error at org.openhab.binding.amazonechocontrol.internal.Connection.makeRequest(Connection.java:586) ~[242:org.openhab.binding.amazonechocontrol:2.5.0.Beta_03]

Is this an config error by me, or is something else wrong?
Thanks
Ray

Binding confirmed working on OH 2.3.0001

Best, Jay

Which device type is the device with the serial G090VP048464xxxx? Is it the echo input?

Hi Michael,

i had some time and readded my homematic thermostats to Alexa through the homekit expose ["CurrentTemperature"].
The Alexa app is able to add these devices and i added them to groups.
Unfortunately Alexa isn´t able to get the temperature from oH.
When asking Alexa for the temperature in the kitchen, she just answers that the device is currently not responding.

Item:

Number:Temperature itmHeizung_Kueche_IST "Temperatur Kueche [%.1f °C]" <heating> (Kueche, Temperatur, gPersist, gCharts) ["CurrentTemperature"] {channel="homematic:HG-HM-CC-RT-DN:default:<SERIALNUMBER>:4#ACTUAL_TEMPERATURE"}

Do you have any idea if this is an Alexa issue?


I know that iobroker also has an Alexa integration that allows you to send TTS to multiple echos.
A friend of mine is using this to call everyone when dinner is ready.
This TTS is performed on multiple echos around the house without a problem.
Maybe you could have a look at the Alexa intregration in iobroker?

kind regards
Michael

Alexa is working for me when I ask what a room or outside temperature using the [“CurrentTemperature”] tag for my thermostats and sensors.

I have broadcast TTS working on an Echo and a Dot by putting them in a group and sending the TTS command to the group. I am about to get some more Echo’s to see if it scales up. I did notice the Dot responds a bit faster than the echo and they are not exactly in sync, but almost.

Yes, its the echo input,and its online

Hi Michael,

I am using your great plugin on a 2.4 installation and I experience a strange thing, the constant creation of HttpClient threads, to a point I have to re-start the OpenHab instance to avoid it eating all my server resources, as these threads always remain. To check this, I am just using the Karaf console and list the threads and grep HttpClient.

Do you have any idea where this could be coming from?

Rgds,

L.

Hi Michael,

great binding, thank you very much.
Just for information. I’ve updated from 2.4.0.201811161948 to 2.5.0.Beta_04
and change from Paper UI - Things to a manuel things File.
In addition to your “Steps for update from previous version” I still had to do:

  1. Uninstall old bundle in Karaf console:
openhab> bundle:list | grep -i echo
191 x Active    x  80 x 2.4.0.201811161948     x Amazon Echo Control Binding
244 x Installed x  80 x 2.5.0.Beta_04          x Amazon Echo Control Binding
openhab> bundle:uninstall 191
openhab> bundle:list | grep -i echo
244 x Active   x  80 x 2.5.0.Beta_04          x Amazon Echo Control Binding
  1. Add again the items for openhabCloud with Amazon Skill (List of items that are made accessible to IFTTT and similar services.)

Maybe it helps someone.
Regards
Steffen

Echo Input:

2019-02-04 21:59:44.011 [ome.event.ItemCommandEvent] - Item 'alexa_Buero_TTS' received command <speak><voice name="Celine">Ich liebe Dich</voice>.</speak>
2019-02-04 21:59:44.013 [nt.ItemStatePredictedEvent] - alexa_Buero_TTS predicted to become <speak><voice name="Celine">Ich liebe Dich</voice>.</speak>
==> /var/log/openhab2/openhab.log <==
2019-02-04 21:59:45.837 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception: 
org.openhab.binding.amazonechocontrol.internal.HttpException: GET url 'https://alexa.amazon.de/api/equalizer/xxxxxxxxxxxx/xxxxxxxxxxxxxx' failed: Internal Server Error

Echo Dot: everything fine

Regards
Steffen

Hi again,

To complement my question, here is what I see in the karaf console:

24623 HttpClient@32bcef65-24623 RUNNABLE 0 0
24624 HttpClient@32bcef65-24624 TIMED_WAITING 9 0
24625 HttpClient@32bcef65-24625 TIMED_WAITING 2 0
24626 HttpClient@32bcef65-24626 TIMED_WAITING 3 0
24627 HttpClient@32bcef65-24627 RUNNABLE 7 0
24628 HttpClient@32bcef65-24628 TIMED_WAITING 1 0
24629 HttpClient@32bcef65-24629 TIMED_WAITING 0 0
24630 HttpClient@32bcef65-24630 TIMED_WAITING 11 10
24632 HttpClient@32bcef65-scheduler TIMED_WAITING 0 0

So every now and then, I see a list of threads being created (more or less 9, but not always exactly) which never disappear afterwards. Going through the logs, it seems this results from some exception when trying to contact the amazon server (my Internet connection is not super stable). So I suspect it might be an exception which is not interupting the threads but for which the binding is re-creating the connection, leaving the old threads hanging around. I tried to read the code on GitHub, but I could not easily find where the threads are started and where they should be released.

Any help appreciated, as this is preventing me from keeping the binding in production (as per previous mail, this behaviour makes my openhab install eat all my memory over time).

L.