Skip to content
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

XSD Add semantic tag on things #4617

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Conversation

andrewfg
Copy link
Contributor

@andrewfg andrewfg commented Feb 23, 2025

The purpose of this PR is to add a semantic (equipment) tag to things so that the UI can use that tag for putting items that are bound to channels on such things in the semantic model.

Adds two things:

  1. Extends the XSD schema definition to add a semantic (equipment) tag on thing types. See also XSD Add restrictions for semantic tags on channel type definitions #4615
  2. Adds code to permeate this tag throughout OH core wherever it may be needed. Specifically in the classes, DTOs and (de)serializers for thing types and things.

Signed-off-by: Andrew Fiddian-Green [email protected]

Signed-off-by: Andrew Fiddian-Green <[email protected]>
@andrewfg andrewfg requested a review from a team as a code owner February 23, 2025 11:39
@andrewfg andrewfg marked this pull request as draft February 23, 2025 11:39
@andrewfg andrewfg changed the title XSD Add new definition for semantic tags on things XSD Add new definition for semantic tags on thing type definitions Feb 23, 2025
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/openhab-5-semantic-model-proposal/162526/96

@andrewfg andrewfg changed the title XSD Add new definition for semantic tags on thing type definitions XSD Add semantic tag on things Feb 23, 2025
Signed-off-by: Andrew Fiddian-Green <[email protected]>
@andrewfg andrewfg marked this pull request as ready for review February 23, 2025 16:24
@andrewfg andrewfg marked this pull request as draft February 24, 2025 07:56
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
@andrewfg
Copy link
Contributor Author

@mherwege can I kindly ask you to be a sparring partner for this PR? My goal is to allow developers to set a (proposed) semantic (equipment) tag in their thing type xml, and have this permeated through the thing type instances to the actual thing instances so that the UI can use that semantic (equipment) tag (as a hint) in creating a semantic model.

@mherwege
Copy link
Contributor

@mherwege can I kindly ask you to be a sparring partner for this PR? My goal is to allow developers to set a (proposed) semantic (equipment) tag in their thing type xml, and have this permeated through the thing type instances to the actual thing instances so that the UI can use that semantic (equipment) tag (as a hint) in creating a semantic model.

@andrewfg Sure. I like the idea as long as it does not then enforce anything on the item semantics. So I would think that it should be carried to the point of a having a tag on the thing, but then it should be up to the UI to pick this up as a suggested equipment semantic when creating the group item with its points (create model from thing).
As it should not be used on the thing directly, except when creating items, I am wondering what it should be called. Some day someone may think it carries meaning beyond a suggestion for an equipment group item, and may want to also show that in the UI...

@andrewfg
Copy link
Contributor Author

andrewfg commented Feb 24, 2025

Indeed. The tags in the ChannelType xml are hints for semantic “point” and semantic “property” tags which are intended for functional Item creation. And the single tag in the ThingType xml would be a hint for the semantic “equipment” tag intended for semantic GroupItem creation. The remaining “location” semantic tag is entirely user dependent and would not come from the xml.

PS we could even explicitly name it equipmentTag ..

Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
* @param semanticEquipmentTag a string with semantic (equipment) tag for this thing
* @return the {@link ThingBuilder} itself
*/
public ThingBuilder withSemanticEqipmentTag(@Nullable String semanticEquipmentTag) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

Suggested change
public ThingBuilder withSemanticEqipmentTag(@Nullable String semanticEquipmentTag) {
public ThingBuilder withSemanticEquipmentTag(@Nullable String semanticEquipmentTag) {

* @param semanticEquipmentTag semantic (equipment) tag
* @return the updated builder
*/
public DiscoveryResultBuilder withSemanticEquipmentTag(@Nullable String semanticEquipmentTag) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it would be better to stay consistent and generic like e.g. here:

/**
* Adds a tag to the ChannelType
*
* @param tag Tag to be added to the ChannelType
* @return this Builder
*/
T withTag(String tag);
/**
* Sets the StateDescription for the ChannelType
*
* @param tags Collection of tags to be added to the ChannelType
* @return this Builder
*/
T withTags(Collection<String> tags);

so simply withTag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #4617 (comment) above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants