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

development
binding
alexa
Tags: #<Tag:0x00007fd30e5f2c90> #<Tag:0x00007fd30e5f2b50> #<Tag:0x00007fd30e5f2a10>

(Kim Skatun) #548

Great binding @michi !
I have 6 echo dot devices and I use them as an alarm clock, however I would like my heating to turn on 15 minutes before the alarms goes off, and also it would be nice to slowly increase light level before alarm goes off. The problem is that I can not figure out how to get the current alarm time. I can do things with IFTTT when the alarm goes off, but I would like do things before the alarms goes off! Is this possible to implement?


(Mark) #549

Hi Andrew,

I am interested in how did this. The more details the better for me as I am still learning. Thx


(Mark) #550

A question.

I am not sure if its an Echo limitation or the binding I am using. For shutter control it seems I have only two options, either 0% or 100%. Stop, open, close , up, down do not work. Where is the limitation? I am using the BTicino BUS binding by Massimo.


(Andrew Pawelski) #551

Heres my full rule for my calendar reminder:

rule "Calendar Reminder"
	when
		 Time cron "0 0/1 * * * ?"   // every 1 minute
	then
		if (Away_switch.state != ON) {
			val DateTime CheckTimeStart = new DateTime((CalendarTimeStart1.state as DateTimeType).getZonedDateTime.toInstant.toEpochMilli)
			val DateTime roundedeventstart = CheckTimeStart.minuteOfDay().roundFloorCopy
			val DateTime roundednow = now.minuteOfDay().roundFloorCopy			
			val reminderList = newArrayList("You have a calendar event, ", "You've got an event -  ", "Start thinking about the event -  ", "Next up in your Calendar is, ", "It's nearly time - ", "There is something in your Calendar, ", "Something's coming up - ")
			val rndNumber = (Math::floor((Math::random * 7) + 1).doubleValue).intValue
			val remindsound = newArrayList("ECHO:system_alerts_soothing_01", "ECHO:system_alerts_atonal_02", "ECHO:system_alerts_melodic_05", "ECHO:system_alerts_repetitive_04", "ECHO:system_alerts_melodic_03", "ECHO:system_alerts_melodic_06", "ECHO:system_alerts_repetitive_01","ECHO:system_alerts_melodic_07", "ECHO:system_alerts_soothing_05", "ECHO:system_alerts_atonal_03", "ECHO:system_alerts_rhythmic_02", "ECHO:system_alerts_musical_02", "ECHO:system_alerts_melodic_01", "ECHO:system_alerts_melodic_02", "ECHO:system_alerts_alarming_03")
			val rndremindNumber = (Math::floor((Math::random * 15) + 1).doubleValue).intValue
			val heylist = newArrayList("Y'all  ", "Everybody  ", "Friends  ", "People  ", "Peops  ", "Folks  ", "Humans  ", "Chums  ", "Pals  ", "Gang  ", "Crew  ", "Squad  ", "Pack  ", "Posse  ", "Colleagues  ", "Team  ", "Mates  ", "Companions  ", "Compatriots  ", "Associates  ", "Confidants  ", "Confederates  ", "Crowd  ", "Team Pawelski  ", "Plebs  ", "Band  ", "You Lot  ", "Mortals ", "Groovy Dogs ", "You crazy pack of drop bears ")
			val rndheyNumber = (Math::floor((Math::random * 30) + 1).doubleValue).intValue
			val remindsoundvalue = remindsound.get(rndremindNumber - 1).toString

			if (roundednow.plusMinutes(60) == roundedeventstart) {
				Alexa_Living_Room_PlayAlarmSound.sendCommand(remindsoundvalue)
				Thread::sleep(7000)
				Alexa_Living_Room_PlayAlarmSound.sendCommand('')
				Alexa_Living_Room_Speak.sendCommand('Hey ' + heylist.get(rndheyNumber - 1).toString + ', ' + reminderList.get(rndNumber - 1).toString  + CalendarName1.state +  ' starting in 60 minutes')
			}
			else if (roundednow.plusMinutes(30) == roundedeventstart) {
				Alexa_Living_Room_PlayAlarmSound.sendCommand('ECHO:system_alerts_melodic_06')
				Thread::sleep(7000)
				Alexa_Living_Room_PlayAlarmSound.sendCommand('ECHO:system_alerts_melodic_06')
				Thread::sleep(7000)
				Alexa_Living_Room_PlayAlarmSound.sendCommand('')
				Alexa_Living_Room_Speak.sendCommand('Hey ' + heylist.get(rndheyNumber - 1).toString + ', ' + reminderList.get(rndNumber - 1).toString  + CalendarName1.state +  ' starting in 30 minutes')
			}
		}
end

(Markus S.) #552

Hi to all.
Any news or ideas how i can solve the problem with undefinied state of volume.items?
Thanks and greetings,
Markus


(David B.) #553

Hi,

that binding is an awesome idea. Thanks!

But I’ve got a problem. I’m not able to connect to my Amazon Account (.de). When I open /amazonechocontrol, I get an error 500 with the following message:

org.openhab.binding.amazonechocontrol.internal.ConnectionException: No session id received
	at org.openhab.binding.amazonechocontrol.internal.Connection.getLoginPage(Connection.java:435)
	at org.openhab.binding.amazonechocontrol.internal.AccountServlet.doGet(AccountServlet.java:219)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:584)
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:284)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
	at org.eclipse.jetty.server.Server.handle(Server.java:534)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
	at java.lang.Thread.run(Thread.java:748)

