OpenHAB 5 Semantic Model Proposal

Unless you really want both .items files and the Overview tabs in MainUI to be populated (or you use HABot or might benefit from them in your rules a lot), I do not recommend using the model. It’s just too hard right now and the benefits are not that large.

If you use managed Items, right now it can be even more painful to retrofit your existing Items into the model because there is no easy way to change the tags and Group membership on a bunch of Items at once and that’s all the semantic model is, tags and Group memberships.

I find it ends up being a lot less work in the long run to just delete the old Items and create them again through the “add equipment to model”. You can use the same names but you’ll have the opportunity to pick the appropriate semantic tags. Once done you’ll have new Items with the same old names but they will have appropriate semantic tags and Group memberships and all the Items for a given Things are done all at once. You can do this on a Thing-by-Thing basis instead of needing to do it on an Item-by-Item basis. Usually there is a one-to-one mapping between Things and Equipment so this saves a lot of work. This is IMO currently the only way to reasonably apply a semantic model.

When drag and drop on the model view gets completed and merged, you’ll be able to build your hierarchy just by dragging Items around (e.g. put a bunch of thermostat Items into an Equipment and put that Equipment into a Location just by dragging them around instead of needing to go into the Item and manually change the Group membership). This will make it much easier to retrofit your Items into the model.

I also have an issue open to allow us to select existing Items from the “add equipment to model” and “add points to model” page. This should let you choose a Location, create the Equipment and then modify the settings of the existing Items (i.e. add tags) and when you hit save it applies the tags and Group memberships to your existing Items instead of creating new ones.

I’m not really sure how to help file based users though. Part of me wants to say TANSTAFFL and the complexity is what you sign up for be using .items files. Needing to look up the proper tags to use in the proper place is all part of the job you’ve taken upon yourself when using files.

But I do think there are things that can be done to help even those users. I’ll reiterate them:

  • Make the VSCode extension tag aware; there is a REST API endpoint that can be used to facilitate this.
  • Generate errors when parsing an Item that includes nonsensical tags or Group memberships (e.g. using an Equipment tag and a Property tag on the same Item, more than one Equipment tag on the same Item, etc and one Equipment or Point in more than one Location)
    Beyond that, short of massive changes to the syntax of .items files, I’m not sure what we can do except improve the documentation.

Those syntax changes, btw, would be to let users define their .items file hierarchically. I’m thinking something similar to how you can have Things inside a Bridge Thing definition in a .things file. You’d have Items defined inside of Items to represent the hierarchy. I’m not sure how feasible that is to do with the current DSL. It should be easier if we ever get to a YAML or some other “standard” based file format. There’s lots of work going on this front as well.

I’ll note though that I don’t use that in practice (as you should be able to see in my screen shots of the model view). I used them in that one place in the post above for explanatory purposes. Generally, the name of the Item is sufficient to identify whether it’s a Location, Equipment, or Point and if it’s not, the Model view makes that clear. But if using a prefix is useful by all means use it.

That’s exactly what I mean by making the semantic model more available to UI widgets. Right now only oh-repeater has access to this info and the way that works is far too inefficient to have more than a few on a given page at a time.

If it were possible to navigate the semantic model from a UI widget in an efficient manner, then most of the problems identified in the OP wouldn’t be a problem. It’s not an easy problem to solve technically though.

2 Likes

I’ve got this halfway ready for a PR.

1 Like

I had to look up that acrynym! For me, it’s the only type of lunch I’d like to eat. Yes, indeed, needing to look up the proper tags is part of the job, and my best friend is to google semantic tags csv. The first result is the master list that is my main reference. I wonder if this list is included / referenced in the main doc.

1 Like

It’s not and that’s a problem that needs to be fixed. Docs for the static model need a lot of work.

There is also a REST endpoint you can use to get all the semantic tags. The advantage there is the list will include custom tags too.

I just now saw that there’s an endpoint to add tags. I wonder how long that’s been there. So we are just missing the UI changes to define new tags? That’s good news! I may move my yaml file to become managed

It’s been there a while. Indeed we’re just waiting for someone to create the mainui interface.

@rlkoshak @JustinG I’d love some help please.

This is the setup of items to test the semantic tag check. Hopefully it’s self explanatory.

// Testing combination of tags within a single item
Group ValidCombination1 ["Location"]
Group ValidCombination2 ["Equipment"]
Number ValidCombination3 ["Point"]
Number ValidCombination4 ["Point", "Property"]
Number ValidCombination5 ["Property"]

