|
| 1 | +# Meta |
| 2 | + |
| 3 | +Version: **<!--VERSION-->1.1.0<!--VERSION-->** |
| 4 | +Date: **<!--DATE-->12. Jul 2019<!--DATE-->** |
| 5 | +Authors: **<!--AUTHORS-->[EPNW](https://epnw.eu)<!--AUTHORS-->** |
| 6 | +License: **<!--LICENSE-->[CCA 4.0](https://homieiot.github.io/license)<!--LICENSE-->** |
| 7 | + |
| 8 | +## Abstract |
| 9 | +This extension defines how to add metadata and tags to devices, nodes and properties. |
| 10 | + |
| 11 | +Tags are simple annotations that every device, node oder property can have. |
| 12 | +Metadata on the other hand are more complex. They allow the definition of multiple *mainkeys* and *mainvalues* for each device, node or property. |
| 13 | +Each main-key-value-pair may have nested sub-key-value-pairs. |
| 14 | +Having metadata might be useful for Homie controllers. |
| 15 | +A concrete usecase is the openHAB controller, which relies on metadata and tags to make voice assistants like Amazons Alexa or the Google Assistant able to control it. |
| 16 | +With this extension, properties are able to advertise how they want to be treated. |
| 17 | + |
| 18 | +## Homie Version |
| 19 | +This extension supports Homie `3.0.1` and `4.x`. |
| 20 | + |
| 21 | +## Extension Identifier |
| 22 | +The ID of this extension is `eu.epnw.meta`. |
| 23 | +Therefore the **$extensions entry** is `eu.epnw.meta:1.1.0:[3.0.1;4.x]`. |
| 24 | + |
| 25 | +## Extension Datatypes |
| 26 | +This extension defines no new datatypes. |
| 27 | + |
| 28 | +## Extension Attributes |
| 29 | + |
| 30 | +### Extension Attributes for any kind of Items |
| 31 | + |
| 32 | +The following attributes are all **optional** and may be added to any kind of item (devices, nodes or properties). |
| 33 | + |
| 34 | +| Topic | Description | Payload type | Default value| |
| 35 | +|----------------------|-----------------------------|----------------------------|--------------| |
| 36 | +| $tags | List of *tags* for the item | Comma (`,`) separated list | | |
| 37 | +| $meta/$mainkey-ids | List of IDs for *mainkeys* | Comma (`,`) separated list | | |
| 38 | + |
| 39 | +Since *tags* are represented by a comma separated list, a limitation is that a tag itself MUST NOT contain a comma. |
| 40 | +The elements in the `$mainkey-ids` list are **not** the names of the keys. |
| 41 | +Instead, these entries are just used for topic IDs. |
| 42 | +Therefore, the entries have to be valid topic IDs (see [the Homie convention](https://homieiot.github.io/specification/#topic-ids))! |
| 43 | + |
| 44 | +**Examples** |
| 45 | +Assuming the base topic is *homie*, device ID is *super-car*, the node is *engine* and the property is *temperature* then: |
| 46 | +```java |
| 47 | +homie/super-car/engine/temperature/$meta/$mainkey-ids → "alexa,homekit" |
| 48 | +homie/super-car/engine/temperature/$tags → "Lighting,Switchable,Thermostat" |
| 49 | +``` |
| 50 | + |
| 51 | +For each element in the `$mainkey-ids` list, two nested attributes are **required**: |
| 52 | + |
| 53 | +| Topic | Description | Payload type | |
| 54 | +|---------------------------|-----------------------------------|--------------| |
| 55 | +| $meta/*mainkey id*/$key | The *mainkey*s name | String | |
| 56 | +| $meta/*mainkey id*/$value | The *mainvalue* for the *mainkey* | String | |
| 57 | + |
| 58 | +**Examples** |
| 59 | +With respect to the previous example: |
| 60 | +```java |
| 61 | +homie/super-car/engine/temperature/$meta/0/$key → "HomeKit" |
| 62 | +homie/super-car/engine/temperature/$meta/0/$value → "Fan.v2" |
| 63 | +homie/super-car/engine/temperature/$meta/1/$key → "Alexa" |
| 64 | +homie/super-car/engine/temperature/$meta/1/$value → "Fan" |
| 65 | +``` |
| 66 | + |
| 67 | +Notice that in this example, the *mainkey ids* are *alexa* and *homekit*, but the actual key names are *Alexa* and *HomeKit*. |
| 68 | + |
| 69 | +A *mainkey* can have an arbitrary number of *subkeys*. |
| 70 | +Analogous to how *mainkeys* are advertised, each *mainkey* may have an **optional** list of *subkey ids*: |
| 71 | + |
| 72 | +| Topic | Description | Payload type | Default value | |
| 73 | +|-------------------------------|--------------------------------------------|--------------|---------------| |
| 74 | +| $meta/*mainkey id*/$subkey-ids | List of IDs for *subkeys* | Comma (`,`) separated list | | |
| 75 | + |
| 76 | +Again, elements in the `$subkey-ids` list are **not** the names of the keys, and have to be valid topic IDs. |
| 77 | + |
| 78 | +**Examples** |
| 79 | +With respect to the previous example: |
| 80 | +```java |
| 81 | +homie/super-car/engine/temperature/$meta/alexa/$subkey-ids → "type,step-speed" |
| 82 | +``` |
| 83 | + |
| 84 | +For each element in the `$subkey-ids` list, two nested attributes are **required**: |
| 85 | + |
| 86 | +| Topic | Description | Payload type | |
| 87 | +|---------------------------------------|--------------------------------------|--------------| |
| 88 | +| $meta/*mainkey id*/*subkey id*/$key | The *subkey*s name | String | |
| 89 | +| $meta/*mainkey id*/*subkey id*/$value | Value for the *subkey* | String | |
| 90 | + |
| 91 | + |
| 92 | +**Examples** |
| 93 | +With respect to the previous example: |
| 94 | +```java |
| 95 | +homie/super-car/engine/temperature/$meta/alexa/type/$key → "type" |
| 96 | +homie/super-car/engine/temperature/$meta/alexa/type/$value → "oscillating" |
| 97 | +homie/super-car/engine/temperature/$meta/alexa/step-speed/$key → "stepSpeed" |
| 98 | +homie/super-car/engine/temperature/$meta/alexa/step-speed/$value → "3" |
| 99 | +``` |
0 commit comments