Released: Openhab2 Amazon Echo Control Binding (controlling alexa from openhab2)

development
binding
alexa
Tags: #<Tag:0x00007fd30f0fb920> #<Tag:0x00007fd30f0fb6c8> #<Tag:0x00007fd30f0fb588>

(Markus S.) #749

Hi to all.
Is it possible to use a timer to get the end of a TTS message?
I get the info in the logs:
EchoTTS changed from to “Text”
EchoTTS changed from “Text” to
Between this two logs is the time alexa needs to say the TTS.
Then i don’t need the sleep function and it will run much nicer.
But i don’t understand the item state of changed from “Text” to ???
Is it undef oder null?
Greetings,
Markus


(Thomas) #750

@Master79: Unfortunately the EchoTTS changed from “Text” to state change occurs before the TTS voice has ended. So it’s not a good candidate to flag the end of TTS.

  • Thomas

(Ben) #751

Hi,
now I have more and more problems with the binding. Weeks ago the account was just disconnected from time to time. Reentering the Amazon side like described in the offline error fixed the problem for maybe two days. Then the account was offline again and the typical offline error was thrown all the time. I just ignored it after some time. The Echo was still ready for commands inside my network, while it was shown as offline.
But now from time to time when it goes offline, Alexa is not saying anything if I am sending commands to the Echo. After reentering the website it works again for two days until its offline again.
So right now, the binding is not a very reliable thing, because it just drives me nuts fixing the connecttion every two days.
Typical error:

2018-07-10 19:39:35.237 [INFO ] [mazonechocontrol.internal.Connection] - Login failed: Login fails. Check your credentials and try to login with your webbrowser to http(s)://<youropenhab:yourport>/amazonechocontrol/8XXXXXXXX

Wichtige Mitteilung! Zum besseren Schutz Ihres Kontos geben Sie bitte nochmals Ihr Passwort ein, und geben Sie dann die Zeichen ein, die in der Abbildung unten gezeigt werden.

(Mark) #752

I have been working on this. I created a virtual string type item called ‘Announcement’. When it receives a new message it triggers a rule that plays an attention tone using a short burst of one of the alarm melodies followed by Alexa speaking the message.

So, now I need to just one line code placed wherever I want an TTS announcement with a precdeing attention tone

eg

Announcement.postUpdate('Snow mode is set')

To create the attention tone I did it two ways. One with timers and the other using sleep function and played around with the timing to get the attention tone followed by the announcement.

Here is the more complicated rule using timers. Sleep is much simpler. I am not sure which is best to use.

var Timer PlayAlarmTimer = null
var Timer StopAlarmTimer = null
var Timer SpeakTextTimer = null

rule 'Echo announcement with attention tone'
when 
  Item Announcement changed
  then
  //start attention tone
  if (PlayAlarmTimer === null) {
    PlayAlarmTimer = createTimer(now.plusSeconds(0)) [|
    Echo_AlarmSound.sendCommand('ECHO:system_alerts_melodic_07')
    PlayAlarmTimer?.cancel()
    PlayAlarmTimer = null
    ]
  }

  //end attention tone
  if (StopAlarmTimer === null) {
    StopAlarmTimer = createTimer(now.plusMillis(8500)) [|
    Echo_AlarmSound.sendCommand('')
    StopAlarmTimer?.cancel()
    StopAlarmTimer = null
    ]
  }

  //play announcement
  if (SpeakTextTimer === null) {
    SpeakTextTimer = createTimer(now.plusMillis(9000)) [|
    Echo_Volume.sendCommand(35)
    Thread::sleep(2000)
    Echo_Speak.sendCommand(Announcement.state.toString)
    SpeakTextTimer?.cancel()
    SpeakTextTimer = null
    ]
  }
end

I need to improve the code a bit but it works.

edited to add…

I refined it a bit and edited above code. Now just the following code is placed wherever I want a TTS announcement preceded by an attention tone.

Announcement.postUpdate('<TTS text goes here>')

