Official Alexa Smart Home Skill for openHAB 2

At the moment the smart home commands are only remote-control-commands.
"Switch on light x"
I would like so see another kind of voice-commands like
"Switch off light x at midnight"
or
"Close roof-window in 20 minutes"
I think, it would be ok to use the alexa internal timer functions.
Is this combination of Alexa-functions possible or are the apis separated from each other?

Any hint why the command lasts so long from saying to doing? I say “Light Living Room Off” and about 1 minute later the light is off. But not always as it doesn’t seem to understand me all the time. With the hue emulation it worked better and about immediately.

And only the Label of the item is recognized as triggerword for alexa.
Is it possible to add different variations for a single item?
(In our house one person calls it “Library”, the other “Music Room” and the third says “Piano Room” for the same light.)

Yes, I’ve done this. Create an item for each name variant.

Switch  lamp1 "Music room lamp"  [ "Lighting" ]
Switch  lamp2 "Library lamp"  [ "Lighting" ]
Switch  lamp3 "Piano room lamp"  [ "Lighting" ]

Alexa will discover the three above.

and another item for the actual lamp:

Switch lamp "lamp" { .........}

Create a rule for each of the above so that when they change state, they turn the lamp item on and another rule to turn it off. Six rules in all. Here are the first two:

rule "lamp ON"

when
	Item  lamp1 changed from OFF to ON
then 
  	 	sendCommand(lamp, ON)
		
  	 
end

and

    rule "lamp OFF"

    when
    	Item  lamp1 changed from ON to OFF
    then 
      	 	sendCommand(lamp, OFF)
    		
 end

There’s probably a better way to do it though!

1 Like

Thanks, this works!

I’m not sure I understand the way Alexa recognizes devices. I’ve created item groups in the Alexa app for different rooms and added the corresponding light switches to each group. My Alexa is set to German, so something like “Wohnzimmer Licht an” works, while “Living room lights on” doesn’t. Also, I added a group “Aquarium” which contains a switched outlet controlling the light. All my items are tagged as “Lighting”. Unfortunately, it doesn’t recognize any commands regarding the aquarium…

Do I need groups, or can it go by the item labels displayed in the Alexa app? It doesn’t seem to recognize any of the (English) labels on my items.

Does Alexa only work with one language at a time?

Does Alexa only work with one language at a time?

Yes, that would appear to be the case. You need to chose on or the other.

Alexa isn’t finding my devices, which I’m sure is something I’m doing wrong.

I’ve installed the OpenHAB Cloud Service via PaperUI, signed up for and can see my items in myOpenHAB.org and have tagged an item as such:

Switch          onkyoPower      "Power"         { channel="onkyo:onkyoUnsupported:1bb0a221-68a2-21b9-e2ab-210968b961d8:zone1#power" } ["Lighting"]

Where have I gone wrong? Do I need the Homekit binding too?

EDIT: I moved my tag to before the thing {GUID} and that seemed to work. I confirmed that I could see the tags in the myOpenHAB rest test and they were discovered.

My girlfriend gave me a funny look when I started getting giddy as it worked

Try putting the tag before the binding information, that worked for me.

1 Like

That was exactly the issue :slight_smile:

1 Like

myopenhab was having some issues this morning, I’m still looking at why. Is it working better now?

1 Like

So If I want to control my garage door I would just add?

and [ “Lighting” ]

Switch GarageDoorSwitch1         "Left Garage Door"         (Garages, gMyOpenHAB)           { myq="1" } 
Switch GarageDoorSwitch1         "Left Garage Door"    <light>      (Garages, gMyOpenHAB)           { myq="1" } [ "Lighting" ] 

Will try when back home. Thanks for information!

What is the reason/benefit of going through a cloud service? The overall value propostion looks very similar to the Hue emulation, which doesn’t need that…

At the moment no benefit. Currently less commands are supported via cloud than via hue emulation.

Just an example which is not working(Hopefully i did nothing wrong):
Number Wohnzimmer_Thermostats
"Wohnzimmer"
[ “TargetTemperature” ]
{ channel=“homematic:HM-TC-IT-WM-W-EU:1ddd6d8d:MEQ1841880:2#SET_TEMPERATURE”}

I’d like to do this too but as stated above:

I might have a play with grouping it as a thermostat later to see if I can make a workaround

Yes. It really is that simple.

I’m wondering about the benefits of the skill vs Hue Emulation. If everything currently works as desired, is there a noticable performance enhancement or features planned that won’t be available unless you switch?

@gbealmer

A massive caveat is that I’ve done this at work so have no idea what happens when I ask Alexa but…

This was my group of temperatures before:

/* Groups */
Group Temperature_Sensors

/* Temperature Sensors */
Number Fish_Tank_Temp "Fish Tank Temperature [%.1f °C]" <temperature> (Temperature_Sensors) {mqtt="<[oh2:hab/livingroom/temperature/0:state:default]"}
Number Living_Room_Temp "Living Room Temperature [%.1f °C]" <temperature> (Temperature_Sensors) [ "CurrentTemperature" ] {mqtt="<[oh2:hab/livingroom/temperature/1:state:default]"}
Number Bathroom_Temp1 "Bathroom Temperature [%.1f °C]"  <temperature> (Temperature_Sensors) {mqtt="<[oh2:hab/bathroom/temperature:state:default]"}
Number Bathroom_Humid "Bathroom Humidity [%.1f %%]" <water> (Humidity_Sensors) {mqtt="<[oh2:hab/bathroom/humidity:state:default]"}

And this is what they look like now:

/* Groups */
Group Temperature_Sensors "Temperature Sensors" ["Thermostat"]

/* Temperature Sensors */
Number Fish_Tank_Temp "Fish Tank Temperature [%.1f °C]" <temperature> (Temperature_Sensors)[ "TargetTemperature" ] {mqtt="<[oh2:hab/livingroom/temperature/0:state:default]"}
Number Living_Room_Temp "Living Room Temperature [%.1f °C]" <temperature> (Temperature_Sensors) [ "CurrentTemperature" ] {mqtt="<[oh2:hab/livingroom/temperature/1:state:default]"}
Number Bathroom_Temp1 "Bathroom Temperature [%.1f °C]"  <temperature> (Temperature_Sensors) {mqtt="<[oh2:hab/bathroom/temperature:state:default]"}
Number Bathroom_Humid "Bathroom Humidity [%.1f %%]" <water> (Humidity_Sensors) {mqtt="<[oh2:hab/bathroom/humidity:state:default]"}
String DummyCoolingMode "Dummy Cooling Mode" (Temperature_Sensors) [ "homekit:HeatingCoolingMode" ]

I don’t actually have a smart thermostat, just temperatures logged via MQTT. Therefore I created a dummy sting called “DummyCoolingMode” which is updated to be “AUTO” by a very simple rule:

rule "Set Cooling Mode"
when
        Item Living_Room_Temp received update
then
        DummyCoolingMode.postUpdate("AUTO")
end

Also, as per the HomeKit binding, you need a current and target temperature, so I’ve used the fish tank as my target but it could easily be another dummy item with a value of 1.

The final step was to search for devices through the alexa web page, which turned up my temperature group

If this works the next task is to get multiple temperatures set as “CurrentTemperature”

EDIT: Alexa isn’t having any of it. I think we’re going to have to wait for Amazon to support telling the temperature in Europe

Configuration -> Services -> Openhab Cloud -> Configure -> Items to expose to apps such as IFTTT (Select them)