How do I create groups and items in runtime mode, display them in the user´s interface (basic UI perhaps), and control their events (also in runtime)? Is it possible?

My idea:
I have some eletronic boards that work by tcp (json) commands and they have some controls (relays, dimmers, temperature and humidity reader, 0 and 1 inputs, etc). Let’s say that each room has one of these boards and with it I can control the whole environment of the room (temperature, lamps or anything that suits the relays and dimmers).
Following the basic of OpenHAB, I create the “groups” (sitemap file) with the name of each room, and create each control of the board as an item (item file) of OpenHAB, associated with the room’s group.
But what I want, is to create scenarios in runtime mode.
So, on a screen, I’ll show all usable items of the boards, representing them with a Switch. In the next screen, I´ll only show the ones I chose (Switch = ON), but on the way they really are (Relay as Switch, dimmer as Dimmer, Contact for 0 and 1 inputs, Number for temperature and humidity, etc.).
When I define which items will work and how they will work, those scenarios will be written on the database or json file.
So when I enter the screen of registered scenarios, these saved scenarios will appear as Switch, and when triggered, will act on the items as programmed.
I have already studied hashmap and lambdas (I was able to take advantage of what I know of C#), so with a little effort I can create lists of items, lists of groups, save this information on database or json file. I can create a “scenario_01” group, and include items in it, in runtime mode.
But I have not found anything that tells how I can present these new groups or new items in the user interface. What is the direction, if any? Is it possible?
(Sorry for my poor english).

http://docs.openhab.org/tutorials/beginner/rules.html

http://docs.openhab.org/configuration/rules-dsl.html

These paragraphs do not make any sense. HashMaps and Lambdas are concepts that apply to Rules, not Groups and Items. You don’t put them on your sitemap. Your Sitemap is for Items and Groups.

You need to create a Design Pattern: Unbound Item (aka Virtual Item) which you put on your sitemap and use a Rule that triggers when that Unbound Item is triggered that sends the right commands to all the other Items.

If you have a group of Items that are all of the same type that you want to command as if it were one Item (e.g. a bundh of switches controlled by a single switch), create a Group:Switch, add all the Items you want controlled by that Group as members, and put the Group on your sitemap using the Switch element.

Switch item=myGroup

So, there’s no way to add an item or group in runtime mode.
Ex: The user wants to create a new scenario, and wants to give the name “Good evening”. But it does not have this scenario planned, it is not written in the files ‘rule’ or ‘sitemap’. There is no ‘Good_evening’ group or items associated with this group either.
This will never be possible in OpenHAB: create a group through the Basic UI, associate items with this new group, indicate how each of these items should work, without changing the rule and sitemap files.
Is correct?
I read about Virtual Item. I understood it as being a resource to use as an item without having to present it in the UI (this is optional). It is like using a Switch as a boolean variable, but with the advantage of persistence and the use of triggers (it’s is an exemple).
Anyway, I would have to declare it on some item file. What I’m looking for is not having to declare on an item file, because I just do not know what the user is going to want to do. What I want is to create mechanisms to create scenarios, by the UI, without declaring items in the files.
Something similar to my idea was discussed here:
https://community.openhab.org/t/configurable-scenarios/10140/7
The difference is that all items and all groups are declared. But what if the user wants to add another scenario? I would have to rewrite the rules, items and sitemap files. What I’m looking for is an alternative to do this without rewrite. So I mentioned hashmap, where I can create lists, new items and new groups in memory, but I still do not know how to present these new things, because in essence, OpenHab only presents what is explicitly described on item and sitemap files.

I wouldn’t say never as a lot of new concepts and capabilities are being added in the Experimental Rules Engine. But as of right now that is correct.

Even with the current limitations of OH I wouldn’t say this is completely impossible but it will take a good deal of pre-configuration to set up.

First, you would need to create a Group that gets put on your sitemap using the Group element. Then any Item or Group that you create dynamically (which you would do using the OH REST API) would be added to that parent Group and BasicUI will show that Item. However, you will have no ability to control how these Items are presented including their order or, for example, showing a Switch Item with the Text element because you don’t want the Item controlled from the UI).

But your scenario you described doesn’t have much to do with what your OP was asking about. Lambdas and HashMaps are still just concepts that are used within Rules.

Any Item can be optionally be presented in the UI. A Virtual Item is an Item that is not bound to a binding nor linked to a Channel on a Thing. It is an Item whose purpose is to store/set state that is independent of a device.

Ultimately this is not really what OH was designed to support. At the end of the day, you will probably be better off developing your own custom UI that creates the Items, Groups, and sitemap using the OH REST API and sitemap files.

As I discussed in that thread, if you want to provide simple automation presented to the user you have to make the automation less capable. OH provides no mechanism to present a less capable interface to the user so if that is what you want you will have to build it yourself.

Like I’ve mentioned, you can create Items and Groups using the OH REST API. You are not required to use .rules files.

There are techniques you can use using Groups that allow you to write somewhat generic Rules in the Rules API. The JSR223 binding will let you write Rules in Jython, JavaScript, or Groovy which provides even more opportunity to write rules in a generic way. But the existing sitemap based UIs require edits to the .sitemap file unless you use Groups like I described above. HABPanel I think is not capable of supporting this at all.

You can’t because the HashMap only exists in the Rules. The sitemap only knows about Items.

Thank you so much!!!