Official Alexa Smart Home Skill for openHAB 2

Unfortunately, there is no way to customize colors in the Alexa Skill API as of yet. The only solution here would be to use a proxy color item and mapping rules to use your predefined color values while having the reported state in line with Alexa’s color values. Also, you should use the “Lighting” metadata label, since the color controller interacts with the color levels only. You wouldn’t be able to dim or turn on/off that light the way you have set it up, unless these capabilities are controlled with different channels.

items

Color DG_Buero_TV_Light_HSB_Alexa "TV Licht HSB" (DG_Buero, DG_Buero_TV_Light) {alexa="Lighting"}
Color DG_Buero_TV_Light_HSB       "TV Licht HSB" (DG_Buero, DG_Buero_TV_Light) {channel="shelly:shellyrgbw2-color:661f4f:color#hsb"}

rules

rule "TV Licht HSB Alexa Commands"
when
  Item DG_Buero_TV_Light_HSB_Alexa received command
then
  switch receivedCommand.toString {
    case "39,100,100": DG_Buero_TV_Light_HSB.sendCommand("8,100,89") // Orange
    ...
    default: DG_Buero_TV_Light_HSB.sendCommand(receivedCommand)
  }
end

rule "TV Licht HSB Changes"
when
  Item DG_Buero_TV_Light_HSB changed
then
  switch DG_Buero_TV_Light_HSB.state.toString {
    case "8,100,89": DG_Buero_TV_Light_HSB_Alexa.postUpdate("39,100,100") // Orange
    ...
    default: DG_Buero_TV_Light_HSB_Alexa.postUpdate(DG_Buero_TV_Light_HSB.state)
  }
end
1 Like

Thanks for your help. Great idea.
I’ve implemented the items and rules like you suggested but the logs shows, that the rules are not working:

2019-11-03 17:36:57.961 [vent.ItemStateChangedEvent] - DG_Buero_TV_Light_Watt changed from 7.12 to 3.49

2019-11-03 17:37:02.692 [ome.event.ItemCommandEvent] - Item ‘DG_Buero_TV_Light_HSB_Alexa’ received command 39,100,100

2019-11-03 17:37:02.716 [vent.ItemStateChangedEvent] - DG_Buero_TV_Light_HSB_Alexa changed from 240,100,100 to 39,100,100

2019-11-03 17:37:02.720 [ome.event.ItemCommandEvent] - Item ‘DG_Buero_TV_Light_HSB’ received command 39,100,100

2019-11-03 17:37:02.751 [nt.ItemStatePredictedEvent] - DG_Buero_TV_Light_HSB predicted to become 39,100,100

I forgot to convert both switch case conditions to string type. I have updated my original post. It should work now.

Hello Jeremy,
thanks a lot, now it works.
Best regards, Michael

I am struggling with this as well:
Is is possible to define two {} within one item?
one with the {alexa=" stuff and one with e.g. z-wave like {channel="zwave?

Furthermore:
Is there a way to block and control trough amazon to OH, when I am not home?
(I switch off Alexa with a power plug, but theoretically my openhab would still be controllabe by amazon)

I see…

So, you always need an auxiliary item for each item you would like to switch?

You only need an auxiliary item if the command generated by the Alexa skill cannot be directly processed on the OH side. Most of the time, you would have both alexa and channel metadata values defined on a given item.

Dimmer BedromLight "Bedroom Light" {alexa="Lighting", channel="zwave:..."}

The only way I could think of would be to switch the openHAB Cloud service mode from remote to notification, back and forth, via the REST API using a rule that triggers a curl command. This will prevent the skill from issuing commands to your OH server, when in notification mode, but would also prevent any other remote access such as the openHAB mobile app. Just to be clear, the expose items referred below are the ones you setup for IFTTT integration. No need to add the items setup for the Alexa skill in that list.

curl -X PUT --header "Content-Type: application/json" --header "Accept: application/json" -d "{
  \"mode\": \"remote\",
  \"baseURL\": \"https://myopenhab.org/\",
  \"expose\": [
    \"<exposeItem1>\",
    \"<exposeItem2>\",
    ...
  ]
}" http://localhost:8080/rest/services/org.openhab.openhabcloud/config

Oh, great! I didn’t know that this is even possible!
Thanks a mil!

