How to "convert" a sitemap item to an openHAB 4 item

I am new to openHAB and I am using the UI of openHAB 4 to create my items.

I have this item example from an add-on I want to create and I have no idea how to create this in openHAB 4 UI. From the add-on description.

“For example, the following sitemap item can be used to send commands to the area and receive response status as modified color of a label:”

Switch item=areaControl label="Actions[]" mappings=[QA="Regular Quick Arm",QS="Stay Quick Arm",D1111="Disarm"] labelcolor=[Ok="green",Fail="red"]

Can somebody show me the way to create this item?

That’s not an Item definition. That’s a Sitemap element. That doesn’t define an Item. It describes how an Item appears on a sitemap.

Because it’s a Switch element with Mappings, I would assume it’s a String Item, so create it like you’d create any Item from the Model page using “add point”, or from the + icon on the Settings → Items page. If this Item is to be linked to a Channel on a Thing, you can create the Item from the Model page using “Create Points from Thing” or “Create Equipment from Thing” or from the Thing’s Channels tab where those two options are also available.

@rlkoshak Thank you for your reply. I am no sure that your solution will solve my question, but maybe it is my misunderstanding. Again, I am new to openHAB and slowly progressing.

Since my original question does not really have a straightforward migration path, I will rephrase my question and maybe it will be clearer what I need.

The Thing Channel is a simple String channel to which I can send string commands and it returns a response “Ok” or “Fail”. The author seems to create a multi state switch labelled “Actions”, the switch has three states and each state can send a string command:

“Regular Quick Arm” → Sends QA to the Channel
“Stay Quick Arm” → Send QS to the Channel
“Disarm” → Sends D1111 to the Channel

The return code will determine the color of the Label: Ok=“green”,Fail=“red”

How can I create an Item that can do this, if at all possible? Again, I don’t yet totally understand all the concepts. Maybe for this I do need to use sitemaps, but not sure if it will be compatible with Model/Pages.

Thanks for your help.

There is some confusion about what exactly you are asking for because you appear to be mixing up terms. Note that in openHAB the word ‘Item’ has a very precise meaning as it is one of the functional units of the software. In OH an item is a construct that holds some piece of information. It looks like you already have the Item because the sitemap element you have showed refers to an Item named areaControl. Your site map element sends a command to that item based on which button you have pushed, and it seems likely, based on your description that the areaControl Item is linked to the channel of interest.

So, if you are really asking about creating an “Item”, then Rich’s advice is the path you want to follow.

If you are asking about creating a UI element for the MainUI that does the same thing as the Sitemap element you already have, then the answer is 1) yes it can be done, 2) there is no directly equivalent solution but there are many different options, and 3) it will take some understanding of the widget syntax and editing system. So, if you haven’t worked with widgets yet then you really should go through the Quick Start Tutorial and related pages:

as well as the more detailed MainUI specific documentation:

This may also help while you are reading those:

The closest MainUI element to the mapped buttons on a sitemap is probably the segmented button which is a container that will hold multiple other buttons. In this, case you would then add one button for each of the commands that you want to send your Item:

- component: f7-segmented
    raised: true
      - component: oh-button
          text: Regular Quick Arm
          action: command
          actionCommand: QA
          actionItem: areaControl
      - component: oh-button
          text: Stay Quick Arm
          action: command
          actionCommand: Qs
          actionItem: areaControl
      - component: oh-button
          text: Disarm
          action: command
          actionCommand: D111
          actionItem: areaControl

That segmented button defined above looks like this:

Another very easy option is a single button that when you click on it presents you with a menu of the different options:

- component: oh-button
    text: Menu
    action: options
    actionItem: areaControl
    actionOptions: QA=Regular Quick Arm,QS=Stay Quick Arm,D111=Disarm

This just presents as a button:

But when you click on it, it brings up a list of the options:

The MainUI system is so flexible that there are many other options as well, but these are the two easiest and most direct.

@JustinG Thank you for your very detailed reply, I will look into this. I will get back once I have figured it out and will complete the topic, but it might take a while. I do this on spare time.

I do understand what an Item is in openHAB, it is the sitemap that is not clear. The item named “areaControl” is from a sitemap example that the author of the add-on posted, I do not have that item.

I think you’re too focused on that example.

A sitemap is just a graphic UI, and nothing more. In most cases it’s just used to display and control items. You can’t use it to define items. You have to create items in openHAB and then add them to a sitemap.