Using Mappings in an items file with the Alexa binding

Hello everybody,

I hope somebody might be able to help me.
I have been working with Openhab 2 for half a year now and right now im trying to find an easier way to talk to Alexa about her Tasks. For example I am telling her to turn item test on.

Switch Test "Test" ["Lighting"]

And then i got this in my rules file.

rule "RolladenHoch"
when
Item Test received command ON
then
RolladeEGRechts.sendCommand ("0")
RolladeEGMitte.sendCommand ("0")
RolladeEGLinks.sendCommand ("0")    
end

rule "RolladenRunter"
when
Item Test received command OFF
then
RolladeEGRechts.sendCommand ("100")
RolladeEGMitte.sendCommand ("100")
RolladeEGLinks.sendCommand ("100")    
end

So this is working just fine, but it feels unnatural to tell Alexa to turn something on so that the shutter go up or down.
I wanna exchange the On and Off command with like close/open.
I have researched a couple of times now but it seems like the only way to use mappings is in the sitemap file.

I thought maybe i need to change the Endpoint of the Item to something where i can put my own commands, but i did it and it did not seem to work.
And again i am not talking about mappings in a sitemap!
Is there any other way for me to change the command i am telling Alexa to do just the same thing?
Maybe the answer lays just before me and i am too blind to see it.
Thanks and have a nice day!

Hi, I have to admit, I don’t have a shutter in my OH config. If I remember well, at the beginning there was only “Switchable” and “Lightning”. Nowadays, there are more possibilities to tag an item for Alexa.

But according to the documentation, there is also a better alternative. See here a nice sample and also with own commands. As said, I don’t use it by my own, but docu sounds very promising for your case:

Cheers
thefechner

To add to what @thefechner pointed out, you should get familiar with the semantic extension concept. Also you should create a group as a single endpoint to control all your shutters at the same time.

Items

Group:Rollershutter gRolladeEG "Rollade EG" {alexa="RangeController.rangeValue" [category="INTERIOR_BLIND", friendlyNames="@Setting.Opening", supportedRange="0:100:10", unitOfMeasure="Percent", actionMappings="Close=100,Open=0,Lower=(+10),Raise=(-10)", stateMappings="Closed=100,Open=0:99"]}
Rollershutter RolladeEGRechts "Rollade EG Rechts" (gRolladeEG) {alexa="RangeController.rangeValue" [category="INTERIOR_BLIND", friendlyNames="@Setting.Opening", supportedRange="0:100:10", unitOfMeasure="Percent", actionMappings="Close=100,Open=0,Lower=(+10),Raise=(-10)", stateMappings="Closed=100,Open=0:99"]}
Rollershutter RolladeEGMitte "Rollade EG Mitte" (gRolladeEG) {alexa="RangeController.rangeValue" [category="INTERIOR_BLIND", friendlyNames="@Setting.Opening", supportedRange="0:100:10", unitOfMeasure="Percent", actionMappings="Close=100,Open=0,Lower=(+10),Raise=(-10)", stateMappings="Closed=100,Open=0:99"]}
Rollershutter RolladeEGLinks "Rollade EG Links" (gRolladeEG) {alexa="RangeController.rangeValue" [category="INTERIOR_BLIND", friendlyNames="@Setting.Opening", supportedRange="0:100:10", unitOfMeasure="Percent", actionMappings="Close=100,Open=0,Lower=(+10),Raise=(-10)", stateMappings="Closed=100,Open=0:99"]}

Utterances
Alexa, open Rollade EG
Alexa, set Rollade EG to half
Alexa, set Rollade EG Mite to 25%

Thank you both for the fast replies!

@thefechner i have spent ages on that site of the documentation, but somehow i don’t get it…

@jeshab okay I’ll try this out, but i thought i need to use the group endpoints for item groups. Also i’ve used the PercentageController.percentage instead of the RangeController.rangeValue which difference does it make?

There are two type of groups representation at the Alexa skill level: (1) functional which represents a device with different capabilities (e.g. thermostat) and would be a group endpoint. (2) item type group which represents a group of same type devices and would be a single endpoint.
The way you can also differentiate them is that if you need to create a specific group for Alexa purpose on the OH, it is more likely to model a group endpoint. Warrant in your use case, you used rules to define a standard group on the OH side.

If you go over the semantic extension documentation I linked, you will see that RangeController interface is supported but not PercentageController. This means that if you want to use “Open” or “Close” actions, you have to model your item as RangeController.

Okay, thank you!
It now works like I wanted it to do.

So the trick is to use a group Endpoint, if i want to use a Group to control a whole room?
For example I have a light and a thermostat in a room and just say lower the temperature in in the living room or turn the living room green to control the light. Do i need the endpoint.other then?

Thanks for all your help!

For a group that controls a whole room, I would suggest using the Alexa groups especially if there are different device types as you seem to point out. As I mentioned above, a group endpoint should be representing a device with different capabilities (e.g. thermostat, receiver or TV).

Okay I got it now, but I’d prefer using groups in OH and not using the Alexa groups. But it seems like it’s impossible right now.

Thanks again for your help!

Keep in mind that using Alexa group also give the opportunity to use the room awareness feature allowing to control specific devices in a given room just by function. For example, you can add all the lights of your kitchen and link the echo device in that room to an Alexa group, and you will be able to request Alexa, turn off the lights to control all the lights in that room.