// Mixed types
Group InvalidCombination1 ["Location", "Equipment"]
Group InvalidCombination2 ["Location", "Point"]
Group InvalidCombination3 ["Equipment", "Point"]
Group InvalidCombination4 ["Location", "Property"]
Group InvalidCombination5 ["Equipment", "Property"]

// multiple tags of the same type
Group InvalidCombination6 ["Location", "Bedroom"]
Group InvalidCombination7 ["Equipment", "Lightbulb"]
Group InvalidCombination8 ["Point", "Switch"]
Group InvalidCombination9 ["Property", "Temperature"]

// Testing model hierarchy

// Some valid Locations / Equipment / Points to be used by the test items below
Group SetupLocation ["Location"]
Group SetupLocation2 (SetupLocation) ["Location"]
Group SetupEquipment (SetupLocation) ["Equipment"] 
Group SetupEquipment2 (SetupLocation2) ["Equipment"]
Group SetupSubEquipment (SetupEquipment) ["Equipment"]
Group SetupPoint (SetupLocation) ["Point"]

// Test Point configurations
Number ValidPoint1  (SetupEquipment) ["Point"]
Number ValidPoint2  (SetupLocation) ["Point"]
Number ValidPoint3   ["Point"]
Group ValidPoint4 ["Point"]
Group ValidPoint5 (SetupEquipment) ["Point"]
Group ValidPoint6 (SetupLocation) ["Point"]
Number ValidPoint6 (SetupPoint) ["Point"] // this is fine, although not treated as related

Number InvalidPoint1  (SetupEquipment, SetupEquipment2) ["Point"]
Number InvalidPoint2  (SetupLocation, SetupLocation2) ["Point"]
Number InvalidPoint3  (SetupEquipment, SetupLocation) ["Point"]

// Test Location configurations
Group ValidLocation1 ["Location"]
Group ValidLocation2 (SetupLocation) ["Location"]
Group ValidLocation3 (SetupLocation2) ["Location"]
Group ValidLocation4 (SetupPoint) ["Location"] // this is fine, although not treated as related

Number InvalidLocation1 ["Location"] // location must be a group
Group InvalidLocation2 (SetupLocation, SetupLocation2) ["Location"]
Group InvalidLocation3 (SetupEquipment) ["Location"]

// Test Equipment configurations
Number ValidEquipment1 ["Equipment"]
Number ValidEquipment2 (SetupLocation) ["Equipment"]
Number ValidEquipment3 (SetupEquipment) ["Equipment"]

Group ValidEquipment4 ["Equipment"]
Group ValidEquipment5 (SetupLocation) ["Equipment"]
Group ValidEquipment6 (SetupEquipment) ["Equipment"]

Group ValidEquipment7 (SetupPoint) ["Equipment"]  // this is fine, although not treated as related

Group InvalidEquipment1 (SetupLocation, SetupLocation2) ["Equipment"] 
Group InvalidEquipment2 (SetupLocation, SetupEquipment) ["Equipment"] 
Group InvalidEquipment3 (SetupEquipment, SetupEquipment2) ["Equipment"] 

Can you think of any other scenarios I need to check?

This is the error messages being logged for the above test (sorry it’s not sorted), but they’re all accounted for afaik.

15:44:01.431 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidPoint2' has invalid semantic structure:
it belongs to multiple locations: [SetupLocation, SetupLocation2]. It should only belong to one location.
15:44:01.432 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidPoint3' has invalid semantic structure:
it directly belongs to both location(s) [SetupLocation] and equipment(s) [SetupEquipment]. It should only directly belong to either, not both.
15:44:01.432 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidPoint1' has invalid semantic structure:
it belongs to multiple equipments: [SetupEquipment, SetupEquipment2]. It should only belong to one equipment.
15:44:01.433 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidEquipment2' has invalid semantic structure:
it directly belongs to both location(s) [SetupLocation] and equipment(s) [SetupEquipment]. It should only directly belong to either, not both.
15:44:01.434 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidCombination8' contains an invalid combination of semantic tags.
15:44:01.434 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidEquipment3' has invalid semantic structure:
it belongs to multiple equipments: [SetupEquipment, SetupEquipment2]. It should only belong to one equipment.
15:44:01.435 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidCombination7' contains an invalid combination of semantic tags.
15:44:01.435 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidCombination6' contains an invalid combination of semantic tags.
15:44:01.435 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidEquipment1' has invalid semantic structure:
it belongs to multiple locations: [SetupLocation, SetupLocation2]. It should only belong to one location.
15:44:01.436 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidCombination5' contains an invalid combination of semantic tags.
15:44:01.436 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidCombination4' contains an invalid combination of semantic tags.
15:44:01.436 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidCombination3' contains an invalid combination of semantic tags.
15:44:01.437 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidCombination2' contains an invalid combination of semantic tags.
15:44:01.437 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidCombination1' contains an invalid combination of semantic tags.
15:44:01.438 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidLocation3' has invalid semantic structure:
it is a location but it belongs to equipment(s) [SetupEquipment]. A Location can only belong to another Location, not Equipment.
15:44:01.438 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidLocation1' has invalid semantic structure:
is a location but not a group.
15:44:01.438 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidLocation2' has invalid semantic structure:
it belongs to multiple locations: [SetupLocation, SetupLocation2]. It should only belong to one location.
15:44:01.439 [WARN ] [mantics.internal.SemanticsServiceImpl] - Item 'InvalidCombination9' contains an invalid combination of semantic tags.
2 Likes

Did not check completely, but a semantically tagged Item (Point) can belong to only one semantically tagged group (Location, Equipment). This is a known limitation and has been mentioned many times.

Yes this is already represented in the test .items file above.

Copied below:

Number InvalidPoint1  (SetupEquipment, SetupEquipment2) ["Point"]
Number InvalidPoint2  (SetupLocation, SetupLocation2) ["Point"]
Number InvalidPoint3  (SetupEquipment, SetupLocation) ["Point"]

The first one belongs to two equipments, the second one belongs to two locations, the third one belongs to one equipment and one location. All these scenarios are invalid and detected as such.

Sorry, missunderstood your post as a question.
:wink:

I’m adding semantic check into items so that invalid configurations will issue warnings.

Can you think of scenarios that I have missed? If not, I’ll proceed with writing JUnit tests and submit it as a PR

Will have to think about it and have a closer look at your examples….

I’m not in a position to test it at the moment, but I should think that this is not actually a valid configuration. I would expect that a Point type tag is a requirement for the model to find an item as a point. Certainly, the UI does not even present the option of Properties unless a Point has already been selected.

Should it be valid for a point to be a group? I’m not sure this is actually addressed anywhere, and my gut says it actually muddies the waters a little bit. Then again, I was in favor of being able to link groups to channel back in that discussion, so maybe it does make sense? Food for thought, anyway.

This is exactly what I mean by “muddies the waters”.

This is actually valid in certain cases, and intentionally so. The primary case is with a temperature point (if I recall humidity might behave the same way). The location cards, of course, have a badge for the temperature of that location, and if there are multiple temperature measurement points inside all the equipment in that location that temperature is calculated as the average of all those points. However, this is often not correct because some of those temperature measurements do not refer to the ambient location temperature (e.g., a kitchen with a smart-oven temp point, or an office with a CPU temp point). In these situations you can explicitly define one temperature point as being the ambient location temperature by making that point a direct member of the location group in addition to it still being inside the appropriate equipment.

Right now I cannot see anything you’ve missed. I’ll let you know if anything comes to mind.

Is there enough information here to make this error message more actionable or provide more information? It says what’s wrong but it doesn’t provide any information on what I as the end user should do about it. Why is it an invalid combination? Maybe we don’t even need to be specific and just list the rules:

... contains an invalid combination of semantic tags. Locations and Equipment can have exactly one semantic tag from their respective categories and Points can have exactly one Point tag and optionally one Properties tag.

But if possible, being more specifc like

InvalidCombination1 contains an invalid combination of semantic tags [Location, Equipment]. It has both a Location tag and an Equipment tag.

I think this covers everything I can think of.

Thanks! I think it will be a big improvement!

Good catch, yes a Property by itself is invalid.

Yes. Consider the case where I might have one light fixture with three smart bulbs. Logically it’s one light and can be modeled that way using a Group with a Point tag. Usually you’d want there to be an aggregation function but I can imagine cases where the Group represents “fire and forget” actuators.

Of course, in this case, the members of this Group would not be included in the model at all.

