Official Alexa Smart Home Skill for openHAB 2

I have used virtual Switches for my rules, tagged them as „Switchable“, but Alexa sees them as Lightbulbs and tries to switch them on and set brightness to 100/0 percent

Sure.
I ought to point out that using routines, Alexa doesn’t analyse the text string for values etc so it’s one string for one command. What that means is that if you want the shutters at 50%, you’ll need a routine with a string which explicitly states “Alexa, set shutter to 50%” and if you want your shutters at 30%, you’ll need a new routine created which states “Alexa, set shutter to 30%” .

My example is with a security roller shutter which I only want totally up or totally down.
My example is a bit complicated too as the shutter is Bubendorff and you cannot access the RF codes themselves so I use an Arduino to set the old remote switch levels to 0V or 3V3 and MQTT for the Arduino to talk to openHAB via wifi.
It was one of the first things I did with openHAB and I’m going to improve it - one day.

Items:

Switch virShutterTerraceDoorUP "Terrace door shutter up" [ "Switchable" ] 
Switch virShutterTerraceDoorDOWN "Terrace door shutter down" [ "Switchable" ]

Switch ShutterTerraceDoorUP    {mqtt=">[mosquitto:house/shutters/TerraceDoor/up:command:ON:UP]"} 
Switch ShutterTerraceDoorDOWN  {mqtt=">[mosquitto:house/shutters/TerraceDoor/down:command:ON:DOWN]"} 

Rule:

rule "terrace door shutter UP"

when

	Item virShutterTerraceDoorUP changed

then

	if (virShutterTerraceDoorUP.state == ON ) {
		
		sendCommand(virShutterTerraceDoorDOWN, OFF)
		sendCommand(ShutterTerraceDoorUP, ON)
		   createTimer(now.plusSeconds(2)) [|
		   	sendCommand(virShutterTerraceDoorUP, OFF)
		   	logInfo("Shutters","Terrace door shutter up through openHab")
        ]
	}

end

rule "terrace door shutter DOWN"

when

	Item virShutterTerraceDoorDOWN changed

then

	if (virShutterTerraceDoorDOWN.state == ON ) {
		sendCommand(virShutterTerraceDoorUP, OFF)
		sendCommand(ShutterTerraceDoorDOWN, ON)
			createTimer(now.plusSeconds(2)) [|
				sendCommand(virShutterTerraceDoorDOWN, OFF)
				logInfo("Shutters","Terrace door shutter down through openHab")
        ]
	}

end

Next you need to discover the Devices in the Alexa app.

After that, in the smartphone/tab app:

  • Menu
  • Routines
  • “+” When this happens…
    Add text for what you want to say:
Alexa, open the terrace shutter
  • “+” Add action…
  • Select “smart home”
  • Select "Terrace door shutter up!
  • Save

Create a second routine for Shutter Down.

Wait a couple of minutes for Alexa to sort itself out before testing.

This is perhaps a bit complicated for shutters and it’s much easier with Somfy shutters etc. but it works and the response in instantaneous so I’m happy.

I ought to add that the reason for virtual and real items is so I can use the virtual items in rules, HABpanel, Alexa routines etc and have the two shutter rules control the actual shutters without any problems.

1 Like

Mine does that too. Set them at 100% and they act as if they have two states, ON and OFF.

That‘s exactly how I did it, so I will have to dig deeper into this.

Hi Thanks for that. I got it working with one slight change. I needed to use 0 for OFF and 100 for ON for the real blind item.
Mark.

Update:
Yesterday I tried to integrate another item in Alexa Smart Home.
As before, the new item was not found and I got the same log errors again.
After more intensive testing, I find out that apparently too many items are present through the REST API. (Yes I have many items over 500), so either the Skill runs into a time out(?).
Then I removed all the item files that were not tagged (then maybe there were 100-150 items left) and behold the new item was found.

Is there any option to switch off the microphone of Alexa remotely Instead of pushing the physical button to make Alexa stop listening?

I also had an issue with Alexa discovery from one minute to the next. In my case it was my nginx proxy that needs to write temp files because of the response size. And this was not correct configurated, no access for the user.

You can simply check it with current url:

https://:/rest/items?&metadata=alexa&recursive=true

For me it runs on localhost without proxy, from externel with proxy it fails

I’m trying to use virtual items as you suggest to trigger a rule
However when activating them via the echo I get a “Server is not responding” error
This isn’t the case when I use the echo to control other openhab items (e.g. my lights)

Switch xSleep_Mode “Sleep Mode Virtual Trigger” [“Switchable”]

Defines my item - do I need to do something more to allow my echos to control this virtual trigger?

1 Like

There is some forecast when it will be supported in Spanish or how it could be helped

1 Like

Spaces are missing:
Switch xSleep_Mode “Sleep Mode Virtual Trigger” [ “Switchable” ]

Thank you - resolved and working now!

You should update the link to Homekit documentation in the first post as the current one gives a 404 error.
The correct link is: https://www.openhab.org/addons/integrations/homekit/#global-configuration

I’m trying to use the binding to get one of my Alexa Echos to play an audio book from Audible. I’m able to change the music provider ID to “AUDIBLE” or “Audible”, it seems to accept both. When I sent the command to the voice command music channel to play a book I get an exception telling me the command cannot be interpreted. Should I be using another channel?

Hey,

I use the Alexa skill v2 since some months and it’s really very, very usefull! But I’m quite keen on API v3 support, as it seems there are much more possibilities.

Is API v3 already available via the openhab cloud skill?

Is there a collection of commands and questions alexa API v3 can support/answer (in german). E.g. how can I ask, which postition my shutter has?
“Alexa, welche Stellung hat der Rollo im Wohnzimmer?”
“Alexa, wie hell ist das Wohnzimmerlicht?”
“Alexa, wie warm ist der Termostat im Wohnzimmer eingestellt?”
I’m, quite sure that alexa won’t anser my questions, but which would be the right formula? Where can I find the commands?

How can I rule my music player? Which commands do I have in german?
“Alexa, starte Player im Wohnzimmer”
“Alexa, überspringe das aktuelle Lied”
“Alexa, mach Player im Wohnzimmer lauter”
“Alexa, spule Player im Wohnzimmer vor/zurück” - how can I stop the fast for-/backward?

Are this correct item definitions:

Rollershutter RolloWohnzimmerLinks "Rollo Wohnzimmer Links [%d %%]" (gRollo) [ "Alexa.PowerController.powerState","Alexa.BrightnessController.brightness" ] { knx="1/3/0,1/3/9,1/3/18<3/3/18" }

Group gPlayerWohnzimmer "Squeezebox Wohnzimmer"	 <squeezebox>	 ["Alexa.Endpoint.Speaker"]
Dimmer sq_wohnen_volume "Wohnzimmer Lautstärke" <volume> (gPlayerWohnzimmer) ["Alexa.Speaker.volume"]    { channel="squeezebox:squeezeboxplayer:bebaee7f:wohnen:volume" }
Switch sq_wohnen_power "Wohnzimmer Lautsprecher" <exit> (gPlayerWohnzimmer)	["Alexa.PowerController.powerState"] { knx="1/5/2+<3/5/2", channel="squeezebox:squeezeboxplayer:bebaee7f:wohnen:power" }
Player sq_player_wz "Player Wohnzimmer" <playlist> (gPlayerWohnzimmer)	 ["Alexa.PlaybackController.playback"] { channel="squeezebox:squeezeboxplayer:bebaee7f:wohnen:control" }

Group   gThermostatWohnzimmer "Wohnzimmer" ["Alexa.Endpoint.Thermostat"]	  
Number  AktuellerSollwertWohnzimmer  "Wohnzimmer akt. Soll [%.1f °C]"  <temperature>  (gThermostatWohnzimmer) ["Alexa.ThermostatController.upperSetpoint"] { knx="1/4/37" }
Number  IstwertWohnzimmer  "Wohnzimmer Thermostat [%.0f °C]"  <temperature>  (gThermostatWohnzimmer) ["Alexa.TemperatureSensor.temperature"] { knx="0/3/0", expire="120m" }
1 Like

Hello, Amazon Alexa has been in beta testing in Italy in the last few months.
Will the Amazon Alexa Skill for Openhab2 be available on Amazon Italy any time soon?

Thanks

I just want to put this here because the info was very difficult for me to find and not covered clearly in the readme or anywhere else from my searches. If setting up your own to talk to a private myopenhab instance via oAuth, you need to set the Authorization URI to https://youropenhabdomain.com/oauth2/authorize and the Access Token URI to https://youropenhabdomain.com/oauth2/token . In addition, you need to set the scope to something meaningful (like “alexa”). Then on your private myopenhab instance you need to do the following, substituting the name to match the scope you put in on your skill and the clientId and clientSecret you used.

mongo
use openhab;
db.oauth2scopes.insert( { name : "alexa", description: "Access to myopenHAB specific API for Actions on Alexa", } )
db.oauth2clients.insert({ clientId: "xxxxx", clientSecret: "xxxxxxxxx" })
4 Likes

Any idea about this?

hi zolakk, is this all that is required to connect Alexa to a private openhab cloud instance?

If you follow the rest of the readme on the github page about setting it up, it should be yes. That’s all I needed anyway to fill in the gaps where the readme was vague. This is assuming you followed the guide on setting up your myopenhab instance with a letsencrypt cert and your myopenhab is reachable on port 443 by some kind of DNS name

1 Like