To enable this I changed the rule trigger to be without conditions:

when 
  Item Announcement changed

I also decided to go with the sleep function version as its a lot less code and it seems to give a more consistent attention tone timing. I will post it if someone asks for it.


(Paul Miller) #753

Its been a few weeks and I have moved away from my RPi platform onto a virtual machine for OH2 and I am finding things much snappier.

I still have a few issues with the binding that I would like to raise again.

Volume changing very frequently
I reported this a while back just as Michi informed us of a two week break as he was busy on other things. The last idea ws any rules that were causing the change in volume. I have checked multiple times and I have no rules that affect the volume. Someone also pointed out that the volume change although reported always as from BR3_Echo_Volume actually in my DEBUG logs showed it was two different echo devices reporting (BR3 and BR2 devices) and for some reason they were both logging as BR3.
I have since reset both BR2 and BR3 echo devices and registered them again and the same thing occurs. comment out either of these devices stops the constant volume change events. It would appear that BR2 also complains that they set one volume and later when they try it the volume has changed so the volume may well be changing on the device. At this stage I am considering this may be an account issue but I need an easy way to explain the issue to Amazon support and demonstrate to them the problem, anyone any ideas of a simple test that eliminates Openhab and this binding from the equation?

wha device
I canot seem to define the wha thing correctly in the .things file to have it show as defined. See the screenshot.

vox device
Does the binding support the vox device as I cannot seem to get it to show as defined? This is the new device type that the alexa app uses.

.thing file

{
    Thing echo	LR_Echo		"Alexa" @ "Living Room" 	[serialNumber="G090P308741307M7"]
    Thing echo	HO_Echo		"Alexa" @ "Office" 			[serialNumber="G090LF0964851QJA"]
    Thing echo	BR1_Echo	"Alexa" @ "Bedroom" 		[serialNumber="G090LF0971160DL3"] 
    Thing echo	BR2_Echo	"Alexa" @ "Hollys Roomn" 	[serialNumber="G090L90971620LK5"]
    Thing echo	BR3_Echo	"Alexa" @ "O Ryans Room" 	[serialNumber="G090L90963910VUM"]

	Thing vox	Paul_Echo	"Alexa" @ "IOS Device"		[serialNumber="406F6AD7BC7248BEA4D405DF284088D7"]
	
    Thing wha	ALL_Echo	"Everywhere" @ "Music Groups" [serialNumber="bff62eee1e5f4d838a11447b03cd0131"]

    Thing flashbriefingprofile flashbriefing1 "Flash Briefing Technical" @ "Flash Briefings" 
    Thing flashbriefingprofile flashbriefing2 "Flash Briefing Life Style" @ "Flash Briefings" 
}

Thanks

Paul


(Mark) #754

I have noticed the volume as shown in the logs jumping around. Eg I send command to set it to 35 and a few seconds later it jumps from 35 to 37 or sometimes even UNDEF. I only notice this when I use values like 35 and wonder if this would go away if I only used only ten’s values?? eg 10,20,30,40 and not values in between. Voice command to Alexa is in integer steps, 1 to 10 so that might make sense.


(Helmut Schütt) #755

Hi,
Thanks for the great work on this binding.
For me it’s working well with 3 Echo Dots.

But after a certain time i get the following messages in openhab.log. (every few seconds):

2018-07-12 04:57:57.837 [INFO ] [mazonechocontrol.internal.Connection] - Login failed: Login fails. Check your credentials and try to login
with your webbrowser to http(s)://youropenhab:yourport/amazonechocontrol/XXXXce
2018-07-12 04:58:00.936 [INFO ] [mazonechocontrol.internal.Connection] - Login failed: Login fails. Check your credentials and try to login
with your webbrowser to http(s)://youropenhab:yourport/amazonechocontrol/XXXXce
Wichtige Mitteilung! Zum besseren Schutz Ihres Kontos geben Sie bitte nochmals Ihr Passwort ein, und geben Sie dann die Zeichen ein, die in
der Abbildung unten gezeigt werden.

