-
-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Letting the user extend the semantics model #3619
Comments
When I first thought about how I can integrate it into HABApp I thought about adding a |
Yaml is not very user friendly IMHO and all our configuration files use a dedicated syntax that is more user friendly. Implementing managed tags (with its JSON DB) is already something not so trivial if you don't have a good knowledge of the OH core storage stuff. I am sure that I will need more time than a core maintainer but I can take examples from how it is done for items or things. |
Please don't introduce new XText. XText is a PITA to work with and currently blocks us from upgrading GSON. Upgrading XText this time is even more difficult than the last time because they introduced dependencies on equinox runtime. |
And @jimtng added the ability to add tag class but not to remove them. It is also something else missing. Added in my first message. |
Regarding the textual config file, one option could be use a simple CSV file, similar to what we already have in code to generate the predefined model. |
I know you are just listing examples, but the hierarchy of the tags is important too. Don't forget to capture the parent tag which can be any existing tag, not just Location, Equipment, Point or Property.
And return the full list. If MainUI is going to support this (and there's no reason it shouldn't) it needs to get the full list from the API too. Showing them in a hierarchy would be useful and informative so maybe return the list as a JSON hierarchy.
Ephemeris uses XML so having a different format from some custom XTex based format or JSON has precedent. Compared to XML and JSON, YAML is way more user friendly. But in addition to CSV, .ini and .properties files could fit here too. I agree, we should try to move away from inventing our own file formats for file based stuff in OH where possible, even if XText didn't have the problems @J-N-K mentions. The one advantage I can see to YAML over CSV or some other format is that in MainUI these tag definitions will be shown as YAML on the Code tab. It would be kind of nice if we could inch towards consistency between what you see in the UI and what you do in files. I know we can never get there entirely but even baby steps would be an improvement. |
From all the file formats (csv, json, xml) in this threads yaml is without doubt the most user friendly. The custom XText files might have shorter syntax, but it's still impossible to e.g. define nested item metadata because nobody knows how to define it in XText. I'd rather have a feature complete but more verbose file format which I can read with a somewhat standard file parser than another format which only benefit is that it's shorter. |
There seems to be a well-maintained library for YAML which is also an OSGi bundle: SnakeYAML. It also supports serialization, so in the long-term we could switch from XText to YAML because we could parse the model and write a converted YAML for it. |
@J-N-K just a heads up: |
It seems that |
I think it would be really good to have a 1.2 parser because the changes make it work much more straight forward and there are less traps for new users.
It's possible to directly and arbitrarily embed custom type directives in yaml, e.g. my_key: !!my.custom.data.type
- value1 Doing that is normally discouraged and most yaml parsers provide a "save load" which ignores this directive. |
It looks like unloading a Java class is not really possible. |
@spacemanspiff2007 I just found that we have YAML support already integrated:
This seems to use SnakeYAML (but 2.0, so only YAML 1.1 support). I don't think we should add another YAML engine in that case, it is already confusing that we have
|
There already is a PR to load the tags from REST, but it is waiting for review and merge: openhab/openhab-webui#1882. |
I believe I should be able to submit a PR soon, at least a partial PR. |
Related to openhab#3619 New registry for custom tags. New managed provider to add/remove/update custom tags. Storage of managed custom tags in a JSON DB file. New REST API to add/remove/update custom tags in the semantic model. New REST API to get a sub-tree of the semantic model. Signed-off-by: Laurent Garnier <[email protected]>
The main part is now implemented. Next step (and final step for me) will then be the adding of a provider taking custom tags from a configuration file. |
In my PR (not yet merged), I have enhanced with two new fields the data returned by the API. I hope this will not break your PR. |
I can adjust my PR if needed. |
Any idea how to show/manage the tags tree in MainUI to allow adding/removing custom tags? |
We have the model built by the user by assigning tags to items, this one is called the semantic model in MainUI. How do you call the model with the predefined hierarchy of tags that can now be extended with custom tags ? Isn't it also the semantic model ? Or the tags model ? |
I agree, especially when you are not talking about the most used language all over the world. @florian-h05 : with your UI PR, will the custom tags be automatically considered in the locations/equipments/points/properties tabs of the UI ? |
I imagine we could have a new page "Tags" in addition to pages "Things", "Items", "Model", ... With my PR in progress, you will receive all tags (predefined + custom) but there is currently no way to distinguish them in the result of the API call. I guess you will need this information. I can add a new boolean field "custom" ? |
@J-N-K : for the configuration files, I will have to handle the external updates of files triggering the update of the tags registry. Can you please tell me where I can find a good entry point where it is already done in core framework ? I already know that I need to add a new custom tag provider that will read the file(s) to return a list of custom tags. Regarding the starting process, I am not yet sure we need the custom tags being loaded before the items ? If custom tags are used on items and custom tag is not yet loaded, I am not sure of the consequence. And if the load happens after, is it ok ? |
I‘d propose a tree view such as for the semantic model on a separate page, see the next paragraph regarding naming.
I‘d name it‘s menu point „Semantic Tags“ with description „Manage tags for the semantic model“.
Great, can you probably comment on my UI PR to ask Yannick to review it?
Exactly, yes. Everywhere UI uses the semantic tags, the ones loaded from the API will be used as they are not hard-coded to the UI anymore.
I‘d rather name it |
Related to openhab#3619 New registry for custom tags. New managed provider to add/remove/update custom tags. Storage of managed custom tags in a JSON DB file. New REST API to add/remove/update custom tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
You're right. |
Related to openhab#3619 New registry for custom tags. New managed provider to add/remove/update custom tags. Storage of managed custom tags in a JSON DB file. New REST API to add/remove/update custom tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New defualt semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of managed semantic tags in a JSON DB file. New REST API to add/remove/update semantic tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of managed semantic tags in a JSON DB file. New REST API to add/remove/update semantic tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of managed semantic tags in a JSON DB file. New REST API to add/remove/update semantic tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of managed semantic tags in a JSON DB file. New REST API to add/remove/update semantic tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Label, description and synonyms removed from TagInfo annotation. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Tag label/description/synonyms are now in the registry, no more as part of the semantic class annotation. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Tag label/description/synonyms are now in the registry, no more as part of the semantic class annotation. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Tag label/description/synonyms are now in the registry, no more as part of the semantic class annotation. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Tag label/description/synonyms are now in the registry, no more as part of the semantic class annotation. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Tag label/description/synonyms are now in the registry, no more as part of the semantic class annotation. Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Semantic tag class annotations are removed. Semantic tag classes are now created at runtime. Classes Locations, Equipments, Points and Properties are removed Static methods SemanticTags.add removed The adding of semantic tag classes is now managed only by the tag registry. Avoids calling static method SemanticTags.getById when possible SemanticsMetadataProvider service now requires semanticTagRegistry to start. Signed-off-by: Laurent Garnier <[email protected]>
I have now a file provider (YAML) working. I will submit a new PR probably tomorrow after the initial PR is merged. |
* Add semantic tag registry + REST API to manage user tags Related to #3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Semantic tag class annotations are removed. Semantic tag classes are now created at runtime. Classes Locations, Equipments, Points and Properties are removed Static methods SemanticTags.add removed The adding of semantic tag classes is now managed only by the tag registry. Avoids calling static method SemanticTags.getById when possible SemanticsMetadataProvider service now requires semanticTagRegistry to start. Signed-off-by: Laurent Garnier <[email protected]>
Files in folder conf/tags are loaded by this provider. Related to openhab#3619 Signed-off-by: Laurent Garnier <[email protected]>
Files in folder conf/tags are loaded by this provider. Related to openhab#3619 Signed-off-by: Laurent Garnier <[email protected]>
Files in folder conf/tags are loaded by this provider. Related to openhab#3619 Signed-off-by: Laurent Garnier <[email protected]>
Files in folder conf/tags are loaded by this provider. Related to openhab#3619 Signed-off-by: Laurent Garnier <[email protected]>
Files in folder conf/tags are loaded by this provider. Related to openhab#3619 Signed-off-by: Laurent Garnier <[email protected]>
MainUI is now correctly handling semantic tags added through the REST API, that is a very good point. I will do more tests, I have done only a basic tests with the addition of a location and an equipment. I believe this new feature will be very appreciated by a lot of users and I hope we can make it usable in a more convenient way before OH4 is released. I can easily understand that adding a new page in MainUI to show and manage semantic tags is not something trivial and I am not sure that the remaining time before OH4 is released will be sufficient. So I would like to provide at least the config file option. I was asked not to use XText to create a new file format but rather YAML format. I think my proposal in PR #3659 is already ready at 95% and I even considered @J-N-K general concept proposed in #3666. Note that there is not yet any UI tab showing YAML code for a semantic tag and the YAML code for a semantic tag is very simple. |
) * Add semantic tag registry + REST API to manage user tags Related to openhab#3619 New registry for semantic tags. New default semantic tags provider for all built-in semantic tags. New managed provider to add/remove/update user semantic tags. Storage of user semantic tags in a JSON DB file. New REST API to add/remove/update user tags in the semantic model. New REST API to get a sub-tree of the semantic tags. Semantic tag class annotations are removed. Semantic tag classes are now created at runtime. Classes Locations, Equipments, Points and Properties are removed Static methods SemanticTags.add removed The adding of semantic tag classes is now managed only by the tag registry. Avoids calling static method SemanticTags.getById when possible SemanticsMetadataProvider service now requires semanticTagRegistry to start. Signed-off-by: Laurent Garnier <[email protected]> GitOrigin-RevId: f86635f
* Add a YAML file provider for semantic tags Files in folder conf/tags are loaded by this provider. Related to #3619 Signed-off-by: Laurent Garnier <[email protected]>
I close this issue as we have everything in 4.1 except the UI part for managed custom tags. |
PR #3519 introduced a technical way to add dynamically new tags in the semantics model. This was an important part but this is only a small part of what must be achieved to let the final user create and control the tags he would like.
I try to list all the missing steps:
Please let me kn ow if I am missing something.
The first 3 items are the minimum requirements and I will try to provide items 2 and 3.
The text was updated successfully, but these errors were encountered: