Change semantic classification of item


I want to change semantic classification of an item from “isPartOf X” to “hasLocation X”. I tried the following using REST API:

curl -X PUT "http://openhabian:8080/rest/items/Verdichter/metadata/semantics" -d "{\"value\":\"Equipment\",\"configuration\":{\"hasLocation\":\"X\",\"isPartOf\":null}}"

… which returns 200 but doesn’t seem to have any effect. Any solutions welcome.

The hierarchy in the semantic model is created through Group membership. If you want it to be in a given location instead of being a part of a given equipment, remove it from the parent Group Item that has the equipment tag and add it as a direct member of the Group Item with the Location tag.

It already had a parent group item with Location tag, but what I did before is I changed that parent group item from Equipment to Location. Doing that seems to not update semantic classification of children. What I did now is just removed the parent association completely and readded it again. Now everything is fine. Thanks for the pointer :slight_smile:

In general, I consider this to be a bug. There is an API to do what I did which resulted in an invalid state.

No, there is no API because it’s not driven by the API. It’s driven by the Group membership. There isn’t enough detail here but I suspect that had you reloaded the browser the new relationship would have been picked up. There is no event generated when an Item changes Groups so there is nothing to tell the UI that the Item’s parent Group has changed. So short of having the UI constantly reloading all the Items all the time there really isn’t any way to make a change like that show up immediately.

I don’t meant that there is an API for changing semantic classification, but for changing an Item from Equipment to Location. It’s exactly that status transition which does not manage the child’s classification correctly, leading to the state which caused me to ask this question.

And as I said, there is no event that gets published when that happens. So there is nothing to tell the UI that it needs to change what it’s showing you. However, a refresh of the page should force it to load all the Items anew and it will see the change.

Unfortunately a refresh hadn’t any effect at all. I wrote a script which deassociated all members and just associated them again. That worked successfully.