I wasn’t aware of that. That does make things much more complicated. I wish some other approach were take to solve this. That pretty much violates the “only in one place” rule of the model. Is this limited to just temperature and humidity or is it a generic capability taht works for all Item types?

I’ve been following the discussion and appreciate the insights from everyone who’s contributed—especially around the documentation gap and how the existing semantic model can already do a lot if used as intended. There’s real value in clarifying the recommended path (i.e., fully using the UI’s one-tag-per-item approach) and improving tutorials and examples, so new users don’t slip into confusion.

At the same time, I still see potential in exploring a more device-centric layer within openHAB, whether that means a curated dictionary of recognized device types or a dedicated UI wizard that simplifies how Items get classified. For some of us, especially with large or mixed setups, or those who dabble in text-based configs, the possibility of a “one-stop” device definition—one that automatically leads to consistent UI, easier automation, and simpler voice setups—remains appealing.

I’m not suggesting we throw out the current semantic model or force everyone into a locked dictionary. The existing flexibility is obviously a huge asset for openHAB. Rather, I’m wondering if there’s a middle ground: for instance, a well-documented standard set of device definitions (like “Light,” “Thermostat,” “Sensor,” etc.) combined with a clear path to custom expansions that still play nicely with the default UI.

A few folks have rightly pointed out that many of these ideas might be addressed by enhanced docs or UI improvements—for example, better validation or wizards that help new users avoid partial or mismatched tagging. That’s a fair perspective, and I agree better documentation alone could solve a huge portion of the confusion. But I’d still love to see whether something more formalized (like a small “device dictionary” or a structured device UI approach) might benefit both brand-new and advanced openHABers.

To be clear, I don’t claim to have a finished blueprint for “openHAB 5.” My goal has always been to start a conversation about how we might reduce friction for both novices and those tackling complex setups. If we can keep the door open for discussions—be it about clearer docs, a new UI layer, or a device dictionary approach—maybe we can come up with a path forward that complements the existing flexibility instead of undermining it.

Anyway, thanks for all the constructive feedback so far. I’m glad we’re talking about usability improvements, whether they’re purely in the docs/UI or in adding something more explicitly “device-centric.” I look forward to seeing how this evolves.

2 Likes

Please explain more what you mean by this. OH already is very device centric.

A Thing represents a device as illustrated in the docs:

An Equipment represents a device in the model.

I don’t see what’s missing, besides the list of Equipment tags needing work to add some more common types to the default list.

What do you mean when you say you want it to be more device-centric? What parts of OH are you thinking of when you say that? Can you provide a concrete example, maybe tracing how it would look to an end user from creation of the Thing through what ever end point you have in mind?

I’m trying to understand because right now, with my current understanding, saying “OH needs to be more device-centric” is like saying “apples need to be more apple like”. I’m not seeing what you are seeing.

It will be some work but that’s certainly something that could be in the docs. But just be clear that the “default UI” is not those custom UI widgets from the marketplace. The “default UI” is the Locations, Equipment, and Properties tabs of the Overview page in MainUI. And that already plays nicely with both custom and default tags mainly because it’s pretty simplistic. It mainly just groups stuff with the same tags together so there isn’t a whole lot that can go wrong.

The Location tab does a bit more with the badges and how the badges work really needs some good documentation.

What would “formalized” look like to you? Beyond having a default list of tags which we have now what would make that more formalized? I’m not attacking this idea or anything like that. I’m just trying to understand.

Let me list what we have now so we can come up with the missing pieces.

  1. better validation for .items files is on the way (huge thanks for @jimtng jumping on this!) so you should get meaningful errors for invalid semantic tagging. In the UI it’s impossible to invalidly tag an Item. The UI prevents you from being able to do that.

  2. It’s more like a form than a wizard, but “add equipment to model” is a device centric method to add a device to OH and the semantic model. You pick the Location, name the Equipment (this will be created) and configure all the Points. The Points will default to semantically meaningful tags (e.g. a temperature sensor will default to Measurement/Temperature). If the Equipment is already in the model, you get the same form for “add points to model” only you select the Equipment instead of creating a new Equipment. Given that Things are supposed to represent a device this form is device centric.

This is how it works now. What would you like to see changed or what different approach would make sense? Maybe add a wizard to help users build the Locations part of their model? I’m not sure it makes sense to model the Equipment independently of the Things but maybe there’s a benefit there. Maybe have a way to select a bunch of Things from the Things page and go through the “add equipment to model” for each one in turn to add a bunch of stuff to the model all at once instead of individually device-by-device.

