Skip to content

Commit ae491a7

Browse files
authored
Extra fields for addon discovery in addon.xml (#2150)
* Add description of discovery-methods Signed-off-by: Andrew Fiddian-Green <[email protected]> * Add description of discovery-methods Signed-off-by: Andrew Fiddian-Green <[email protected]> * [developers-addons-addon] fix markdown errors Signed-off-by: Andrew Fiddian-Green <[email protected]> --------- Signed-off-by: Andrew Fiddian-Green <[email protected]>
1 parent b86d502 commit ae491a7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

developers/addons/addon.md

+42
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ If the add-on consists of more than one bundle, only one `addon.xml` is allowed
3838
OR
3939
<config-description-ref uri="{addon|thing-type|channel-type|any_other}:addonID:..." />
4040

41+
<discovery-methods>
42+
...
43+
</discovery-methods>
44+
4145
</addon:addon>
4246
```
4347

@@ -53,6 +57,7 @@ If the add-on consists of more than one bundle, only one `addon.xml` is allowed
5357
| config-description | The configuration description for the binding within the ConfigDescriptionRegistry (cf. [Configuration Description](config-xml.html)) | optional |
5458
| config-description-ref | The reference to a configuration description for the binding within the ConfigDescriptionRegistry | optional |
5559
| config-description-ref.uri | The URI of the configuration description for the binding within the ConfigDescriptionRegistry | mandatory |
60+
| discovery-methods | A set of xml elements that describe how the system can scan the network to discover present devices | optional |
5661

5762
The full XML schema for add-on definitions is specified in the [Add-on XSD](https://openhab.org/schemas/addon-1.0.0.xsd) file.
5863

@@ -63,6 +68,27 @@ The full XML schema for add-on definitions is specified in the [Add-on XSD](http
6368
- Normally the service id must not be defined, because it is implicitly set to "type.&lt;addonId&gt;".
6469
An add-on can register an OSGi service which implements the ManagedService interface and define the service.pid as e.g."binding.hue" to receive the configuration.
6570

71+
### Discovery Methods
72+
73+
The system can scan the network for present devices to determine if it should suggest to install specific addons during setup.
74+
Optionally, if you want the system to scan the user's network for your addon then you need to include additional `discovery-method` fields.
75+
76+
| XML Element Name | Description | Instances |
77+
|---------------------|-------------------------------------------------------------------------------|------------------------------------------------|
78+
| `discovery-methods` | Wrapper for `discovery-method` elements (see below). | Zero or one instances per file. |
79+
| `discovery-method` | Complex XML element describing an addon discovery method. | Zero or more instances per file. |
80+
| `service-type` | The type of discovery method. May be `upnp` or `mdns`. | Mandatory one per `discovery-method`. |
81+
| `mdns-service-type` | If `service-type` is `mdns`, contains the MDNS discovery service type. | Optional one per `discovery-method`. |
82+
| `match-properties` | Wrapper for `match-property` elements (see below). | Zero or one instances per `discovery-method`. |
83+
| `match-property` | A property name and regular expression used for matching discovery findings. | Zero or more instances per `discovery-method`. |
84+
| `name` | A property name to search for. | Mandatory one instance per `match-property`. |
85+
| `regex` | A regular expression (or plain string) that needs to match the property name. | Mandatory one instance per `match-property`. |
86+
87+
Notes:
88+
89+
- A `discovery-method` may contain multiple `match-property` entries, and in such a case **all** entries must match i.e. it a logical `AND` function is applied.
90+
- If you want to apply a logical `OR` function you can define a second separate `discovery-method` containing the respective `match-property` entry.
91+
6692
## Example
6793

6894
The following code gives an example for an add-on definition used in bindings.
@@ -81,5 +107,21 @@ The following code gives an example for an add-on definition used in bindings.
81107

82108
<connection>local</connection>
83109

110+
<discovery-methods>
111+
<discovery-method>
112+
<serviceType>mdns</serviceType>
113+
<mdnsServiceType>_hue._tcp.local.</mdnsServiceType>
114+
</discovery-method>
115+
<discovery-method>
116+
<service-type>upnp</service-type>
117+
</match-properties>
118+
<match-property>
119+
<name>modelName</name>
120+
<regex>Philips hue bridge</regex>
121+
</match-property>
122+
</match-properties>
123+
</discovery-method>
124+
</discovery-methods>
125+
84126
</addon:addon>
85127
```

0 commit comments

Comments
 (0)