hmm… that’s not really perfect, but might be ok (I go to my server through VPN anyway)

Hi,

I am struggling to get voice commands for opening and closing my blinds to work reliably with RangeController. It has worked but not consistently. Voice commands to a numbered position work every time.

Is anyone using the range controller meta data with success?

My item definition is like these examples:


Rollershutter Test "stone" {alexa="RangeController.rangeValue" [presets="0=@Value.Open,100=@Value.Close"], channel="openwebnet:bus_automation:Screen10:55:shutter" }

I also tried with

Rollershutter Test "stone" {alexa="RangeController.rangeValue" [presets="0=@Value.Open,100=@Value.Close", supportedRange="0:100:10], channel="openwebnet:bus_automation:Screen10:55:shutter" }
Rollershutter Test "stone" {alexa="RangeController.rangeValue" [presets="0=@Value.Open,100=@Value.Close", category="EXTERIOR_BLIND], channel="openwebnet:bus_automation:Screen10:55:shutter" }

Commands such as Raise, Lower, Increase, Decrease all work but Raise and Lower actually move the blinds in the opposite direction to expected. 100 = Close. So, ‘Raising’ the number moves the blinds down.

Amazon recently introduced the ability to use open, close, raise and lower commands for the mode, range and toggle controllers via semantic extensions. This support still needs to be implemented in the skill. So, for the time being, the recommended solution is to setup Alexa routines as a workaround.

OK, Thanks for that.I had read that and other info. I am already using Routines work around. I guess I am bit ahead of the game :slight_smile:

Actually, I had working for a while but as I said not consistently. Here you see the command but it appears in the log after being processed.

image

I am not sure to follow. Do you have a routine for “office blinds open” to set to another value than 0?

I already have Alexa Routines working using a proxy switch and openHAB rules for Open, Close and Stop. This works buts is a lot of code for 18 blinds.

With the new v3 style Alexa tags I was trying?hoping to get it to work without this work around. It did work sometimes but not reliably. I thought that maybe I was doing something wrong with the v3 tags.

The example I posted is an occasion where it worked without routines and used RangeController.rangeValue with the presets option.

I see. I have been working on adding the support. You won’t have to wait for much longer :smile:

As a sneak peek, here is how a standard window blind would be configured once that support will be added. This would resolve your invert issue. Value in parenthesis will be considered as incremental adjustments.

Rollershutter WindowBlind "Window Blind" {alexa="RangeController.rangeValue" [supportedRange="0:100:10", friendlyNames="@Setting.Opening", actionMappings="Close=0,Open=100,Lower=(-10),Raise=(+10)", stateMappings="Closed=0,Open=1:100"]}
3 Likes

That sounds great.

I am trying to understand how it works and have a few questions if that’s OK…helps me later explore the possibilities for my item definitions. A dummies guide would be useful :slight_smile:

What is the difference between Alexa.Setting.Opening and Alexa.Value.Open ? I don’t see the equivalent Closing for Alexa.Setting.Opening.

https://developer.amazon.com/docs/device-apis/resources-and-assets.html#global-alexa-catalog

hello, great news!
Do you know if is available for Italian speak language?

If I understand it correctly … when predefined friendly names are used in the definition then they are automatically translated into the supported languages

https://developer.amazon.com/docs/device-apis/resources-and-assets.html#global-alexa-catalog

You can use the global Alexa catalog for pre-defined names of devices, settings, values, and units. This catalog is localized into all the languages that Alexa supports.

Supported locals for the range controller

More details here:

I’ve update my items file but now I see like that:image

and no “interactive” image like switchable or dimmer or blinds…

The difference between the two is just the friendly names they are representing. The former would be used to name a component/capability while the latter a specific mode or range preset.

So setting friendlyNames="@Setting.Opening" allows a user to control the window blind opening using this command, for example: Alexa, set the window blind opening to 50%.

Also, as a side note, for reference purpose, you should use the skill documentation opposed to the Alexa Skill API documentation. Some of the latest features in the API aren’t available in the skill as of yet. I have seen a couple users jumping to conclusion by just looking at the API documentation.

Asset Catalog
Regional Availability

1 Like

I am not sure yet if it will be available. Once the feature is implemented, we will have to run some tests to confirm.