|
| 1 | +--- |
| 2 | +layout: developersguide |
| 3 | +title: Developer Guidelines on Semantic Tags |
| 4 | +--- |
| 5 | + |
| 6 | +# Developer Guidelines on Semantic Tags |
| 7 | + |
| 8 | +## Introduction |
| 9 | + |
| 10 | +A semantic tag is an attribute of an openHAB [object](#objects-that-use-semantic-tags) that provides information to the openHAB User Interface about the type (i.e. the nature) of either things or items. |
| 11 | +Note the use of the word `type`. |
| 12 | + |
| 13 | +Semantic tags are divided into the following categories: |
| 14 | + |
| 15 | +- EQUIPMENT (relates to the `type` of a piece of equipment) |
| 16 | +- POINT (relates to the `type` of a particular data point within some equipment) |
| 17 | +- PROPERTY (relates to the `type` of the information carried by a point) |
| 18 | +- LOCATION (relates to the `type` of the location of an equipment or point). |
| 19 | + |
| 20 | +## Purpose of Semantic Tags |
| 21 | + |
| 22 | +The various equipment, points, properties, and locations are displayed in the openHAB User Interface in a hierarchical tree structure, which is based on a hierarchy of semantic tags defined in openHAB Core. |
| 23 | +The primary purpose of semantic tags is to help the User Interface generate such a hierarchical tree structure of the user’s home system with its respective nested rooms, devices (things) and items. |
| 24 | +Semantic tags are also used by HABot and end users in rules. |
| 25 | + |
| 26 | +The purpose of this document is to provide rules for openHAB developers and openHAB maintainers in applying existing semantic tags as follows: |
| 27 | + |
| 28 | +- By addon developers/reviewers at design time in the addon's `thing-type.xml` and `channel-type.xml` definitions. |
| 29 | +- By addon developers/reviewers at run-time dynamically in the addon's Java code. |
| 30 | +- By addon developers/reviewers in deciding whether to propose/approve a new semantic tag. |
| 31 | + |
| 32 | +Note: the document may also provide information to help users when setting up their system. |
| 33 | + |
| 34 | +## Objects that use Semantic Tags |
| 35 | + |
| 36 | +Semantic tags can be applied to the following openHAB objects with a chain of inheritance as follows: |
| 37 | + |
| 38 | +- `Channel-Type` : POINT/PROPERTY tags applied at design time via the `channel-type.xml`. |
| 39 | +- `Channel` : POINT/PROPERTY tags inherited from the `Channel-Type` above, and/or applied at run time by the binding Java code. |
| 40 | +- `Item` : POINT/PROPERTY tags inherited from the `Channel` above, and/or all types of tags applied users when setting up their system. |
| 41 | +- `Thing-Type` : EQUIPMENT tag (single) applied at design time in the `thing-type.xml`. |
| 42 | +- `Thing`: EQUIPMENT tag inherited from the `Thing-Type` above, and/or applied at run time by the binding Java code. |
| 43 | +- `Semantic Model`: EQUIPMENT tree structure ("create equipment from thing") inherited from the `Thing` above, and/or by users. |
| 44 | + |
| 45 | +## General Rules for Semantic Tags |
| 46 | + |
| 47 | +The list of semantic tags defined in openHAB Core is extensible. |
| 48 | +This document describes the developer rules for applying or extending this list. |
| 49 | + |
| 50 | +The core predefined semantic tags are presented to users as propositions, suggestions, or hints. |
| 51 | +It is possible for users to add their own customised tags at their own discretion. |
| 52 | +The remainder of this document does NOT relate to user customised tags. |
| 53 | +It applies solely to the openHAB Core tags. |
| 54 | + |
| 55 | +This following uses terms "MUST", "MAY", "SHALL", "SHALL NOT", etc. that are defined in Internet Standard [RFC-2119](https://datatracker.ietf.org/doc/html/rfc2119) |
| 56 | + |
| 57 | +### A. Rules for **APPLYING** Core Predefined Semantic Tags |
| 58 | + |
| 59 | +1. Developers MUST apply core predefined tags in their addons where possible. |
| 60 | +1. Developers MAY hard code the tags in the `thing-type.xml` or apply them dynamically at run time via the Java code. |
| 61 | +1. Developers SHALL NOT apply LOCATION tags either in the `thing-type.xml`, or via the Java code. |
| 62 | +1. Developers SHALL NOT apply customised tags in their addons. |
| 63 | +1. Developers MAY apply a POINT tag without a PROPERTY tag (in cases where a property makes no sense). However, in such a case the developer MAY submit a new PROPERTY tag that fits. |
| 64 | +1. Developers SHALL NOT apply a PROPERTY tag without a POINT tag. |
| 65 | +1. Semantic EQUIPMENT tags MUST be applied at the thing level. |
| 66 | +1. Semantic POINT and PROPERTY tags MUST be applied at channel level. |
| 67 | +1. Developers MAY open a new PR to propose extensions to the core predefined tags as follows. |
| 68 | + |
| 69 | +### B. Rules for **EXTENDING** Core Predefined Semantic Tags |
| 70 | + |
| 71 | +The purpose of the semantic model is to provide a stable base set of tags for binding authors to use. |
| 72 | +Submiting and adopting new tags should be a rare occurance. |
| 73 | + |
| 74 | +1. New tags MUST fit within the hierarchy of semantic tags already defined in openHAB Core. |
| 75 | +1. New tags SHALL NOT be synonyms of existing tags e.g. kitchen/kitchenette, sitting/living room. |
| 76 | +1. New PROPERTY, POINT and EQUIPMENT tags SHOULD aim to be applicable across more than one binding. |
| 77 | +1. Developers MUST provide supporting arguments in their PR that the rules above and below are met. |
| 78 | + |
| 79 | +## C. Rules for extending EQUIPMENT Tags |
| 80 | + |
| 81 | +An EQUIPMENT tag describes the equipment type of a piece of equipment. |
| 82 | +Examples are thermostat, pump, car, wall switch, push button, alarm system, or alarm detector. |
| 83 | + |
| 84 | +1. New EQUIPMENT tags MUST describe the equipment type of a physical or virtual device. |
| 85 | +1. New EQUIPMENT tags MUST be a noun. |
| 86 | + |
| 87 | +## D. Rules for extending POINT Tags |
| 88 | + |
| 89 | +A POINT is a tag that describes the functional type (or purpose) of a data point within an equipment. |
| 90 | +Examples are measurement, control, set point, or status. |
| 91 | + |
| 92 | +1. New POINT tags MUST describe the functional type (or purpose) of the data point. |
| 93 | +1. New POINT tags MUST be what you (the binding) does to, or how you (the binding) gets, the state of the Item. |
| 94 | +1. New POINT tags SHOULD be defined in conjunction with an information type in a PROPERTY tag. See examples [below](#examples-of-point-and-property-tags). |
| 95 | + |
| 96 | +## E. Rules for extending PROPERTY Tags |
| 97 | + |
| 98 | +A PROPERTY is a tag that describes the information type (or content type) of the data produced or consumed by a point. |
| 99 | +Examples are temperature, brightness, on-off, time stamp. |
| 100 | + |
| 101 | +1. New PROPERTY tags MUST describe the information type (or content type) of the point. |
| 102 | +1. New PROPERTY tags MUST be a noun and represent some attribute commonly controlled or sensed in a home automation context. |
| 103 | +1. New PROPERTY tags MUST be defined in conjunction with the functional type of a POINT tag. See examples below. |
| 104 | + |
| 105 | +### Examples of Point and Property Tags: |
| 106 | + |
| 107 | +- A humidity sensor would have POINT=`Measurement` plus PROPERTY=`Humidity`. |
| 108 | +- A thermostat's target temperature would have POINT=`Setpoint` plus PROPERTY=`Temperature`. |
| 109 | +- A smoke alarm would have POINT=`Alarm` plus PROPERTY=`Smoke`. |
| 110 | + |
| 111 | +## F. Rules for extending LOCATION Tags |
| 112 | + |
| 113 | +A LOCATION is a tag that describes the location type of a point. |
| 114 | +Its most common use case is to assign equipment to a location. |
| 115 | +Examples are ground floor, dining (eating) room, kitchen (cooking room), living room, or garage. |
| 116 | + |
| 117 | +1. New LOCATION tags SHALL NOT be synonyms of existing tags (see [rule B.2.](#b-rules-for-extending-core-predefined-semantic-tags)) |
0 commit comments