I’m trying to figure out what something like this might look and be used.

But no wizard is going to address .items files users unless the model is rebuilt to be independent of the Items themselves, and I’m not sure that’s feasible.

OK, sure, I can see that.

Taking a quick look at the code, it appears that this is the case for all the continuous numeric badge types - Measurements: temp, humid, CO2, and light and Setpoints: temp and humid. It also looks like it’s the case for the status badges for lights, battery, presence, and alarms.

So…most :man_shrugging:

This already exists (it’s the UI addition mentioned above with the discussion of the item name prefixes). You can choose from a few different living space templates which then give you a default location hierarchy that allows you some customization of room choices and names. It then creates all the location groups at once.

When I added it, however, Yannick decided that he preferred to have the option only appear when the model is completely empty so that it is a just starting point. That’s probably why you (and many other users) have never encountered it. It might be worth an issue or PR to revisit that decision.

It is also more of a page along the lines of the Add Equipment from Thing page, and I know that Yannick has always wanted to include more of a question and answer style wizard as well, but it’s just never made it to the top of the list.

2 Likes

This validation I’m working on will apply to all items regardless of how they were created. This means it applies to .items, managed, ruby created items, etc.

I don’t think the UI is this foolproof. Very recently I’ve closed a bug that allows you to mess up an items semantic tags by entering them in the"other tags".

I believe you can still mess up the group hierarchy as of now.

Plus you can also create items using rest api without the UI, eg habapp

It really isn’t hard to apply semantic model using .items file. It just needs a basic understanding of how it works, how to apply it, the list of built in tags, and knowledge about how to add new tags.

However, I’m not sure if this last bit about adding custom tags is yet documented.

There’s the yaml method, and you can create them using jsscripting and jruby too

No, this is incorrect. If you set property by itself, the point will be inferred for you based on whether the state description says it’s a read only item. So the point would either be a Control or a Measurement. Hence why I added/allowed this particular case.

Try it!

Thanks for the explanation. I will remove the warning for this scenario.

However, this seems like a hack that should’ve been implemented differently, e.g. using a special tag or metadata, but I admit that doing it this way is more convenient. I’m not opening a discussion about this here though. It is what it is for now, the validation will adjust to the current setup.

I will still ensure though that when a Point is a member of one equipment and one location, it will only be OK if the equipment belongs to the same location

Now how about when a point belongs to two or more locations? Should that still trigger a warning?

This discussion started out with “Everything’s fine—you just don’t know how to use it.” But as the conversation progressed, its became clear that not everyone finds the current system so straightforward. We uncovered real challenges in how Items, Things, Channels, and semantic tags can be overwhelming—especially for new users or those who just want to get a device up and running without all the manual linking steps.

To show where I’m coming from, let me outline how things typically work in openHAB today (as seen in the docs):

  1. Install a binding and let it discover a new device as a “Thing.”
  2. Add that Thing in the Main UI.
  3. Create Items (manually or auto-link) for each channel (on/off, brightness, etc.).
  4. Optionally rename or reorganize those Items if you want a neat naming scheme or a consistent semantic model.

If you’re an experienced user, that might feel routine, but it’s still multiple steps—and confusing for newcomers who don’t care about the low-level architecture. In theory, the binding already knows the device type: e.g., a “LightBulb” with on/off or dimming. Why not let it auto-generate the Items under a recognized “Light” device so the user only needs to say “Yes, call it ‘Living Room Lamp’”?

The technical mechanism is straightforward: when the ThingHandlerFactory (or a DiscoveryService) enumerates a device, it could also create (or propose) a fully formed “Light” device (or “Speaker,” “Thermostat,” etc.), with Items pre-linked and correctly tagged. All the user sees is:

  • “Found LightBulb. Add it?”
  • Click “Yes,” name it if they want, and done.

For advanced users, the existing manual approach remains intact. They can rename, reorganize, or handle everything in a more granular way. But for the majority use case—where you just want to turn on a new light or control a new speaker—this automated approach removes a ton of friction. My own work on the LinkPlay binding has shown how beneficial this would be: if I could auto-generate a “Speaker” device with Items for volume, play/pause, metadata, etc., the user wouldn’t have to manually link each channel or guess how to label them. That’s the usability we should be aiming for. All home automation platforms have rigorous device defintions - because it improves usability.

2 Likes