Than I have to stop and start the binding thru karaff shell. After that I have to reenter password twice and one captcha. (I’ve done this on a client PC, with the URL of openhab.log entry)
Afterwards the binding is running well a few days, until the same issue occurs.

Has anyone an idea, whats going wrong there?
Thanks a lot


(Markus S.) #756

@m4rk Have tested it. No change. Same problem.
Greetings,
Markus


(Markus S.) #757

@helmar74
Same problem here. Every 5 days i think.
Greetings,
Markus


(Helmut Schütt) #758

Yes I think also 5 days for me…


(James Hiscott) #759

Yep same problem, I wasnt sure if it was related to logging in to my amazon account from a different location (work) while the binding is trying to login from home or if it was simply time based.

Also the binding information page shows its still connected but the log fills with the “try to login” message.

I think it was spoken about above in this topic.


(Mark) #760

I also had a hunch that the problem could be connected to logging in elsewhere. I had my longest stable period when not using Amazon accounts from anywhere else. I use both .de and co.uk. Shorty after logging in at work my Echo went off line. I left it that way as its working well enough anyway.


(Cadbures) #761

Session stored in Openhab gets expired when we login from somewhere else with same amazon ID… since when the addon tries to login again and again… repeated failure will make amazon to ask for Captcha along with username and password…

Sent from my BlackBerry 10 smartphone.


(Thomas) #762

As reported by others, I’m seeing the account problem every 5 days.
Using the “Amazon Echo Account Online Status” rule posted earlier I get emailed when the problem begins. That tells me it’s time to restart Openhab, wait for it to initialize, then visit the amazon control web page and log in. Problem goes away for another 5 days, rinse & repeat.

  • Thomas

(Cadbures) #763

‎This could be the limitation from the Amazon… expiry of session after 5 days. This can get resolved if the credentials that we put into Amazon Account will get authenticated periodically without we doing it manually like restarting openhab and then visit amazon website and then login let us see if Michi can come up with some solution for it.


(Joseph Rogers) #764

I just noticed this was going on. I have a crontab job restarting OpenHAB at 2am every day, which may have masked the problem. I noticed it stopped working yesterday but didn’t figure out that the binding was logged off until just now.

So I just logged off of the alexa.amazon.com site and restarted the OpenHAB service but that didn’t seem to fix . Could there be some other problem?

OK, so I completely rebooted my Raspberry and I’m still getting:

Status: OFFLINE - COMMUNICATION_ERROR Login fails.

Somethings not right.

And now it is working again. I have no idea why.


(Rainer) #765

Hi,
I’m already using Alexa to Control my OpneHab items. Now I wanted to turn it around with this skill and control Alexa via OpenHAB.

First use case should be quite simple: read periodically configured Alarms from my Alexa bedroom device. In case an Alarm is set, switch on my Hue lamp 10 minutes before the alarm goes off. Increase lamp intensitivity over the remaining 10 minutes step-by-step. Ideally this helps to wake you up in a smoother way!

I’m wondering how to read (and even set) an Alarm on Alexa via OpenHab? Apologies if I’ve missed it somewhere.

Cheers.

Rainer


(Kris K) #766

Hi All,

I have a local instance of OpenHab Cloud, can I use this with the Amazon Echo Binding and NOT use the myopenhab.org site?


(Bert Kaufmann) #767

In the meantime I can confirm that Alexa integrated in the Sonos One Player can be controlled by this binding. I got it working now. I can start TuneIn Radio stations, set Volume and so on.

But what I can’t get working until today is text to speech with the Sonos speakers. :frowning_face:

Am I alone with this? Has anybody got this working and give me an advice what to do?


(Falk S.) #768

Hi @Kfm,

no you are not alone. See here.
There seems to be a limitation with Alexa’s sisters for this and other features. E.g. making/receiving calls also does not seem to be available for Alexa’s derivatives.