commandOptions in textual configuration

How do I set commandOptions in file based config? I can’t find any documentation on that.

We probably need more information to understand what you mean by “commandOptions” (it’s not a generic openHAB term, maybe it’s something specific to a binding?).

I found the answer in this thread: [OH3] Add metadata to Items via configuration files

This is what worked for me.

Number ShellyRGBW2AlwinRegalhinten_Schema   "Schema"   <text> (alwin_room, tasmota_rgb_scheme)   ["Control", "ColorTemperature"]  {
	channel="mqtt:topic:BigmacBroker:shelly_rgbw2_alwin_shelf_back:Scheme",
	stateDescription=""[
		options="1=Static, 2=Cycle Up, 3=Cycle down"
	]
}

you can configure them for label cards:
image

and for items as metadata:
image

not sure what the difference between item command options and state description → options is

OK, those. I had thought about MainUI given the category this was posted in.

There’s too much of OH for one person to keep up with.

In general, if you see something in MainUI and you want to represent it in a text based config I recommend the following:

  1. Do it in the UI first.
  2. Click on the “Code” tab. You’ll see a YAML representation of your metadata.
  3. Use the following simple rules to translate from the YAML to .items files syntax:

First an example:

Metadata goes between the { } of the Item. Different metadata is separated by a comma (in your example above you have a “channel” and a “stateDescription” separated by a comma.

  • The first value is the namespace of the metadata. In my screenshot example it’s “debounce” (look at the orange part at the top where is says “Edit Item Metadata: debounce”.
  • After the namespace will always be an =.
  • Next you have the value which is put in quotes immediately after the =. If there is no value, use an empty string "".
  • Then you have an array of additional name/value pairs. An array is defined by [ ]. This is called the “config”. If there is no config you can omit this part or add an empty [].
    • each entry will be name="value" format
    • if there is more than one entry they are separated by a comma.

Given these rules, the above screen shot example would translate to:

debounce="Garagedoor_Sensor"[timeout="1s", state="OPEN,CLOSED"]

These rules apply to all Item metadata, whether it’s so called “well known” metadata like state description, Alexa, or Google Assistant, as well as custom metadata you might define yourself.

2 Likes

It’s not obvious, but relates to the fundamental openHAB distinction between commands and states - very important.

In this GUI context, you might regard stateDescription as a display map i.e.
options="1=Static ...
When the Item value is 1, display the text “Static”

command options are about input i.e. when the button marked “Static” is pressed, send command 1 to the Item.