OH3 Switch Mapping Equivalent i.e. item with multiple options

Since starting with OH3 I’ve struggled to find a way to create an item with mutliple options (mappings). In OH2 I did it like it’s described here:

And in my sitemap I had things like:

I’d looked through all the docs but couldn’t see how to do this in OH3 but when I finally worked it out it looks really cool and I figured it was worth sharing a guide incase any one else is struggling or if anyone can suggest how I could improve further.

So this is how I did it: To start I create an item ‘HDMI 1’ as a number and pop that as a point in a piece of equipment in the semantic model:

Screenshot 2021-01-16 at 16.45.49

Then I added metadata to the those item and add ‘Command Options’ in this list. From the screen shot you can see how I map some states to labels:

Now when you click that item from a widget you get a pop up list from which you can select the labels and that gives the item that state:

The last bit is just to create a rule that does something when the item ‘HDMI 1’ in this case is updated. Mine just posts from Http requests:

Note there’s 6 outputs to 6 ‘ifs’ however i only have four bits of kit connected at the moment so only 4 command options. It’s great how to add kit I just need to add a few lines in there.

The only part I’d like some advice on is as my ‘selection’ is state-less i.e. mine fires an IR code I reset to the state to NULL as don’t know if it’s been changed in another way, so I’d like to hide the number in the widget:

Is there a way to do that?

Anyway hopefully this will be helpful to other people.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.