OH3 UI: Advice on organizing items by models

My setup has around 400 items, mostly from modbus and knx things, all of them created in a text file. Many of them are organized in groups.

I’d like to create models to include them in the UI. For example, in the Equipment tab have all the windows contact listed. Given the amount of items, what would be my best option?

The semantic model is organized around physical layout
i.e. this temperature reading sensor belongs to this equipment
This equipment is a multi-sensor
this equipment is located in room B
room B is on the ground floor

It’s pretty much useless for “show me all temperature readings”. That’s okay, ordinary Groups still exist outside of any model.

I recommend recreating the Items using “Create Equipment from Thing”. Trying to build and maintain the model in .items files is a whole lot more work in comparison.

Just be sure to create equipment based on what your end users see. It is irrelevant that the actual relay is in a closet in the garage somewhere. The end users just care about this lamp in the kitchen. So model the lamp and the kitchen.

Not necessarily. The Properties tab of the Overview page will show the Items grouped by Property.

Hmmm, those numbers don’t look right, I may meed to calibrate my office sensors, it’s not 73 °F in here right now I guarantee. I still have those Items I was using to test that units problem with the MQTT binding there too.

You can even generate a chart of them all on the fly by clicking the “Analyze All” button at the bottom.

In rules it’s easy to get all the Items with a given tag so you can pull all the Items with the “Temperature” tag.

The model isn’t exactly useless for this. But there can be challenges if you’ve some temperature tagged Items you want to exclude in some cases. For example, if I want to calculate the average indoor temp I certainly don’t want to include the outside temp.

Thanks for all your thoughts.

At this point it’s not. I don’t have the guts of recreating all the items, in the UI. And yes, I’m one of those that prefers text files over UIs… :slight_smile:

Good luck then. More than one person has preferred to use. items files has moved to the UI or simply given up on the model. With 400 Items I guarantee it’s not going to be ready in files.

I have had a setup with files and a pretty complete model. It worked but I switched to UI management anyway. It’s much easier to find the right way to do something and I find the I-can-quickly-grab-my-phone-and-fix-that method splendid.

Don’t be afraid to make the switch. Get to know the API a bit and something like postman and you can do it all (items, things and rules) in one evening.
I’ve actually done this kind of workflow:

  1. from a file based config, query the API for the objects you want to move, for example GET /things
  2. copy/paste the json response to a text file and save it to disk
  3. prepare a postman call to POST /things that will create one object at a time, use the test runner to iterate over all the objects in the previously saved file
  4. remove you .things files
  5. execute the postman runner

You don’t necessarily need postman for that. The API Docs Explorer under Developer Tools is interactive. You can query and prayer there JSON there.

And if course for Items, there’s the "add items from text definition x where you can issue in a whole .items file at a time if you want.

There are lots of ways to make moving to the UI easier. It almost never has to be a point and click process.

Yes I know the api has that nice swagger interactive documentation. But I don’t think you can automatically create multiple things or rules with it without copy pasting each thing JSON definition in the window and clicking on submit?

You can submit multiple Things as an array in one request.

If that were the case, it would greatly improve on migration from file based to ui based config.

However I’m afraid it’s not. I just did the test and have sent this:

  { "label": "Test json list thing 1",
    "bridgeUID": "mqtt:broker:home",
    "configuration": {},
    "properties": {},
    "UID": "mqtt:topic:home:test1",
    "thingTypeUID": "mqtt:topic"
    "label": "Test json list thing 2",
    "bridgeUID": "mqtt:broker:home",
    "configuration": {},
    "properties": {},
    "UID": "mqtt:topic:home:test2",
    "thingTypeUID": "mqtt:topic"

On POST /things

And received back a code 500:

Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $\",\"http-code\":500,\"exception\":
{\"class\":\"com.google.gson.JsonSyntaxException\",\"message\":\"java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $\",\"localized-message\":\"java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $\",\"cause\":\"java.lang.IllegalStateException\"}}}"

Since your good luck post, you made me think what if I’m wrong, and .items files is not the way to go…

I’m giving it a try, and with postman or the API explorer, maybe I get the thing done without too much effort.

(being a git geek, it’s hard for me move away from text files…)

I have these concerns/doubts:

  1. I tried “Create Equipment from Thing”, but I was only able to add equipment using the “Add equipment” option (after adding a location). Is that because the things are also defined in .things files?

  2. When a equipment is added, I need to add one or more Points. Is a point a new item that is created? So when a point is created, there will be 2 items pointing to the same thing, right?

  3. If I succeed the migration, will I have to redo all the rules, with the new Point items?


It’s still text files. I have all my configs checked into git. The order is even preserved in the JSON files so it’s easy to keep track of history.

About the only things you give up are inline comments and the ability to split them into multiple files.

I need more information. Just remember that it’s all just Group membership and tags so it isn’t impossible to do anything that can be done with those. Where are you seeing the “add equipment” option? What order did you try to do this, step-by-step?

When you choose “add equipment from thing” or “add points from thing” then yes, it’s creating new Items for those Channels you choose to include. If you already have Items linked to a given Channel, you will have two Items linked that Channel after adding the equipment.

If you choose different names for the Items yes, you’ll have to update your rules with the new names.

That’s why I recommend recreating your Items, not building up duplicates of your Items, one in the model and one not. Since you are currently using .items files, that’s as simple as removing a .items file or commenting out some entries in the file, recreating the Items using ‘add equipment from thing’ or ‘add points from thing’ and if you are careful to use the same names for the Items you don’t have to do anything to your rules or persistence.