The Device Templates configuration automatically applies standard configurations to multiple devices.
Overview
The Device Template configuration cannot work in the flat model and is available only for the specific hierarchy case. The Device Templates configuration automatically configures your devices based on a criteria that you can define in the form of an XML file. It allows you to:
The Home Device Manager will configure all devices that match a given template, as soon as they become accessible.
Creating Configuration XML File
Write/generate the configuration XML file according to the schema definitions:
Creating a Template
The configuration XML can contain one or several templates and hence enables you to configure several devices/groups.
To define a template in the configuration:
In your XML file insert a config element with attribute name equal to Template<index> , where <index> is an integer that specifies the template's priority.
The following example defines a ConfigTree configuration that contains two empty device templates (The role of theGroup element is explained below).
<config name="DeviceTemplates">
<config name="Group">
<config name="Template1">
<!--Define template here-->
</config>
<config name="Template1">
<!--Define second template here-->
</config>
</config>
</config>
A working template must contain two elements: a <Filter/> element that identifies the target device or devices and a <Configuration/> element, which contains the configuration that should be applied to them.
First, specify the criteria for selecting Home Devices that should be configured by the template. You may specify your target Home Devices by their device properties.
To specify the criteria:
In your template, insert a config element with attribute name equal to Filter. The filter contains the properties by which the target devices are identified. The properties can be defined as a list of key-value pairs and also as an LDAP filter.
The following examples contains a template which matches all ZigBee devices which are manufactured by ACME:
<config name="DeviceTemplates">
<config name="Group">
<config name="Template1">
<config name="Filter">
<property key="vendor" value="ACME" type="string"/>
<property key="adapter" value="ZigBee" type="string"/>
</config>
<!--Define the rest of the template here-->
</config>
</config>
</config>
<config name="DeviceTemplates">
<config name="Group">
<config name="Template1">
<property key="filter" value="(&(vendor=ACME)(adapter=ZigBee))" type="string"/>
</config>
<!--Define the rest of the template here-->
</config>
</config>
After the target devices are identified you may configure them by modifying the properties their Home Device objects and by changing the properties and executing operations on their Device Class Objects. To do that:
In your template, insert a config element with attribute name equal to Configuration<index> where <index> is an integer that specifies the configuration's priority. You may apply several configurations to the same device or set of devices. The
To configure the Home Devices properties of your target devices:
In the Configuration element, insert a config element with attribute name equal to Properties and in it, specify the keys of the properties you want to modify/add, along with their values.
To configure the properties of the Device Class Objects of your target devices:
In the Configuration element, insert a config element with attribute name equal to DeviceClasses and it, add a config element for each device class whose properties you want to modify.
The following example contains a full template which sets one property of the matched Home Device objects and executes one operation to all Binary Switches that are attached to them.
Grouping Templates
By default when a new Configuration XML file is loaded in ConfigTree all the data from the old one is overwritten. You can avoid this by separating your device templates into groups so when a new file is loaded, it will overwrite only templates from same groups as the ones that are imported.
The following example contains two groups of templates Group1 and Group2. If it is loaded in ConfigTree, it will only overwrite the templates that are under these two groups (if any).
<config name="DeviceTemplates">
<config name="Group1">
<config name="Template1">
<!--Define template here-->
</config>
<config name="Template2">
<!--Define template here-->
</config>
</config>
<config name="Group2">
<config name="Template3">
<!--Define template here-->
</config>
</config>
</config>
Template Fail Behavior
If the Home Device Manager fails to apply your template to a given device (for example if the device is not initialized, or the network is unstable), it waits one minute an then tries to apply it again 1 more time.
If you want to change this behavior, insert a config element with attribute name equal to Retry and in it, set values to the following properties:
Key |
Type |
Description |
Default Value |
|---|---|---|---|
retries |
int |
How many times should the Home Device Manager try to apply the configuration again, if it fails the first time. |
1 |
interval |
long |
Amount of time the Home Device Manager waits before it tries to apply the configuration again. |
60000 |
apply.all |
boolean |
Value true means the Home Device Manager will try to apply the whole configuration again. Value false - it will try to apply only those properties/operations that weren't configured. |
false |
You can insert the Retry element in any Template element in order to change its behavior or insert it in a Group element, to change the behavior of all templates in the group.
The following example contains one Retry element which affects all templates from Group1, which means that if the Home Device Manager fails to apply them, it will try to do it 5 more times with a 30-second pause before each try.
<config name="DeviceTemplates">
<config name="Group1">
<config name="Retry">
<property key="retries" value="5" type="int">
<property key="interval" value="30000" type="long">
</config>
<config name="Template1"></config>
<config name="Template2"></config>
</config>
<config name="Group2">
<config name="Template3"></config>
</config>
</config>
Online devices with pending configuration return status: NOT_CONFIGURED.
Applying Templates Configuration
To apply your templates import the XML file in the DeviceTemplates configuration in ConfigTree.