Is there a known solution?

Thanks in advance

David


(SiHui) #554

Did you provide your credentials for your Amazon account?


(David B.) #555

Yes. I also double checked the credentials, they are correct.

When I start openHAB on a different Host (Windows Workstation), the binding works without any problems. The error only occurs on my openHAB server (based on Ubuntu). So I think there is no problem with my account or the credentials.

Has anybody a hint on how to troubleshoot the error? All other bindings are working fine on the ubuntu server.

Thanks and kind regards

David


(Marcus K.) #556

did you try to enter your crendentials using http://YOUR_OPENHAP/amazonechocontrol/ID_OF_THIS_THING i needed to do this on debian because otherwise it wouldn’t connect for me too


(Sebastian Zimmermann) #557

Hello,

for me the same, than DavidB.
This link http://YOUR_OPENHAP/amazonechocontrol/ID_OF_THIS_THING doesn´t work, too.
But the thing wasn´t created. First with error 500. After a second try, with 409, conflict error.

I also tried a complete reboot. I guess, there is something wrong with this binding in combination with OH 2.3 RC1.

Sebastian


(David B.) #558

Hi,

thanks for your reply. I can access this link, but I’m not able to enter any credentials. The error above (No session id received) is shown on that page.

In my openHAB log, there is an error regarding a plugin with the version 2.4.0.*:

2018-06-03 19:46:15.743 [ERROR] [rg.openhab.binding.amazonechocontrol] - FrameworkEvent ERROR - org.openhab.binding.amazonechocontrol
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.amazonechocontrol [266]
  Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="2.4.0.201806030817"; osgi.identity="org.openhab.binding.amazonechocontrol"; singleton:="true"

I’m on openhab 2.3 stable. Any ideas, why 2.4 ist mentioned?

Thanks

David


(Marcus K.) #559

just a guess, do you have the binding installed in your addon folder as well as using paperUI?

also did you already tried deleting the cache?


(Marcus K.) #560

is there a specific reason you are still running OH 2.3 RC1? if not updating to openHAB 2.3.0-1 (Release Build) might be worth a try


(David B.) #561

Yes, i put the file in the addon folder during troubleshooting. Not sure if the message started at that point.

But clearing the cache did the job! Now everything is working fine.

Thank you very much. You made my day! :slight_smile:

And thank you for the binding. I love it!

Greets

David


(Scott Rushworth) #562

I’m getting the same error. First time install of the binding on OH 2.4.0 snapshot 1293. Clearing the cache didn’t help. I had two factor authentication when I first set up the Account Thing, but I’ve deleted the Thing and removed two factor auth. Is there a cookie being used?


(Sebastian Zimmermann) #563

is there a specific reason you are still running OH 2.3 RC1? if not updating to openHAB 2.3.0-1 (Release Build) might be worth a try

There is no reason. This is the version, that was offered to me during apt-get update / upgrade.

sebzim@openHAB:~ $ apt-cache policy openhab2                                                                                                                                                                       
openhab2:                                                                                                                                                                                                          
  Installed: 2.3.0.RC1-1                                                                                                                                                                                           
  Candidate: 2.3.0.RC1-1
  Version table:                                                                                                                                                                                                   
 *** 2.3.0.RC1-1 0                                                                                                                                                                                                 
    100 /var/lib/dpkg/status                                                                                                                                                                                   
 2.3.0-1 0                                                                                                                                                                                                     
    500 https://dl.bintray.com/openhab/apt-repo2/ testing/main armhf Packages                                                                                                                                  
 2.3.0~RC2-1 0                                                                                                                                                                                                 
    500 https://dl.bintray.com/openhab/apt-repo2/ testing/main armhf Packages                                                                                                                                  
 2.3.0~RC1-1 0                                                                                                                                                                                                 
    500 https://dl.bintray.com/openhab/apt-repo2/ testing/main armhf Packages                                                                                                                                  
 2.2.0-1 0                                                                                                                                                                                                     
    500 https://dl.bintray.com/openhab/apt-repo2/ testing/main armhf Packages                                                                                                                                  
 2.1.0-2 0                                                                                                                                                                                                     
    500 https://dl.bintray.com/openhab/apt-repo2/ testing/main armhf Packages                                                                                                                                  
 2.0.0~RC1-1 0                                                                                                                                                                                                 
    500 https://dl.bintray.com/openhab/apt-repo2/ testing/main armhf Packages  

Normally, the latest version should be installed during update / upgrade process, right?


(Sebastian Zimmermann) #564

Got it running. I had “downgrade” to OH 2.3.0-1
With my RC1 version, it was not running.

Thanks for help.


(Daniel Walters) #565

I’m currently using TFA on my Amazon account and would like to use this binding. Is it technically possible to use the API using a user created application token instead of username/password?

.


(SiHui) #566

Since this morning my Amazon Account Thing is offline:

Status: OFFLINE - CONFIGURATION_ERROR Login fails. Check your credentials and try to login with your webbrowser to http(s)://youropenhab:yourport/amazonechocontrol/echo1 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.

It seems Amazon is asking for something like a captcha, but where to call that captcha page?

http(s)://<youropenhab:yourport>/amazonechocontrol/echo1 does show:

1

but a click on “Amazon Account” does not load any page … same for

/amazonechocontrol/ and /amazonechocontrol/account

openHAB snapshot 2.4 #1292


(Michael Geramb) #567

Sorry, currently not.