Release Candidate and Support: Amazon Echo Control Binding

Used this and now its crashed.

sudo rm --recursive /var/lib/openhab2/cache/*
sudo rm --recursive /var/lib/openhab2/tmp/*
2018-05-20 23:13:32.137 [WARN ] [raf.features.internal.osgi.Activator] - Error starting activator

java.io.IOException: Unexpected end of input at 1:1

	at org.apache.karaf.features.internal.util.JsonReader.error(JsonReader.java:337) [9:org.apache.karaf.features.core:4.1.3]

	at org.apache.karaf.features.internal.util.JsonReader.expected(JsonReader.java:331) [9:org.apache.karaf.features.core:4.1.3]

	at org.apache.karaf.features.internal.util.JsonReader.readValue(JsonReader.java:93) [9:org.apache.karaf.features.core:4.1.3]

	at org.apache.karaf.features.internal.util.JsonReader.parse(JsonReader.java:58) [9:org.apache.karaf.features.core:4.1.3]

	at org.apache.karaf.features.internal.util.JsonReader.read(JsonReader.java:52) [9:org.apache.karaf.features.core:4.1.3]

	at org.apache.karaf.features.internal.region.DigraphHelper.readDigraph(DigraphHelper.java:90) [9:org.apache.karaf.features.core:4.1.3]

	at org.apache.karaf.features.internal.region.DigraphHelper.loadDigraph(DigraphHelper.java:70) [9:org.apache.karaf.features.core:4.1.3]

	at org.apache.karaf.features.internal.osgi.Activator.doStart(Activator.java:131) [9:org.apache.karaf.features.core:4.1.3]

	at org.apache.karaf.util.tracker.BaseActivator.run(BaseActivator.java:242) [9:org.apache.karaf.features.core:4.1.3]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

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

With --recursive you also have deleted the directories tmp and cache 
 not good.
Use mkdir to create them and chown to your openHAB user and group.

Edit: I’m not sure if you even deleted the whole var/lib/openhab2 folders, if yes you need to reinstall openHAB (but please check first)

So much thanks. Its running again.
But the amazon account is still offline.

Has anyone found this binding to be resource intensive? I have about 9 echos with the full compliment of channels linked to items. At baseline, if I have all of the items linked, the CPU ramps up to over 200%.
I’m running the most recent binding (191 | Active | 80 | 2.3.0.201805121836 | AmazonEchoControl Binding) on 2.3.0-SNAPSHOT Build #1281. Hardware is raspi3.

My polling interval is set in the Things file: pollingIntervalInSeconds=600

It is enough the it is really causing everything to slowdown. Not enough that I would remove the binding (I’m loving it).

I can reliably toggle my amazonechocontrol items file to comment/uncomment all of the items and the CPU goes from 200-300% down to 20%. As expected there is a fair increase of the activity in the debug console.

If this is to be expected, I’ll just pair down what items I have linked in.

Hi michi,

my echo dot came online and stays online.
even though i brought echo dot in India, using amazon.in domain didn’t work for me. i used amazon.com instead. it’s working now.

Kind Regards
Cadbures

Sorry, no more ideas.

Hi Master79,

Did you try manual way as mentioned by Michi,

** HINT ** IMPORTANT: If the Account thing does not go online and reports a login error, open the url YOUR_OPENHAB/amazonechocontrol/ID_OF_ACCOUNT_THING (Replace YOUR_OPENHAB and ID_OF_ACCOUNT_THING with your configuration) in your browser (e.g. http://openhab:8080/amazonechocontrol/account1 11) and try to login.

Hi Markus,
I have Xiaomi Window Sensors on all my windows.
First, I need to collect their status in Switch Items as the sensors only expose Contact-Items that do not persist state. I group these together to iterate over the items later:

Switch     XiaomiKontaktsensorWohnzimmerTuer_OpenState          "die TerrassentĂŒr im Wohnzimmer"                       (GR_Xiaomi_Sensoren_Kontakt_OpenState)
Switch     XiaomiKontaktsensorKloFenster_OpenState          "das Fenster im GĂ€steklo"                       (GR_Xiaomi_Sensoren_Kontakt_OpenState)
Switch     XiaomiKontaktsensorBadFenster_OpenState          "das Badezimmerfenster"                       (GR_Xiaomi_Sensoren_Kontakt_OpenState)
Switch     XiaomiKontaktsensorArbeitszimmerFenster_OpenState          "das Fenster im Arbeitszimmer"            (GR_Xiaomi_Sensoren_Kontakt_OpenState)
Switch     XiaomiKontaktsensorFlurFenster_OpenState          "das kleine Fenster im Flur"            (GR_Xiaomi_Sensoren_Kontakt_OpenState)

Note the very verbose labels. They are needed for naturally sounding Alexa announcements (e.g., “the small window in the hallway”)

Then, I created a rule for Alexa that activates when I say “Alexa, aktiviere Fensterstatus” (not sure what it would be in english) that triggers by means of this “switch”:
Switch AlexaXiaomiFensterstatus “Fensterstatus” [“Switchable”]

The rule triggers when the switch receives a command, iterates over all open (“ON”) windows and builds a string for voice output. Here it is:

rule "Xiaomi Alexa Fenster Ansage"
when
    Item Fensterstatus received command
then

    val StringBuilder sb = new StringBuilder
    GR_Xiaomi_Sensoren_Kontakt_OpenState.members.filter[ i | i.state == ON].forEach[i | sb.append(", " + i.label) ]
    

    var message = "Alle Fenster und TĂŒren sind geschlossen."

    if(sb.length()>0){
        val indexOfFirstSeparator = sb.indexOf(", ")
        if(indexOfFirstSeparator != -1){
            sb.delete(indexOfFirstSeparator, indexOfFirstSeparator+2)
        }
        val indexOfLastSeparator = sb.lastIndexOf(", ")
        
        var plural = false
        if(indexOfLastSeparator != -1)
        {
            sb.replace(indexOfLastSeparator, indexOfLastSeparator+2, " und ")
            plural = true
        }
        val pluralIndicator1 = if(plural) "" else "Nur "
        val pluralIndicator2 = if(plural) " sind " else " ist "
        message=pluralIndicator1 + sb.toString() + pluralIndicator2 + "offen."
    }

    ChrisSEchoSpot_TextToSpeech.sendCommand(message)
end

There is some string magic included to find out how many windows are open (one or more than one) and make a nice sentence string for Alexa:

case no window open:
“Alle Fenster und TĂŒren sind geschlossen.”

case one window open:
“Nur das kleine Fenster im Flur ist offen.”

case two windows open:
“Das kleine Fenster im Flur und das Fenster im Bad sind offen.”

case multiple windows open:
“Das kleine Fenster im Flur, das Fenster im Arbeitszimmer und das Fenster im Bad sind offen.”

Its in German but I think the idea translates to English easily. The keywords are:
“Nur” = “Only”
“und” = “and”
“ist” = “is”
“sind” = “are”

Thus I get a nice conversation out of Alexa:

Blockquote
“Alexa, aktiviere Fensterstatus”
“Das kleine Fenster im Flur, das Fenster im Arbeitszimmer und das Fenster im Bad sind offen.”

I am really really happy about this and it was extremely easy to build.
Does anyone have suggestions for improvements? Would this be worth a tutorial or is it common sense?

Cheers
Chris

5 Likes

im in the process of moving my OH server from one to another - adding in this binding from marketplace, then do a discover and it finds my amazon account but then when adding it I get an error 500 - I doubt its the binding as my original server works fine but can anyone help in what it might be? Ive add other discovered things in other bindings fine

Juat done a full reinstall of ubuntu server, openhab snapshot and then this binding - same error - i must be doing something wrong?
There is no /var/lib/openhab2/amazonechocontrol folder

And there is no http://openhabip:8080/amazonechocontrol/account1 url

log shows many of these:

2018-05-21 13:11:22.796 [WARN ] [eclipse.jetty.servlet.ServletHandler] - 
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.IncompatibleClassChangeError: Expected static field org.openhab.binding.amazonechocontrol.internal.discovery.AmazonEchoDiscovery.scheduler


Continuing - the market binding doesnt work but the snapshot does - perhaps this is by design as I am running 2.3 OH snapshots?

See the first post and download the binding version for the snapshot build.

I had some progress today with my online/offline Echo issue but in unexpected way that may be of interest to others. My issue was that the Echo didn’t stay online. It came online every 32 seconds but only for 1 sec and then offline gain. The log filled up with these changes. However, I had another issue that I thought was unrelated but its seems it was not.

My second issue was that the Echo would not play my music and the Echo said the music was not configured correctly. I thought this was an Amazon issue arising from my particular use of Amazon. I have been in contact with Amazon today. de. com and .co.uk. After somewhat confusing conversations I now have my music playing on the Echo and also the Echo stays online in openhab :slight_smile:

More details are below on my situation plus some very useful links given to me by Amazon:

My situation. I live in Austria and I have two Amazon accounts. One .de and one .co.uk. Both share the same email and password. I bought the Echo from ‘Amazon.de’ and converted it to English on first set up. This was also a bit strange as at first I had no language options. I think I disconnected and started again and then was able to choose the langauge. I had also previously tried the migrate music feature from .co.uk to .de but it never worked.

Amazon explained that my Echo had been setup as ‘Amazon.com’ due to me using English echo skills. This was part of the issue.

The links that helped today in changing region settings:
Region settings

Go to settings, country/region. On clicking the ‘here’ link I know see ‘Amazon.com’ as available but earlier when I had the issue this it was not shown but .de was. I think was because Amazon had me as already as .com when I should have been .de. Things don’t work when you have mixed region settings!!

This second link was interesting as it created a virtual Echo device in my account. Its an Alexa skill testing tool. The Amazon guy said this helps to make available Amazon skills available from .de and get everything over to .de in my account
Alexa testing tool

After doing the microphone setup Echosim now shows as one of my devices in the first link I gave.

Third I did the migration thing again
Music library migration

Sorry for the confused reply but somehow after messing with the above I have my .de bought music now available on the Echo and as a bonus the Echo stays online in Openhab. Hope this helps someone.

Ps Amazon .de where very helpful. .com useless .co.uk tried a bit but failed.

Maybe someone else figures exactly what the issue was with Echo binding and how I accidentally fixed it.

:slight_smile:

I’m trying to join the party in installing this very cool sounding binding. I drop the jar file into openHAB2\addons and the binding shows up. I accept the new Thing but it won’t save the server address (amazon.com).

I try to load the /amazonechocontrol/AmazonAccount page like the Thing configuration says to do but that results in a 404. Then, crazy happens.

I loose almost all my things. I have to shutdown and clear the cache to get them back. If the AmazonEchoControl binding stays, then most of my other things will go. I’ve done this twice now. Everything stops working.

The first error in openhab.log says:

[ERROR] [org.eclipse.smarthome.core.thing ] - [org.eclipse.smarthome.core.thing.internal.ThingManager(83)] The addThingHandlerFactory method has thrown an exception`

java.lang.IncompatibleClassChangeError: Expected non-static field org.openhab.binding.amazonechocontrol.internal.discovery.AmazonEchoDiscovery.scheduler

Am I doing something wrong? I see many others have this working.
I’m running OH 2.2 on Windows.

Hi omatzyo,
No, the CPU usage should not increase. Because the binding is passive as long as there is not polling or change of a channel. You polling is configured for 10 minutes! So there should really no cpu increase. Maybe you have a rule which causes a lot of write operation? Because there is not check if a command will be set with same value.
Kind regards,
Michael

Yes, the marktplace does not work in a 2.3 environment. I do not know, why it is listed, because I have set the maximum version in the marktplace definition to 2.2.
In the topmost post is the link for a 2.3 build.

Have you download the correct (2.2) version of the binding?

Thanks for the reply - I am sure I had the market binding working at one stage with 2.3 on my Pi3

The file says 2.3.0 snapshot, comes from the link above labeled as the daily snapshot build. Is that the right one?
Thank you you for your time!

Nope. Take the one above which says The binding requires OpenHAB Version 2.2

https://www.michael-geramb.at/app/download/11955329899/org.openhab.binding.amazonechocontrol_2.2.1.201805122332.jar?t=1526162297

Ah I completely miss-understood. I thought I was getting a newer snapshot of the binding, not one made for the daily snapshot of OH. Thanks, fixed my issue.

1 Like